Fixed: Chan-provided diff to revert changes from boolean operators to any()/all(). Closes #1277.

This commit is contained in:
coffeedogs 2018-06-15 12:18:45 +01:00
parent 1f6a7adf03
commit d9f0a8708b
No known key found for this signature in database
GPG Key ID: 9D818C503D0B7E70

View File

@ -2509,18 +2509,14 @@ class MyForm(settingsmixin.SMainWindow): # pylint: disable=too-many-public-meth
treeWidget = self.widgetConvert(sent) treeWidget = self.widgetConvert(sent)
if self.getCurrentFolder(treeWidget) != "sent": if self.getCurrentFolder(treeWidget) != "sent":
continue continue
if all( if (
[ treeWidget == self.ui.treeWidgetYourIdentities
treeWidget == self.ui.treeWidgetYourIdentities, and self.getCurrentAccount(treeWidget) not in (fromAddress, None, False)
self.getCurrentAccount(treeWidget) not in (fromAddress, None, False),
]
): ):
continue continue
elif all( elif (
[ treeWidget in [self.ui.treeWidgetSubscriptions, self.ui.treeWidgetChans]
treeWidget in [self.ui.treeWidgetSubscriptions, self.ui.treeWidgetChans], and self.getCurrentAccount(treeWidget) != toAddress
self.getCurrentAccount(treeWidget) != toAddress,
]
): ):
continue continue
elif not helper_search.check_match( elif not helper_search.check_match(
@ -2565,12 +2561,10 @@ class MyForm(settingsmixin.SMainWindow): # pylint: disable=too-many-public-meth
self.getCurrentSearchLine(tab), self.getCurrentSearchLine(tab),
): ):
continue continue
if all( if (
[ tableWidget == inbox
tableWidget == inbox, and self.getCurrentAccount(treeWidget) == acct.address
self.getCurrentAccount(treeWidget) == acct.address, and self.getCurrentFolder(treeWidget) in ["inbox", None]
self.getCurrentFolder(treeWidget) in ["inbox", None],
]
): ):
ret = self.addMessageListItemInbox( ret = self.addMessageListItemInbox(
inbox, inbox,
@ -2582,12 +2576,10 @@ class MyForm(settingsmixin.SMainWindow): # pylint: disable=too-many-public-meth
time.time(), time.time(),
0, 0,
) )
elif treeWidget == all( elif (
[ treeWidget == self.ui.treeWidgetYourIdentities
self.ui.treeWidgetYourIdentities, and self.getCurrentAccount(treeWidget) is None
self.getCurrentAccount(treeWidget) is None, and self.getCurrentFolder(treeWidget) in ["inbox", "new", None]
self.getCurrentFolder(treeWidget) in ["inbox", "new", None]
]
): ):
ret = self.addMessageListItemInbox( ret = self.addMessageListItemInbox(
tableWidget, tableWidget,
@ -2612,17 +2604,12 @@ class MyForm(settingsmixin.SMainWindow): # pylint: disable=too-many-public-meth
unicode(acct.fromLabel, 'utf-8')), unicode(acct.fromLabel, 'utf-8')),
sound.SOUND_UNKNOWN sound.SOUND_UNKNOWN
) )
if any( if (
[ self.getCurrentAccount() is not None
all( and (
[ self.getCurrentFolder(treeWidget) not in ("inbox", None) # pylint: disable=undefined-loop-variable
self.getCurrentAccount() is not None, or self.getCurrentAccount(treeWidget) != acct.address # pylint: disable=undefined-loop-variable
self.getCurrentFolder(treeWidget) != "inbox", # pylint: disable=undefined-loop-variable )
self.getCurrentFolder(treeWidget) is not None, # pylint: disable=undefined-loop-variable
]
),
self.getCurrentAccount(treeWidget) != acct.address # pylint: disable=undefined-loop-variable
]
): ):
# Ubuntu should notify of new message irespective of # Ubuntu should notify of new message irespective of
# whether it's in current message list or not # whether it's in current message list or not
@ -2789,13 +2776,9 @@ class MyForm(settingsmixin.SMainWindow): # pylint: disable=too-many-public-meth
upnpThread = upnp.uPnPThread() upnpThread = upnp.uPnPThread()
upnpThread.start() upnpThread.start()
if all( if (
[ BMConfigParser().get('bitmessagesettings', 'socksproxytype') == 'none'
BMConfigParser().get( and self.settingsDialogInstance.ui.comboBoxProxyType.currentText()[0:5] == 'SOCKS'
'bitmessagesettings',
'socksproxytype') == 'none',
self.settingsDialogInstance.ui.comboBoxProxyType.currentText()[0:5] == 'SOCKS',
]
): ):
if shared.statusIconColor != 'red': if shared.statusIconColor != 'red':
QtGui.QMessageBox.about( QtGui.QMessageBox.about(
@ -2808,11 +2791,9 @@ class MyForm(settingsmixin.SMainWindow): # pylint: disable=too-many-public-meth
("Bitmessage will use your proxy from now on but you may want to manually restart " ("Bitmessage will use your proxy from now on but you may want to manually restart "
"Bitmessage now to close existing connections (if any)."))) "Bitmessage now to close existing connections (if any).")))
if all( if (
[ BMConfigParser().get('bitmessagesettings', 'socksproxytype')[0:5] == 'SOCKS'
BMConfigParser().get('bitmessagesettings', 'socksproxytype')[0:5] == 'SOCKS', and self.settingsDialogInstance.ui.comboBoxProxyType.currentText()[0:5] != 'SOCKS'
self.settingsDialogInstance.ui.comboBoxProxyType.currentText()[0:5] != 'SOCKS',
]
): ):
self.statusbar.clearMessage() self.statusbar.clearMessage()
state.resetNetworkProtocolAvailability() # just in case we changed something in the network connectivity state.resetNetworkProtocolAvailability() # just in case we changed something in the network connectivity
@ -2879,11 +2860,9 @@ class MyForm(settingsmixin.SMainWindow): # pylint: disable=too-many-public-meth
acceptableDifficultyChanged = False acceptableDifficultyChanged = False
if any( if (
[ float(self.settingsDialogInstance.ui.lineEditMaxAcceptableTotalDifficulty.text()) >= 1
float(self.settingsDialogInstance.ui.lineEditMaxAcceptableTotalDifficulty.text()) >= 1, or float(self.settingsDialogInstance.ui.lineEditMaxAcceptableTotalDifficulty.text()) == 0
float(self.settingsDialogInstance.ui.lineEditMaxAcceptableTotalDifficulty.text()) == 0,
]
): ):
if BMConfigParser().get( if BMConfigParser().get(
'bitmessagesettings', 'bitmessagesettings',
@ -2901,11 +2880,9 @@ class MyForm(settingsmixin.SMainWindow): # pylint: disable=too-many-public-meth
self.settingsDialogInstance.ui.lineEditMaxAcceptableTotalDifficulty.text() self.settingsDialogInstance.ui.lineEditMaxAcceptableTotalDifficulty.text()
) * defaults.networkDefaultProofOfWorkNonceTrialsPerByte))) ) * defaults.networkDefaultProofOfWorkNonceTrialsPerByte)))
if any( if (
[ float(self.settingsDialogInstance.ui.lineEditMaxAcceptableSmallMessageDifficulty.text()) >= 1
float(self.settingsDialogInstance.ui.lineEditMaxAcceptableSmallMessageDifficulty.text()) >= 1, or float(self.settingsDialogInstance.ui.lineEditMaxAcceptableSmallMessageDifficulty.text()) == 0
float(self.settingsDialogInstance.ui.lineEditMaxAcceptableSmallMessageDifficulty.text()) == 0,
]
): ):
if BMConfigParser().get( if BMConfigParser().get(
'bitmessagesettings', 'bitmessagesettings',
@ -2932,11 +2909,9 @@ class MyForm(settingsmixin.SMainWindow): # pylint: disable=too-many-public-meth
# start:UI setting to stop trying to send messages after X days/months # start:UI setting to stop trying to send messages after X days/months
# I'm open to changing this UI to something else if someone has a better idea. # I'm open to changing this UI to something else if someone has a better idea.
if all( if (
[ self.settingsDialogInstance.ui.lineEditDays.text() == ''
self.settingsDialogInstance.ui.lineEditDays.text() == '', and self.settingsDialogInstance.ui.lineEditMonths.text() == ''
self.settingsDialogInstance.ui.lineEditMonths.text() == '',
]
): # We need to handle this special case. Bitmessage has its default behavior. The input is blank/blank ): # We need to handle this special case. Bitmessage has its default behavior. The input is blank/blank
BMConfigParser().set('bitmessagesettings', 'stopresendingafterxdays', '') BMConfigParser().set('bitmessagesettings', 'stopresendingafterxdays', '')
BMConfigParser().set('bitmessagesettings', 'stopresendingafterxmonths', '') BMConfigParser().set('bitmessagesettings', 'stopresendingafterxmonths', '')
@ -2956,11 +2931,9 @@ class MyForm(settingsmixin.SMainWindow): # pylint: disable=too-many-public-meth
if lineEditMonthsIsValidFloat and not lineEditDaysIsValidFloat: if lineEditMonthsIsValidFloat and not lineEditDaysIsValidFloat:
self.settingsDialogInstance.ui.lineEditDays.setText("0") self.settingsDialogInstance.ui.lineEditDays.setText("0")
if lineEditDaysIsValidFloat or lineEditMonthsIsValidFloat: if lineEditDaysIsValidFloat or lineEditMonthsIsValidFloat:
if all( if (
[ float(self.settingsDialogInstance.ui.lineEditDays.text()) >= 0
float(self.settingsDialogInstance.ui.lineEditDays.text()) >= 0, and float(self.settingsDialogInstance.ui.lineEditMonths.text()) >= 0
float(self.settingsDialogInstance.ui.lineEditMonths.text()) >= 0,
]
): ):
shared.maximumLengthOfTimeToBotherResendingMessages = sum( shared.maximumLengthOfTimeToBotherResendingMessages = sum(
float(str(self.settingsDialogInstance.ui.lineEditDays.text())) * 24 * 60 * 60, float(str(self.settingsDialogInstance.ui.lineEditDays.text())) * 24 * 60 * 60,
@ -4289,17 +4262,13 @@ class MyForm(settingsmixin.SMainWindow): # pylint: disable=too-many-public-meth
myAddress = tableWidget.item(currentRow, 0).data(QtCore.Qt.UserRole) myAddress = tableWidget.item(currentRow, 0).data(QtCore.Qt.UserRole)
otherAddress = tableWidget.item(currentRow, 1).data(QtCore.Qt.UserRole) otherAddress = tableWidget.item(currentRow, 1).data(QtCore.Qt.UserRole)
account = accountClass(myAddress) account = accountClass(myAddress)
if all( if (
[ isinstance(account, GatewayAccount)
isinstance(account, GatewayAccount), and otherAddress == account.relayAddress
otherAddress == account.relayAddress, and (
any( 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", )
currentColumn in [1, 2] and self.getCurrentFolder() != "sent",
]
),
]
): ):
text = str(tableWidget.item(currentRow, currentColumn).label) text = str(tableWidget.item(currentRow, currentColumn).label)
@ -4644,12 +4613,10 @@ class MyForm(settingsmixin.SMainWindow): # pylint: disable=too-many-public-meth
if column != 0: if column != 0:
return return
# only account names of normal addresses (no chans/mailinglists) # only account names of normal addresses (no chans/mailinglists)
if any( if (
[ not isinstance(item, Ui_AddressWidget)
not isinstance(item, Ui_AddressWidget), or not self.getCurrentTreeWidget()
not self.getCurrentTreeWidget(), or self.getCurrentTreeWidget().currentItem() is None
self.getCurrentTreeWidget().currentItem() is None,
]
): ):
return return
@ -4719,11 +4686,9 @@ class MyForm(settingsmixin.SMainWindow): # pylint: disable=too-many-public-meth
if tableWidget.item(currentRow, 0).unread is True: if tableWidget.item(currentRow, 0).unread is True:
self.updateUnreadStatus(tableWidget, currentRow, msgid) self.updateUnreadStatus(tableWidget, currentRow, msgid)
# propagate # propagate
if all( if (
[ folder != 'sent'
folder != 'sent', and sqlExecute('''UPDATE inbox SET read=1 WHERE msgid=? AND read=0''', msgid) > 0
sqlExecute('''UPDATE inbox SET read=1 WHERE msgid=? AND read=0''', msgid) > 0,
]
): ):
self.propagateUnreadCount() self.propagateUnreadCount()