diff --git a/run-autopep8.sh b/run-autopep8.sh index 701a6c0d..e879318f 100755 --- a/run-autopep8.sh +++ b/run-autopep8.sh @@ -1,2 +1,2 @@ #!/bin/sh -autopep8 --in-place --recursive src src/bitmessageqt +autopep8 --in-place --recursive src diff --git a/src/bitmessageqt/__init__.py b/src/bitmessageqt/__init__.py index dd922a25..aaf2f243 100644 --- a/src/bitmessageqt/__init__.py +++ b/src/bitmessageqt/__init__.py @@ -53,7 +53,7 @@ import shutdown from .statusbar import BMStatusBar import bitmessageqt.sound as sound # This is needed for tray icon -import bitmessageqt.bitmessage_icons_rc as bitmessage_icons_rc # noqa:F401 pylint: disable=unused-import +import bitmessageqt.bitmessage_icons_rc as bitmessage_icons_rc # noqa:F401 pylint: disable=unused-import import helper_sent try: @@ -152,9 +152,8 @@ class MyForm(settingsmixin.SMainWindow): self.ui.actionNetworkSwitch.triggered.connect(self.network_switch) self.ui.actionManageKeys.triggered.connect(self.click_actionManageKeys) self.ui.actionDeleteAllTrashedMessages.triggered.connect(self.click_actionDeleteAllTrashedMessages) - self.ui.actionRegenerateDeterministicAddresses.triggered.connect( - self.click_actionRegenerateDeterministicAddresses) - self.ui.pushButtonAddChan.clicked.connect(self.click_actionJoinChan) # also used for creating chans. + self.ui.actionRegenerateDeterministicAddresses.triggered.connect(self.click_actionRegenerateDeterministicAddresses) + self.ui.pushButtonAddChan.clicked.connect(self.click_actionJoinChan) # also used for creating chans. self.ui.pushButtonNewAddress.clicked.connect(self.click_NewAddressDialog) self.ui.pushButtonAddAddressBook.clicked.connect(self.click_pushButtonAddAddressBook) self.ui.pushButtonAddSubscription.clicked.connect(self.click_pushButtonAddSubscription) @@ -753,11 +752,11 @@ class MyForm(settingsmixin.SMainWindow): # Put the TTL slider in the correct spot TTL = config.getint('bitmessagesettings', 'ttl') - if TTL < 3600: # an hour + if TTL < 3600: # an hour TTL = 3600 - elif TTL > 28 * 24 * 60 * 60: # 28 days - TTL = 28 * 24 * 60 * 60 - self.ui.horizontalSliderTTL.setSliderPosition(int((TTL - 3600) ** (1 / 3.199))) + elif TTL > 28*24*60*60: # 28 days + TTL = 28*24*60*60 + self.ui.horizontalSliderTTL.setSliderPosition(int((TTL - 3600) ** (1/3.199))) self.updateHumanFriendlyTTLDescription(TTL) self.ui.horizontalSliderTTL.valueChanged.connect(self.updateTTL) @@ -816,20 +815,20 @@ class MyForm(settingsmixin.SMainWindow): config.save() def updateHumanFriendlyTTLDescription(self, TTL): - numberOfHours = int(round(TTL / (60 * 60))) + numberOfHours = int(round(TTL / (60*60))) font = QtGui.QFont() stylesheet = "" if numberOfHours < 48: self.ui.labelHumanFriendlyTTLDescription.setText( - _translate("MainWindow", "%n hour(s)", None, numberOfHours) - + ", " - + _translate("MainWindow", "not recommended for chans", None) - ) + _translate("MainWindow", "%n hour(s)", None, numberOfHours) + + ", " + + _translate("MainWindow", "not recommended for chans", None) + ) stylesheet = "QLabel { color : red; }" font.setBold(True) else: - numberOfDays = int(round(TTL / (24 * 60 * 60))) + numberOfDays = int(round(TTL / (24*60*60))) self.ui.labelHumanFriendlyTTLDescription.setText( _translate( "MainWindow", @@ -1105,7 +1104,7 @@ class MyForm(settingsmixin.SMainWindow): else: statusText = _translate( "MainWindow", "Unknown status: {0} {1}").format(status, - l10n.formatTimestamp(lastactiontime)) + l10n.formatTimestamp(lastactiontime)) items = [ MessageList_AddressWidget( @@ -1222,7 +1221,7 @@ class MyForm(settingsmixin.SMainWindow): # create application indicator def appIndicatorInit(self, app): self.initTrayIcon("can-icon-24px-red.png", app) - self.tray.activated.connect(self.__icon_activated) + self.tray.activated.connect(self.__icon_activated); m = QtWidgets.QMenu() @@ -1393,7 +1392,7 @@ class MyForm(settingsmixin.SMainWindow): self._notifier = _simple_notify # does nothing if isAvailable returns false # XXX unresolved - # self._player = QtGui.QSound.play + #self._player = QtGui.QSound.play if not get_plugins: return @@ -1407,7 +1406,7 @@ class MyForm(settingsmixin.SMainWindow): self._theme_player = get_plugin('notification.sound', 'theme') # XXX unresolved - # if not QtGui.QSound.isAvailable(): + #if not QtGui.QSound.isAvailable(): if not False: _plugin = get_plugin( 'notification.sound', 'file', fallback='file.fallback') @@ -1780,7 +1779,7 @@ class MyForm(settingsmixin.SMainWindow): pen.setBrush(QtGui.QBrush(QtCore.Qt.BrushStyle.SolidPattern)) painter.setPen(pen) painter.setFont(font) - painter.drawText(24 - rect.right() - marginX, -rect.top() + marginY, txt) + painter.drawText(24-rect.right()-marginX, -rect.top()+marginY, txt) painter.end() return QtGui.QIcon(pixmap) @@ -1857,7 +1856,7 @@ class MyForm(settingsmixin.SMainWindow): try: newlinePosition = textToDisplay.indexOf('\n') except: - # If someone misses adding a "_translate" to a string before passing it to this function, + # If someone misses adding a "_translate" to a string before passing it to this function, # this function won't receive a qstring which will cause an exception. newlinePosition = 0 if newlinePosition > 1: @@ -1894,7 +1893,7 @@ class MyForm(settingsmixin.SMainWindow): "MainWindow", "New version of PyBitmessage is available: {0}. Download it" " from https://github.com/Bitmessage/PyBitmessage/releases/latest" - ).format(self.notifiedNewVersion) + ).format(self.notifiedNewVersion) ) def displayAlert(self, title, text, exitAfterUserClicksOk): @@ -1918,7 +1917,7 @@ class MyForm(settingsmixin.SMainWindow): messagelist.item(i, 0).setLabel() def rerenderAddressBook(self): - def addRow(address, label, type): + def addRow (address, label, type): self.ui.tableWidgetAddressBook.insertRow(0) newItem = Ui_AddressBookWidgetItemLabel(address, label, type) self.ui.tableWidgetAddressBook.setItem(0, 0, newItem) @@ -2066,14 +2065,14 @@ class MyForm(settingsmixin.SMainWindow): "MainWindow", "You are trying to send an email instead of a bitmessage. " "This requires registering with a gateway. Attempt to register?"), - QtWidgets.QMessageBox.StandardButton.Yes | QtWidgets.QMessageBox.StandardButton.No) != QtWidgets.QMessageBox.StandardButton.Yes: + QtWidgets.QMessageBox.StandardButton.Yes|QtWidgets.QMessageBox.StandardButton.No) != QtWidgets.QMessageBox.StandardButton.Yes: continue email = acct.getLabel() - if email[-14:] != "@mailchuck.com": # attempt register + if email[-14:] != "@mailchuck.com": # attempt register # 12 character random email address email = ''.join( random.SystemRandom().choice(string.ascii_lowercase) for _ in range(12) - ) + "@mailchuck.com" + ) + "@mailchuck.com" acct = MailchuckAccount(fromAddress) acct.register(email) config.set(fromAddress, 'label', email) @@ -2085,7 +2084,7 @@ class MyForm(settingsmixin.SMainWindow): " an email gateway. Sending registration" " now as {0}, please wait for the registration" " to be processed before retrying sending." - ).format(email) + ).format(email) ) return status, addressVersionNumber, streamNumber = decodeAddress(toAddress)[:3] @@ -2101,19 +2100,19 @@ class MyForm(settingsmixin.SMainWindow): "MainWindow", "Error: Bitmessage addresses start with" " BM- Please check the recipient address {0}" - ).format(toAddress)) + ).format(toAddress)) elif status == 'checksumfailed': self.updateStatusBar(_translate( "MainWindow", "Error: The recipient address {0} is not" " typed or copied correctly. Please check it." - ).format(toAddress)) + ).format(toAddress)) elif status == 'invalidcharacters': self.updateStatusBar(_translate( "MainWindow", "Error: The recipient address {0} contains" " invalid characters. Please check it." - ).format(toAddress)) + ).format(toAddress)) elif status == 'versiontoohigh': self.updateStatusBar(_translate( "MainWindow", @@ -2121,7 +2120,7 @@ class MyForm(settingsmixin.SMainWindow): " {0} is too high. Either you need to upgrade" " your Bitmessage software or your" " acquaintance is being clever." - ).format(toAddress)) + ).format(toAddress)) elif status == 'ripetooshort': self.updateStatusBar(_translate( "MainWindow", @@ -2129,7 +2128,7 @@ class MyForm(settingsmixin.SMainWindow): " address {0} is too short. There might be" " something wrong with the software of" " your acquaintance." - ).format(toAddress)) + ).format(toAddress)) elif status == 'ripetoolong': self.updateStatusBar(_translate( "MainWindow", @@ -2137,7 +2136,7 @@ class MyForm(settingsmixin.SMainWindow): " address {0} is too long. There might be" " something wrong with the software of" " your acquaintance." - ).format(toAddress)) + ).format(toAddress)) elif status == 'varintmalformed': self.updateStatusBar(_translate( "MainWindow", @@ -2145,13 +2144,13 @@ class MyForm(settingsmixin.SMainWindow): " address {0} is malformed. There might be" " something wrong with the software of" " your acquaintance." - ).format(toAddress)) + ).format(toAddress)) else: self.updateStatusBar(_translate( "MainWindow", "Error: Something is wrong with the" " recipient address {0}." - ).format(toAddress)) + ).format(toAddress)) elif fromAddress == '': self.updateStatusBar(_translate( "MainWindow", @@ -2307,7 +2306,7 @@ class MyForm(settingsmixin.SMainWindow): i, AccountColor(address).accountColor(), QtCore.Qt.ItemDataRole.ForegroundRole) self.ui.comboBoxSendFrom.insertItem(0, '', '') - if (self.ui.comboBoxSendFrom.count() == 2): + if(self.ui.comboBoxSendFrom.count() == 2): self.ui.comboBoxSendFrom.setCurrentIndex(1) else: self.ui.comboBoxSendFrom.setCurrentIndex(0) @@ -2330,7 +2329,7 @@ class MyForm(settingsmixin.SMainWindow): i, AccountColor(address).accountColor(), QtCore.Qt.ItemDataRole.ForegroundRole) self.ui.comboBoxSendFromBroadcast.insertItem(0, '', '') - if (self.ui.comboBoxSendFromBroadcast.count() == 2): + if(self.ui.comboBoxSendFromBroadcast.count() == 2): self.ui.comboBoxSendFromBroadcast.setCurrentIndex(1) else: self.ui.comboBoxSendFromBroadcast.setCurrentIndex(0) @@ -2660,13 +2659,13 @@ class MyForm(settingsmixin.SMainWindow): "MainWindow", "%n object(s) pending proof of work", None, powQueueSize() - ) + ", " - + _translate( + ) + ", " + + _translate( "MainWindow", "%n object(s) waiting to be distributed", None, pendingUpload() - ) + "\n\n" - + _translate( + ) + "\n\n" + + _translate( "MainWindow", "Wait until these tasks finish?"), QtWidgets.QMessageBox.StandardButton.Yes | QtWidgets.QMessageBox.StandardButton.No | QtWidgets.QMessageBox.StandardButton.Cancel, QtWidgets.QMessageBox.StandardButton.Cancel) @@ -2749,8 +2748,8 @@ class MyForm(settingsmixin.SMainWindow): if curWorkerQueue > 0: self.updateStatusBar(_translate( "MainWindow", "Waiting for PoW to finish... {0}%" - ).format(50 * (maxWorkerQueue - curWorkerQueue) - / maxWorkerQueue)) + ).format(50 * (maxWorkerQueue - curWorkerQueue) / + maxWorkerQueue)) time.sleep(0.5) QtCore.QCoreApplication.processEvents( QtCore.QEventLoop.ProcessEventsFlag.AllEvents, 1000 @@ -2856,10 +2855,10 @@ class MyForm(settingsmixin.SMainWindow): lines[i]) elif lines[i] == '------------------------------------------------------': lines[i] = '
' - elif lines[i] == '' and (i + 1) < totalLines and \ - lines[i + 1] != '------------------------------------------------------': + elif lines[i] == '' and (i+1) < totalLines and \ + lines[i+1] != '------------------------------------------------------': lines[i] = '

' - content = ' '.join(lines) # To keep the whitespace between lines + content = ' '.join(lines) # To keep the whitespace between lines content = shared.fixPotentiallyInvalidUTF8Data(content) content = content textEdit.setHtml(content) @@ -3018,8 +3017,8 @@ class MyForm(settingsmixin.SMainWindow): toAddressAtCurrentInboxRow = fromAddressAtCurrentInboxRow if fromAddressAtCurrentInboxRow == \ tableWidget.item(currentInboxRow, column_from).label or ( - isinstance(acct, GatewayAccount) - and fromAddressAtCurrentInboxRow == acct.relayAddress): + isinstance(acct, GatewayAccount) and + fromAddressAtCurrentInboxRow == acct.relayAddress): self.ui.lineEditTo.setText(str(acct.fromAddress)) else: self.ui.lineEditTo.setText( @@ -3205,7 +3204,7 @@ class MyForm(settingsmixin.SMainWindow): defaultFilename = "".join(x for x in subjectAtCurrentInboxRow if x.isalnum()) + '.txt' filename = QtWidgets.QFileDialog.getSaveFileName( self, - _translate("MainWindow", "Save As..."), + _translate("MainWindow","Save As..."), defaultFilename, "Text files (*.txt);;All files (*.*)") if filename == '': @@ -3663,8 +3662,8 @@ class MyForm(settingsmixin.SMainWindow): otherAddress = tableWidget.item(currentRow, 1).data(QtCore.Qt.ItemDataRole.UserRole) account = accountClass(myAddress) if isinstance(account, GatewayAccount) and otherAddress == account.relayAddress and ( - (currentColumn in [0, 2] and self.getCurrentFolder() == "sent") - or (currentColumn in [1, 2] and self.getCurrentFolder() != "sent")): + (currentColumn in [0, 2] and self.getCurrentFolder() == "sent") or + (currentColumn in [1, 2] and self.getCurrentFolder() != "sent")): text = str(tableWidget.item(currentRow, currentColumn).label) else: text = tableWidget.item(currentRow, currentColumn).data(QtCore.Qt.ItemDataRole.UserRole) diff --git a/src/bitmessageqt/address_dialogs.py b/src/bitmessageqt/address_dialogs.py index 30af4d9e..29bfc50a 100644 --- a/src/bitmessageqt/address_dialogs.py +++ b/src/bitmessageqt/address_dialogs.py @@ -216,7 +216,6 @@ class NewSubscriptionDialog(AddressDataDialog): class RegenerateAddressesDialog(QtWidgets.QDialog): """QDialog for regenerating deterministic addresses""" - def __init__(self, parent=None): super(RegenerateAddressesDialog, self).__init__(parent) widgets.load('regenerateaddresses.ui', self) @@ -289,7 +288,6 @@ class SpecialAddressBehaviorDialog(QtWidgets.QDialog): class EmailGatewayDialog(QtWidgets.QDialog): """QDialog for email gateway control""" - def __init__(self, parent, config=global_config, account=None): super(EmailGatewayDialog, self).__init__(parent) widgets.load('emailgateway.ui', self) diff --git a/src/bitmessageqt/addressvalidator.py b/src/bitmessageqt/addressvalidator.py index f02faf04..9785c3a2 100644 --- a/src/bitmessageqt/addressvalidator.py +++ b/src/bitmessageqt/addressvalidator.py @@ -16,7 +16,6 @@ from .utils import str_chan class AddressPassPhraseValidatorMixin(object): """Bitmessage address or passphrase validator class for Qt UI""" - def setParams( self, passPhraseObject=None, @@ -170,7 +169,6 @@ class AddressPassPhraseValidatorMixin(object): class AddressValidator(QtGui.QValidator, AddressPassPhraseValidatorMixin): """AddressValidator class for Qt UI""" - def __init__(self, parent=None, passPhraseObject=None, feedBackObject=None, buttonBox=None, addressMandatory=True): super(AddressValidator, self).__init__(parent) self.setParams(passPhraseObject, parent, feedBackObject, buttonBox, addressMandatory) @@ -178,7 +176,6 @@ class AddressValidator(QtGui.QValidator, AddressPassPhraseValidatorMixin): class PassPhraseValidator(QtGui.QValidator, AddressPassPhraseValidatorMixin): """PassPhraseValidator class for Qt UI""" - def __init__(self, parent=None, addressObject=None, feedBackObject=None, buttonBox=None, addressMandatory=False): super(PassPhraseValidator, self).__init__(parent) self.setParams(parent, addressObject, feedBackObject, buttonBox, addressMandatory) diff --git a/src/bitmessageqt/bitmessage_icons_rc.py b/src/bitmessageqt/bitmessage_icons_rc.py index 549b3e61..a06fd964 100644 --- a/src/bitmessageqt/bitmessage_icons_rc.py +++ b/src/bitmessageqt/bitmessage_icons_rc.py @@ -1666,13 +1666,10 @@ qt_resource_struct = b"\ \x00\x00\x01\xe6\x00\x00\x00\x00\x00\x01\x00\x00\x34\xdf\ " - def qInitResources(): QtCore.qRegisterResourceData(0x01, qt_resource_struct, qt_resource_name, qt_resource_data) - def qCleanupResources(): QtCore.qUnregisterResourceData(0x01, qt_resource_struct, qt_resource_name, qt_resource_data) - qInitResources() diff --git a/src/bitmessageqt/bitmessageui.py b/src/bitmessageqt/bitmessageui.py index 268b4ae1..2d4ce3ee 100644 --- a/src/bitmessageqt/bitmessageui.py +++ b/src/bitmessageqt/bitmessageui.py @@ -15,7 +15,6 @@ import bitmessageqt.settingsmixin as settingsmixin from .networkstatus import NetworkStatus from .blacklist import Blacklist - class Ui_MainWindow(object): def setupUi(self, MainWindow): MainWindow.setObjectName("MainWindow") @@ -23,8 +22,7 @@ class Ui_MainWindow(object): self.MainDock = QtWidgets.QDockWidget(parent=MainWindow) self.MainDock.setGeometry(QtCore.QRect(0, 0, 885, 580)) icon = QtGui.QIcon() - icon.addPixmap(QtGui.QPixmap(":/newPrefix/images/can-icon-24px.png"), - QtGui.QIcon.Mode.Normal, QtGui.QIcon.State.Off) + icon.addPixmap(QtGui.QPixmap(":/newPrefix/images/can-icon-24px.png"), QtGui.QIcon.Mode.Normal, QtGui.QIcon.State.Off) self.MainDock.setWindowIcon(icon) self.MainDock.setObjectName("MainDock") self.centralwidget = QtWidgets.QWidget() @@ -33,8 +31,7 @@ class Ui_MainWindow(object): self.gridLayout_10.setObjectName("gridLayout_10") self.tabWidget = QtWidgets.QTabWidget(parent=self.centralwidget) self.tabWidget.setTabShape(QtWidgets.QTabWidget.TabShape.Rounded) - sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Expanding, - QtWidgets.QSizePolicy.Policy.Expanding) + sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Expanding, QtWidgets.QSizePolicy.Policy.Expanding) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.tabWidget.sizePolicy().hasHeightForWidth()) @@ -59,8 +56,7 @@ class Ui_MainWindow(object): self.treeWidgetYourIdentities.setMaximumSize(QtCore.QSize(200, 16777215)) self.treeWidgetYourIdentities.setObjectName("treeWidgetYourIdentities") icon1 = QtGui.QIcon() - icon1.addPixmap(QtGui.QPixmap(":/newPrefix/images/identities.png"), - QtGui.QIcon.Mode.Selected, QtGui.QIcon.State.Off) + icon1.addPixmap(QtGui.QPixmap(":/newPrefix/images/identities.png"), QtGui.QIcon.Mode.Selected, QtGui.QIcon.State.Off) self.treeWidgetYourIdentities.headerItem().setIcon(0, icon1) self.verticalLayout_12.addWidget(self.treeWidgetYourIdentities) self.pushButtonNewAddress = QtWidgets.QPushButton(parent=self.inbox) @@ -139,8 +135,7 @@ class Ui_MainWindow(object): self.tableWidgetAddressBook.setRowCount(0) item = QtWidgets.QTableWidgetItem() icon3 = QtGui.QIcon() - icon3.addPixmap(QtGui.QPixmap(":/newPrefix/images/addressbook.png"), - QtGui.QIcon.Mode.Selected, QtGui.QIcon.State.Off) + icon3.addPixmap(QtGui.QPixmap(":/newPrefix/images/addressbook.png"), QtGui.QIcon.Mode.Selected, QtGui.QIcon.State.Off) item.setIcon(icon3) self.tableWidgetAddressBook.setHorizontalHeaderItem(0, item) item = QtWidgets.QTableWidgetItem() @@ -316,8 +311,7 @@ class Ui_MainWindow(object): self.treeWidgetSubscriptions.setSelectionBehavior(QtWidgets.QAbstractItemView.SelectionBehavior.SelectRows) self.treeWidgetSubscriptions.setObjectName("treeWidgetSubscriptions") icon5 = QtGui.QIcon() - icon5.addPixmap(QtGui.QPixmap(":/newPrefix/images/subscriptions.png"), - QtGui.QIcon.Mode.Selected, QtGui.QIcon.State.Off) + icon5.addPixmap(QtGui.QPixmap(":/newPrefix/images/subscriptions.png"), QtGui.QIcon.Mode.Selected, QtGui.QIcon.State.Off) self.treeWidgetSubscriptions.headerItem().setIcon(0, icon5) self.verticalLayout_3.addWidget(self.treeWidgetSubscriptions) self.pushButtonAddSubscription = QtWidgets.QPushButton(parent=self.subscriptions) @@ -344,10 +338,8 @@ class Ui_MainWindow(object): self.tableWidgetInboxSubscriptions = QtWidgets.QTableWidget(parent=self.subscriptions) self.tableWidgetInboxSubscriptions.setEditTriggers(QtWidgets.QAbstractItemView.EditTrigger.NoEditTriggers) self.tableWidgetInboxSubscriptions.setAlternatingRowColors(True) - self.tableWidgetInboxSubscriptions.setSelectionMode( - QtWidgets.QAbstractItemView.SelectionMode.ExtendedSelection) - self.tableWidgetInboxSubscriptions.setSelectionBehavior( - QtWidgets.QAbstractItemView.SelectionBehavior.SelectRows) + self.tableWidgetInboxSubscriptions.setSelectionMode(QtWidgets.QAbstractItemView.SelectionMode.ExtendedSelection) + self.tableWidgetInboxSubscriptions.setSelectionBehavior(QtWidgets.QAbstractItemView.SelectionBehavior.SelectRows) self.tableWidgetInboxSubscriptions.setWordWrap(False) self.tableWidgetInboxSubscriptions.setObjectName("tableWidgetInboxSubscriptions") self.tableWidgetInboxSubscriptions.setColumnCount(4) @@ -377,8 +369,7 @@ class Ui_MainWindow(object): self.horizontalLayout_4.addLayout(self.verticalLayout_4) self.gridLayout_3.addLayout(self.horizontalLayout_4, 0, 0, 1, 1) icon6 = QtGui.QIcon() - icon6.addPixmap(QtGui.QPixmap(":/newPrefix/images/subscriptions.png"), - QtGui.QIcon.Mode.Normal, QtGui.QIcon.State.Off) + icon6.addPixmap(QtGui.QPixmap(":/newPrefix/images/subscriptions.png"), QtGui.QIcon.Mode.Normal, QtGui.QIcon.State.Off) self.tabWidget.addTab(self.subscriptions, icon6, "") self.chans = QtWidgets.QWidget() self.chans.setObjectName("chans") @@ -397,8 +388,7 @@ class Ui_MainWindow(object): self.treeWidgetChans.setSelectionBehavior(QtWidgets.QAbstractItemView.SelectionBehavior.SelectRows) self.treeWidgetChans.setObjectName("treeWidgetChans") icon7 = QtGui.QIcon() - icon7.addPixmap(QtGui.QPixmap(":/newPrefix/images/can-icon-16px.png"), - QtGui.QIcon.Mode.Selected, QtGui.QIcon.State.Off) + icon7.addPixmap(QtGui.QPixmap(":/newPrefix/images/can-icon-16px.png"), QtGui.QIcon.Mode.Selected, QtGui.QIcon.State.Off) self.treeWidgetChans.headerItem().setIcon(0, icon7) self.verticalLayout_17.addWidget(self.treeWidgetChans) self.pushButtonAddChan = QtWidgets.QPushButton(parent=self.chans) @@ -456,8 +446,7 @@ class Ui_MainWindow(object): self.horizontalLayout_7.addLayout(self.verticalLayout_8) self.gridLayout_4.addLayout(self.horizontalLayout_7, 0, 0, 1, 1) icon8 = QtGui.QIcon() - icon8.addPixmap(QtGui.QPixmap(":/newPrefix/images/can-icon-16px.png"), - QtGui.QIcon.Mode.Normal, QtGui.QIcon.State.Off) + icon8.addPixmap(QtGui.QPixmap(":/newPrefix/images/can-icon-16px.png"), QtGui.QIcon.Mode.Normal, QtGui.QIcon.State.Off) self.tabWidget.addTab(self.chans, icon8, "") self.blackwhitelist = Blacklist() self.blackwhitelist.setObjectName("blackwhitelist") @@ -609,21 +598,19 @@ class Ui_MainWindow(object): self.label_2.setText(_translate("MainWindow", "From:")) self.label.setText(_translate("MainWindow", "To:")) self.textEditMessage.setHtml(_translate("MainWindow", "\n" - "\n" - "


")) - self.tabWidgetSend.setTabText(self.tabWidgetSend.indexOf(self.sendDirect), - _translate("MainWindow", "Send ordinary Message")) +"\n" +"


")) + self.tabWidgetSend.setTabText(self.tabWidgetSend.indexOf(self.sendDirect), _translate("MainWindow", "Send ordinary Message")) self.label_8.setText(_translate("MainWindow", "From:")) self.label_7.setText(_translate("MainWindow", "Subject:")) self.textEditMessageBroadcast.setHtml(_translate("MainWindow", "\n" - "\n" - "


")) - self.tabWidgetSend.setTabText(self.tabWidgetSend.indexOf(self.sendBroadcast), - _translate("MainWindow", "Send Message to your Subscribers")) +"\n" +"


")) + self.tabWidgetSend.setTabText(self.tabWidgetSend.indexOf(self.sendBroadcast), _translate("MainWindow", "Send Message to your Subscribers")) self.pushButtonTTL.setText(_translate("MainWindow", "TTL:")) self.pushButtonClear.setText(_translate("MainWindow", "Clear")) self.pushButtonSend.setText(_translate("MainWindow", "Send")) @@ -645,8 +632,7 @@ class Ui_MainWindow(object): item.setText(_translate("MainWindow", "Subject")) item = self.tableWidgetInboxSubscriptions.horizontalHeaderItem(3) item.setText(_translate("MainWindow", "Received")) - self.tabWidget.setTabText(self.tabWidget.indexOf(self.subscriptions), - _translate("MainWindow", "Subscriptions")) + self.tabWidget.setTabText(self.tabWidget.indexOf(self.subscriptions), _translate("MainWindow", "Subscriptions")) self.treeWidgetChans.headerItem().setText(0, _translate("MainWindow", "Chans")) self.pushButtonAddChan.setText(_translate("MainWindow", "Add Chan")) self.inboxSearchLineEditChans.setPlaceholderText(_translate("MainWindow", "Search")) @@ -666,8 +652,7 @@ class Ui_MainWindow(object): item.setText(_translate("MainWindow", "Received")) self.tabWidget.setTabText(self.tabWidget.indexOf(self.chans), _translate("MainWindow", "Chans")) self.networkstatus.retranslateUi() - self.tabWidget.setTabText(self.tabWidget.indexOf(self.networkstatus), - _translate("MainWindow", "Network Status")) + self.tabWidget.setTabText(self.tabWidget.indexOf(self.networkstatus), _translate("MainWindow", "Network Status")) self.menuFile.setTitle(_translate("MainWindow", "File")) self.menuSettings.setTitle(_translate("MainWindow", "Settings")) self.menuHelp.setTitle(_translate("MainWindow", "Help")) @@ -680,8 +665,7 @@ class Ui_MainWindow(object): self.actionSupport.setText(_translate("MainWindow", "Contact support")) self.actionAbout.setText(_translate("MainWindow", "About")) self.actionSettings.setText(_translate("MainWindow", "Settings")) - self.actionRegenerateDeterministicAddresses.setText( - _translate("MainWindow", "Regenerate deterministic addresses")) + self.actionRegenerateDeterministicAddresses.setText(_translate("MainWindow", "Regenerate deterministic addresses")) self.actionDeleteAllTrashedMessages.setText(_translate("MainWindow", "Delete all trashed messages")) self.actionJoinChan.setText(_translate("MainWindow", "Join / Create chan")) self.updateNetworkSwitchMenuLabel() diff --git a/src/bitmessageqt/blacklist.py b/src/bitmessageqt/blacklist.py index bcfb49c3..87520c92 100644 --- a/src/bitmessageqt/blacklist.py +++ b/src/bitmessageqt/blacklist.py @@ -27,7 +27,7 @@ class Blacklist(QtWidgets.QWidget, RetranslateMixin): self.tableWidgetBlacklist.itemChanged.connect(self.tableWidgetBlacklistItemChanged) # Set the icon sizes for the identicons - identicon_size = 3 * 7 + identicon_size = 3*7 self.tableWidgetBlacklist.setIconSize(QtCore.QSize(identicon_size, identicon_size)) self.UISignalThread = UISignaler.get() @@ -64,7 +64,7 @@ class Blacklist(QtWidgets.QWidget, RetranslateMixin): sql = '''select * from blacklist where address=?''' else: sql = '''select * from whitelist where address=?''' - queryreturn = sqlQuery(sql, *t) + queryreturn = sqlQuery(sql,*t) if queryreturn == []: self.tableWidgetBlacklist.setSortingEnabled(False) self.tableWidgetBlacklist.insertRow(0) @@ -106,10 +106,10 @@ class Blacklist(QtWidgets.QWidget, RetranslateMixin): if isinstance(addressitem, QtWidgets.QTableWidgetItem): if self.radioButtonBlacklist.isChecked(): sqlExecute('''UPDATE blacklist SET label=? WHERE address=?''', - str(item.text()), str(addressitem.text())) + str(item.text()), str(addressitem.text())) else: sqlExecute('''UPDATE whitelist SET label=? WHERE address=?''', - str(item.text()), str(addressitem.text())) + str(item.text()), str(addressitem.text())) def init_blacklist_popup_menu(self, connectSignal=True): # Popup menu for the Blacklist page diff --git a/src/bitmessageqt/dialogs.py b/src/bitmessageqt/dialogs.py index 401b8f08..9cea3fd8 100644 --- a/src/bitmessageqt/dialogs.py +++ b/src/bitmessageqt/dialogs.py @@ -27,7 +27,6 @@ __all__ = [ class AboutDialog(QtWidgets.QDialog): """The `About` dialog""" - def __init__(self, parent=None): super(AboutDialog, self).__init__(parent) widgets.load('about.ui', self) @@ -56,7 +55,6 @@ class AboutDialog(QtWidgets.QDialog): class IconGlossaryDialog(QtWidgets.QDialog): """The `Icon Glossary` dialog, explaining the status icon colors""" - def __init__(self, parent=None, config=None): super(IconGlossaryDialog, self).__init__(parent) widgets.load('iconglossary.ui', self) @@ -73,7 +71,6 @@ class IconGlossaryDialog(QtWidgets.QDialog): class HelpDialog(QtWidgets.QDialog): """The `Help` dialog""" - def __init__(self, parent=None): super(HelpDialog, self).__init__(parent) widgets.load('help.ui', self) @@ -82,7 +79,6 @@ class HelpDialog(QtWidgets.QDialog): class ConnectDialog(QtWidgets.QDialog): """The `Connect` dialog""" - def __init__(self, parent=None): super(ConnectDialog, self).__init__(parent) widgets.load('connect.ui', self) diff --git a/src/bitmessageqt/foldertree.py b/src/bitmessageqt/foldertree.py index b26d9861..896b355d 100644 --- a/src/bitmessageqt/foldertree.py +++ b/src/bitmessageqt/foldertree.py @@ -219,7 +219,6 @@ class Ui_FolderWidget(BMTreeWidgetItem): class Ui_AddressWidget(BMTreeWidgetItem, SettingsMixin): """Item in the account/folder tree representing an account""" - def __init__(self, parent, pos=0, address=None, unreadCount=0, enabled=True): super(Ui_AddressWidget, self).__init__( parent, pos, address, unreadCount) @@ -298,7 +297,6 @@ class Ui_AddressWidget(BMTreeWidgetItem, SettingsMixin): class Ui_SubscriptionWidget(Ui_AddressWidget): """Special treating of subscription addresses""" # pylint: disable=unused-argument - def __init__(self, parent, pos=0, address="", unreadCount=0, label="", enabled=True): super(Ui_SubscriptionWidget, self).__init__( parent, pos, address, unreadCount, enabled) @@ -389,7 +387,6 @@ class BMAddressWidget(BMTableWidgetItem, AccountMixin): class MessageList_AddressWidget(BMAddressWidget): """Address item in a messagelist""" - def __init__(self, address=None, label=None, unread=False): self.setAddress(address) super(MessageList_AddressWidget, self).__init__(label, unread) @@ -439,7 +436,6 @@ class MessageList_AddressWidget(BMAddressWidget): class MessageList_SubjectWidget(BMTableWidgetItem): """Message list subject item""" - def __init__(self, subject=None, label=None, unread=False): self.setSubject(subject) super(MessageList_SubjectWidget, self).__init__(label, unread) @@ -497,7 +493,6 @@ class MessageList_TimeWidget(BMTableWidgetItem): class Ui_AddressBookWidgetItem(BMAddressWidget): """Addressbook item""" # pylint: disable=unused-argument - def __init__(self, label=None, acc_type=AccountMixin.NORMAL): self.type = acc_type super(Ui_AddressBookWidgetItem, self).__init__(label=label) @@ -540,7 +535,6 @@ class Ui_AddressBookWidgetItem(BMAddressWidget): class Ui_AddressBookWidgetItemLabel(Ui_AddressBookWidgetItem): """Addressbook label item""" - def __init__(self, address, label, acc_type): self.address = address super(Ui_AddressBookWidgetItemLabel, self).__init__(label, acc_type) @@ -553,7 +547,6 @@ class Ui_AddressBookWidgetItemLabel(Ui_AddressBookWidgetItem): class Ui_AddressBookWidgetItemAddress(Ui_AddressBookWidgetItem): """Addressbook address item""" - def __init__(self, address, label, acc_type): self.address = address super(Ui_AddressBookWidgetItemAddress, self).__init__(address, acc_type) diff --git a/src/bitmessageqt/messagecompose.py b/src/bitmessageqt/messagecompose.py index 9b2cb357..65fbddb6 100644 --- a/src/bitmessageqt/messagecompose.py +++ b/src/bitmessageqt/messagecompose.py @@ -8,7 +8,6 @@ from PyQt6 import QtCore, QtGui, QtWidgets class MessageCompose(QtWidgets.QTextEdit): """Editor class with wheel zoom functionality""" - def __init__(self, parent=0): super(MessageCompose, self).__init__(parent) self.setAcceptRichText(False) diff --git a/src/bitmessageqt/messageview.py b/src/bitmessageqt/messageview.py index 8c8b09ad..350d0c7f 100644 --- a/src/bitmessageqt/messageview.py +++ b/src/bitmessageqt/messageview.py @@ -135,7 +135,7 @@ class MessageView(QtWidgets.QTextBrowser): out = self.html.raw if self.html.has_html: out = "
" + QtWidgets.QApplication.translate( - "MessageView", "HTML detected, click here to display") + "

" + out + "MessageView", "HTML detected, click here to display") + "
" + out self.out = out self.outpos = 0 self.setHtml("") @@ -145,8 +145,7 @@ class MessageView(QtWidgets.QTextBrowser): """Render message as HTML""" self.mode = MessageView.MODE_HTML out = self.html.sanitised - out = "
" + \ - QtWidgets.QApplication.translate("MessageView", "Click here to disable HTML") + "

" + out + out = "
" + QtWidgets.QApplication.translate("MessageView", "Click here to disable HTML") + "

" + out self.out = out self.outpos = 0 self.setHtml("") diff --git a/src/bitmessageqt/migrationwizard.py b/src/bitmessageqt/migrationwizard.py index d6539d5a..d76661b5 100644 --- a/src/bitmessageqt/migrationwizard.py +++ b/src/bitmessageqt/migrationwizard.py @@ -1,23 +1,22 @@ #!/usr/bin/env python2.7 from PyQt6 import QtCore, QtGui, QtWidgets - class MigrationWizardIntroPage(QtWidgets.QWizardPage): def __init__(self): super(QtGui.QWizardPage, self).__init__() self.setTitle("Migrating configuration") label = QtGui.QLabel("This wizard will help you to migrate your configuration. " - "You can still keep using PyBitMessage once you migrate, the changes are backwards compatible.") + "You can still keep using PyBitMessage once you migrate, the changes are backwards compatible.") label.setWordWrap(True) layout = QtGui.QVBoxLayout() layout.addWidget(label) self.setLayout(layout) - + def nextId(self): return 1 - + class MigrationWizardAddressesPage(QtWidgets.QWizardPage): def __init__(self, addresses): @@ -30,10 +29,10 @@ class MigrationWizardAddressesPage(QtWidgets.QWizardPage): layout = QtGui.QVBoxLayout() layout.addWidget(label) self.setLayout(layout) - + def nextId(self): return 10 - + class MigrationWizardGPUPage(QtWidgets.QWizardPage): def __init__(self): @@ -46,10 +45,10 @@ class MigrationWizardGPUPage(QtWidgets.QWizardPage): layout = QtGui.QVBoxLayout() layout.addWidget(label) self.setLayout(layout) - + def nextId(self): return 10 - + class MigrationWizardConclusionPage(QtWidgets.QWizardPage): def __init__(self): @@ -69,7 +68,7 @@ class Ui_MigrationWizard(QtWidgets.QWizard): super(QtGui.QWizard, self).__init__() self.pages = {} - + page = MigrationWizardIntroPage() self.setPage(0, page) self.setStartId(0) diff --git a/src/bitmessageqt/networkstatus.py b/src/bitmessageqt/networkstatus.py index f8f493f1..32cb3469 100644 --- a/src/bitmessageqt/networkstatus.py +++ b/src/bitmessageqt/networkstatus.py @@ -18,7 +18,6 @@ from .uisignaler import UISignaler class NetworkStatus(QtWidgets.QWidget, RetranslateMixin): """Network status tab""" - def __init__(self, parent=None): super(NetworkStatus, self).__init__(parent) widgets.load('networkstatus.ui', self) diff --git a/src/bitmessageqt/newchandialog.py b/src/bitmessageqt/newchandialog.py index 0dd7784a..e244f0bd 100644 --- a/src/bitmessageqt/newchandialog.py +++ b/src/bitmessageqt/newchandialog.py @@ -17,13 +17,12 @@ from .utils import str_chan class NewChanDialog(QtWidgets.QDialog): """The `New Chan` dialog""" - def __init__(self, parent=None): super(NewChanDialog, self).__init__(parent) widgets.load('newchandialog.ui', self) self.parent = parent # XXX unresolved - # self.chanAddress.setValidator( + #self.chanAddress.setValidator( # AddressValidator( # self.chanAddress, # self.chanPassPhrase, @@ -31,7 +30,7 @@ class NewChanDialog(QtWidgets.QDialog): # self.buttonBox, # False)) # XXX unresolved - # self.chanPassPhrase.setValidator( + #self.chanPassPhrase.setValidator( # PassPhraseValidator( # self.chanPassPhrase, # self.chanAddress, diff --git a/src/bitmessageqt/retranslateui.py b/src/bitmessageqt/retranslateui.py index e987378b..17dee2c7 100644 --- a/src/bitmessageqt/retranslateui.py +++ b/src/bitmessageqt/retranslateui.py @@ -3,7 +3,6 @@ from PyQt6 import QtGui, QtWidgets from debug import logger import bitmessageqt.widgets as widgets - class RetranslateMixin(object): def retranslateUi(self): defaults = QtWidgets.QWidget() @@ -13,9 +12,9 @@ class RetranslateMixin(object): if callable(setTextMethod): getattr(self, attr).setText(getattr(defaults, attr).text()) elif isinstance(value, QtWidgets.QTableWidget): - for i in range(value.columnCount()): + for i in range (value.columnCount()): getattr(self, attr).horizontalHeaderItem(i).setText( getattr(defaults, attr).horizontalHeaderItem(i).text()) - for i in range(value.rowCount()): + for i in range (value.rowCount()): getattr(self, attr).verticalHeaderItem(i).setText( getattr(defaults, attr).verticalHeaderItem(i).text()) diff --git a/src/bitmessageqt/settings.py b/src/bitmessageqt/settings.py index 155bd569..161acf69 100644 --- a/src/bitmessageqt/settings.py +++ b/src/bitmessageqt/settings.py @@ -41,7 +41,6 @@ def getSOCKSProxyType(config): class SettingsDialog(QtWidgets.QDialog): """The "Settings" dialog""" - def __init__(self, parent=None, firstrun=False): super(SettingsDialog, self).__init__(parent) widgets.load('settings.ui', self) diff --git a/src/bitmessageqt/settingsmixin.py b/src/bitmessageqt/settingsmixin.py index 0e2d319b..fc78f794 100644 --- a/src/bitmessageqt/settingsmixin.py +++ b/src/bitmessageqt/settingsmixin.py @@ -10,7 +10,6 @@ from PyQt6 import QtCore, QtGui, QtWidgets class SettingsMixin(object): """Mixin for adding geometry and state saving between restarts.""" - def warnIfNoObjectName(self): """ Handle objects which don't have a name. Currently it ignores them. Objects without a name can't have their @@ -59,7 +58,6 @@ class SettingsMixin(object): class SMainWindow(QtWidgets.QMainWindow, SettingsMixin): """Main window with Settings functionality.""" - def loadSettings(self): """Load main window settings.""" self.readGeometry(self) @@ -74,7 +72,6 @@ class SMainWindow(QtWidgets.QMainWindow, SettingsMixin): class STableWidget(QtWidgets.QTableWidget, SettingsMixin): """Table widget with Settings functionality""" # pylint: disable=too-many-ancestors - def loadSettings(self): """Load table settings.""" self.readState(self.horizontalHeader()) @@ -86,7 +83,6 @@ class STableWidget(QtWidgets.QTableWidget, SettingsMixin): class SSplitter(QtWidgets.QSplitter, SettingsMixin): """Splitter with Settings functionality.""" - def loadSettings(self): """Load splitter settings""" self.readState(self) @@ -99,7 +95,6 @@ class SSplitter(QtWidgets.QSplitter, SettingsMixin): class STreeWidget(QtWidgets.QTreeWidget, SettingsMixin): """Tree widget with settings functionality.""" # pylint: disable=too-many-ancestors - def loadSettings(self): """Load tree settings.""" # recurse children diff --git a/src/bitmessageqt/utils.py b/src/bitmessageqt/utils.py index e6c2b66c..4a5b5ee6 100644 --- a/src/bitmessageqt/utils.py +++ b/src/bitmessageqt/utils.py @@ -89,7 +89,7 @@ def avatarize(address): # QImageReader.supportedImageFormats () extensions = [ 'PNG', 'GIF', 'JPG', 'JPEG', 'SVG', 'BMP', 'PBM', 'PGM', 'PPM', - 'XBM', 'XPM'] + 'XBM', 'XPM' ] # try to find a specific avatar for ext in extensions: lower_hash = state.appdata + 'avatars/' + icon_hash + '.' + ext.lower() diff --git a/src/bitmessageqt/widgets.py b/src/bitmessageqt/widgets.py index 1ed2533a..6e9730a0 100644 --- a/src/bitmessageqt/widgets.py +++ b/src/bitmessageqt/widgets.py @@ -3,13 +3,11 @@ import os.path import paths import sys - def resource_path(resFile): baseDir = paths.codePath() for subDir in ["ui", "bitmessageqt"]: if os.path.isdir(os.path.join(baseDir, subDir)) and os.path.isfile(os.path.join(baseDir, subDir, resFile)): return os.path.join(baseDir, subDir, resFile) - def load(resFile, widget): uic.loadUi(resource_path(resFile), widget)