Updated code quality ignore unicode function warning changes in bitmessageqt/__init__.py

This commit is contained in:
kuldeep.k@cisinlabs.com 2021-08-24 21:37:38 +05:30
parent 6dffb1e470
commit 17071e1874
No known key found for this signature in database
GPG Key ID: AF4FB299BF7C7C2A

View File

@ -1161,11 +1161,11 @@ class MyForm(settingsmixin.SMainWindow):
items = [
MessageList_AddressWidget(
toAddress, unicode(acct.toLabel, 'utf-8')),
toAddress, unicode(acct.toLabel, 'utf-8')), # noqa:F821
MessageList_AddressWidget(
fromAddress, unicode(acct.fromLabel, 'utf-8')),
fromAddress, unicode(acct.fromLabel, 'utf-8')), # noqa:F821
MessageList_SubjectWidget(
str(subject), unicode(acct.subject, 'utf-8', 'replace')),
str(subject), unicode(acct.subject, 'utf-8', 'replace')), # noqa:F821
MessageList_TimeWidget(
statusText, False, lastactiontime, ackdata)]
self.addMessageListItem(tableWidget, items)
@ -1186,11 +1186,11 @@ class MyForm(settingsmixin.SMainWindow):
items = [
MessageList_AddressWidget(
toAddress, unicode(acct.toLabel, 'utf-8'), not read),
toAddress, unicode(acct.toLabel, 'utf-8'), not read), # noqa:F821
MessageList_AddressWidget(
fromAddress, unicode(acct.fromLabel, 'utf-8'), not read),
fromAddress, unicode(acct.fromLabel, 'utf-8'), not read), # noqa:F821
MessageList_SubjectWidget(
str(subject), unicode(acct.subject, 'utf-8', 'replace'),
str(subject), unicode(acct.subject, 'utf-8', 'replace'), # noqa:F821
not read),
MessageList_TimeWidget(
l10n.formatTimestamp(received), not read, received, msgid)
@ -1471,7 +1471,7 @@ class MyForm(settingsmixin.SMainWindow):
self, title, subtitle, category, label=None, icon=None):
self.playSound(category, label)
self._notifier(
unicode(title), unicode(subtitle), category, label, icon)
unicode(title), unicode(subtitle), category, label, icon) # noqa:F821
# tree
def treeWidgetKeyPressEvent(self, event):
@ -1920,9 +1920,9 @@ class MyForm(settingsmixin.SMainWindow):
def rerenderAddressBook(self):
def addRow (address, label, type):
self.ui.tableWidgetAddressBook.insertRow(0)
newItem = Ui_AddressBookWidgetItemLabel(address, unicode(label, 'utf-8'), type)
newItem = Ui_AddressBookWidgetItemLabel(address, unicode(label, 'utf-8'), type) # noqa:F821
self.ui.tableWidgetAddressBook.setItem(0, 0, newItem)
newItem = Ui_AddressBookWidgetItemAddress(address, unicode(label, 'utf-8'), type)
newItem = Ui_AddressBookWidgetItemAddress(address, unicode(label, 'utf-8'), type) # noqa:F821
self.ui.tableWidgetAddressBook.setItem(0, 1, newItem)
oldRows = {}
@ -1964,7 +1964,7 @@ class MyForm(settingsmixin.SMainWindow):
self.ui.tableWidgetAddressBook.removeRow(oldRows[address][2])
for address in newRows:
addRow(address, newRows[address][0], newRows[address][1])
completerList.append(unicode(newRows[address][0], encoding="UTF-8") + " <" + address + ">")
completerList.append(unicode(newRows[address][0], encoding="UTF-8") + " <" + address + ">") # noqa:F821
# sort
self.ui.tableWidgetAddressBook.sortByColumn(
@ -2078,7 +2078,7 @@ class MyForm(settingsmixin.SMainWindow):
status, addressVersionNumber, streamNumber = decodeAddress(toAddress)[:3]
if status != 'success':
try:
toAddress = unicode(toAddress, 'utf-8', 'ignore')
toAddress = unicode(toAddress, 'utf-8', 'ignore') # noqa:F821
except:
pass
logger.error('Error: Could not decode recipient address ' + toAddress + ':' + status)
@ -2268,7 +2268,7 @@ class MyForm(settingsmixin.SMainWindow):
addressInKeysFile, 'enabled') # I realize that this is poor programming practice but I don't care. It's easier for others to read.
isMaillinglist = BMConfigParser().safeGetBoolean(addressInKeysFile, 'mailinglist')
if isEnabled and not isMaillinglist:
label = unicode(BMConfigParser().get(addressInKeysFile, 'label'), 'utf-8', 'ignore').strip()
label = unicode(BMConfigParser().get(addressInKeysFile, 'label'), 'utf-8', 'ignore').strip() # noqa:F821
if label == "":
label = addressInKeysFile
self.ui.comboBoxSendFrom.addItem(avatarize(addressInKeysFile), label, addressInKeysFile)
@ -2292,7 +2292,7 @@ class MyForm(settingsmixin.SMainWindow):
addressInKeysFile, 'enabled') # I realize that this is poor programming practice but I don't care. It's easier for others to read.
isChan = BMConfigParser().safeGetBoolean(addressInKeysFile, 'chan')
if isEnabled and not isChan:
label = unicode(BMConfigParser().get(addressInKeysFile, 'label'), 'utf-8', 'ignore').strip()
label = unicode(BMConfigParser().get(addressInKeysFile, 'label'), 'utf-8', 'ignore').strip() # noqa:F821
if label == "":
label = addressInKeysFile
self.ui.comboBoxSendFromBroadcast.addItem(avatarize(addressInKeysFile), label, addressInKeysFile)
@ -2398,7 +2398,7 @@ class MyForm(settingsmixin.SMainWindow):
self.notifierShow(
_translate("MainWindow", "New Message"),
_translate("MainWindow", "From %1").arg(
unicode(acct.fromLabel, 'utf-8')),
unicode(acct.fromLabel, 'utf-8')), # noqa:F821
sound.SOUND_UNKNOWN
)
if self.getCurrentAccount() is not None and (
@ -2834,7 +2834,7 @@ class MyForm(settingsmixin.SMainWindow):
lines[i] = '<br><br>'
content = ' '.join(lines) # To keep the whitespace between lines
content = shared.fixPotentiallyInvalidUTF8Data(content)
content = unicode(content, 'utf-8)')
content = unicode(content, 'utf-8)') # noqa:F821
textEdit.setHtml(QtCore.QString(content))
def on_action_InboxMarkUnread(self):
@ -3017,7 +3017,7 @@ class MyForm(settingsmixin.SMainWindow):
self.setSendFromComboBox(toAddressAtCurrentInboxRow)
quotedText = self.quoted_text(
unicode(messageAtCurrentInboxRow, 'utf-8', 'replace'))
unicode(messageAtCurrentInboxRow, 'utf-8', 'replace')) # noqa:F821
widget['message'].setPlainText(quotedText)
if acct.subject[0:3] in ('Re:', 'RE:'):
widget['subject'].setText(
@ -3263,7 +3263,7 @@ class MyForm(settingsmixin.SMainWindow):
return self.updateStatusBar(_translate(
"MainWindow", "No addresses selected."))
addresses_string = unicode(
addresses_string = unicode( # noqa:F821
self.ui.lineEditTo.text().toUtf8(), 'utf-8')
for item in selected_items:
address_string = item.accountString()
@ -3756,11 +3756,11 @@ class MyForm(settingsmixin.SMainWindow):
self.setAddressSound(widget.item(widget.currentRow(), 0).text())
def setAddressSound(self, addr):
filters = [unicode(_translate(
filters = [unicode(_translate( # noqa:F821
"MainWindow", "Sound files (%s)" %
' '.join(['*%s%s' % (os.extsep, ext) for ext in sound.extensions])
))]
sourcefile = unicode(QtGui.QFileDialog.getOpenFileName(
sourcefile = unicode(QtGui.QFileDialog.getOpenFileName( # noqa:F821
self, _translate("MainWindow", "Set notification sound..."),
filter=';;'.join(filters)
))
@ -3769,7 +3769,7 @@ class MyForm(settingsmixin.SMainWindow):
return
destdir = os.path.join(state.appdata, 'sounds')
destfile = unicode(addr) + os.path.splitext(sourcefile)[-1]
destfile = unicode(addr) + os.path.splitext(sourcefile)[-1] # noqa:F821
destination = os.path.join(destdir, destfile)
if sourcefile == destination:
@ -3977,7 +3977,7 @@ class MyForm(settingsmixin.SMainWindow):
if item.type == AccountMixin.ALL:
return
newLabel = unicode(item.text(0), 'utf-8', 'ignore')
newLabel = unicode(item.text(0), 'utf-8', 'ignore') # noqa:F821
oldLabel = item.defaultLabel()
# unchanged, do not do anything either
@ -4048,7 +4048,7 @@ class MyForm(settingsmixin.SMainWindow):
self.rerenderMessagelistToLabels()
completerList = self.ui.lineEditTo.completer().model().stringList()
for i in range(len(completerList)):
if unicode(completerList[i]).endswith(" <" + item.address + ">"):
if unicode(completerList[i]).endswith(" <" + item.address + ">"): # noqa:F821
completerList[i] = item.label + " <" + item.address + ">"
self.ui.lineEditTo.completer().model().setStringList(completerList)