Replace unicode() by .decode() in bitmessageqt.foldertree
This commit is contained in:
parent
d75d388522
commit
caec9434b0
|
@ -121,14 +121,12 @@ class AccountMixin(object):
|
||||||
|
|
||||||
def defaultLabel(self):
|
def defaultLabel(self):
|
||||||
"""Default label (in case no label is set manually)"""
|
"""Default label (in case no label is set manually)"""
|
||||||
queryreturn = None
|
queryreturn = retval = None
|
||||||
retval = None
|
|
||||||
if self.type in (
|
if self.type in (
|
||||||
AccountMixin.NORMAL,
|
AccountMixin.NORMAL,
|
||||||
AccountMixin.CHAN, AccountMixin.MAILINGLIST):
|
AccountMixin.CHAN, AccountMixin.MAILINGLIST):
|
||||||
try:
|
try:
|
||||||
retval = unicode(
|
retval = BMConfigParser().get(self.address, 'label')
|
||||||
BMConfigParser().get(self.address, 'label'), 'utf-8')
|
|
||||||
except Exception:
|
except Exception:
|
||||||
queryreturn = sqlQuery(
|
queryreturn = sqlQuery(
|
||||||
'SELECT label FROM addressbook WHERE address=?',
|
'SELECT label FROM addressbook WHERE address=?',
|
||||||
|
@ -139,15 +137,12 @@ class AccountMixin(object):
|
||||||
'SELECT label FROM subscriptions WHERE address=?',
|
'SELECT label FROM subscriptions WHERE address=?',
|
||||||
self.address
|
self.address
|
||||||
)
|
)
|
||||||
if queryreturn is not None:
|
if queryreturn:
|
||||||
if queryreturn != []:
|
retval = queryreturn[-1][0]
|
||||||
for row in queryreturn:
|
|
||||||
retval, = row
|
|
||||||
retval = unicode(retval, 'utf-8')
|
|
||||||
elif self.address is None or self.type == AccountMixin.ALL:
|
elif self.address is None or self.type == AccountMixin.ALL:
|
||||||
return _translate("MainWindow", "All accounts")
|
return _translate("MainWindow", "All accounts")
|
||||||
|
|
||||||
return retval or unicode(self.address, 'utf-8')
|
return (retval or self.address).decode('utf-8')
|
||||||
|
|
||||||
|
|
||||||
class BMTreeWidgetItem(QtWidgets.QTreeWidgetItem, AccountMixin):
|
class BMTreeWidgetItem(QtWidgets.QTreeWidgetItem, AccountMixin):
|
||||||
|
@ -241,13 +236,12 @@ class Ui_AddressWidget(BMTreeWidgetItem, SettingsMixin):
|
||||||
def _getLabel(self):
|
def _getLabel(self):
|
||||||
if self.address is None:
|
if self.address is None:
|
||||||
return _translate("MainWindow", "All accounts")
|
return _translate("MainWindow", "All accounts")
|
||||||
else:
|
|
||||||
try:
|
try:
|
||||||
return unicode(
|
return BMConfigParser().get(
|
||||||
BMConfigParser().get(self.address, 'label'),
|
self.address, 'label').decode('utf-8', 'ignore')
|
||||||
'utf-8', 'ignore')
|
|
||||||
except:
|
except:
|
||||||
return unicode(self.address, 'utf-8')
|
return self.address.decode('utf-8')
|
||||||
|
|
||||||
def _getAddressBracket(self, unreadCount=False):
|
def _getAddressBracket(self, unreadCount=False):
|
||||||
ret = "" if self.isExpanded() \
|
ret = "" if self.isExpanded() \
|
||||||
|
@ -318,11 +312,9 @@ class Ui_SubscriptionWidget(Ui_AddressWidget):
|
||||||
queryreturn = sqlQuery(
|
queryreturn = sqlQuery(
|
||||||
'SELECT label FROM subscriptions WHERE address=?',
|
'SELECT label FROM subscriptions WHERE address=?',
|
||||||
self.address)
|
self.address)
|
||||||
if queryreturn != []:
|
if queryreturn:
|
||||||
for row in queryreturn:
|
return queryreturn[-1][0].decode('utf-8', 'ignore')
|
||||||
retval, = row
|
return self.address.decode('utf-8')
|
||||||
return unicode(retval, 'utf-8', 'ignore')
|
|
||||||
return unicode(self.address, 'utf-8')
|
|
||||||
|
|
||||||
def setType(self):
|
def setType(self):
|
||||||
"""Set account type"""
|
"""Set account type"""
|
||||||
|
@ -412,9 +404,7 @@ class MessageList_AddressWidget(BMAddressWidget):
|
||||||
AccountMixin.NORMAL,
|
AccountMixin.NORMAL,
|
||||||
AccountMixin.CHAN, AccountMixin.MAILINGLIST):
|
AccountMixin.CHAN, AccountMixin.MAILINGLIST):
|
||||||
try:
|
try:
|
||||||
newLabel = unicode(
|
newLabel = BMConfigParser().get(self.address, 'label')
|
||||||
BMConfigParser().get(self.address, 'label'),
|
|
||||||
'utf-8', 'ignore')
|
|
||||||
except:
|
except:
|
||||||
queryreturn = sqlQuery(
|
queryreturn = sqlQuery(
|
||||||
'SELECT label FROM addressbook WHERE address=?',
|
'SELECT label FROM addressbook WHERE address=?',
|
||||||
|
@ -424,10 +414,9 @@ class MessageList_AddressWidget(BMAddressWidget):
|
||||||
'SELECT label FROM subscriptions WHERE address=?',
|
'SELECT label FROM subscriptions WHERE address=?',
|
||||||
self.address)
|
self.address)
|
||||||
if queryreturn:
|
if queryreturn:
|
||||||
for row in queryreturn:
|
newLabel = queryreturn[-1][0]
|
||||||
newLabel = unicode(row[0], 'utf-8', 'ignore')
|
|
||||||
|
|
||||||
self.label = newLabel
|
self.label = newLabel.decode('utf-8', 'ignore')
|
||||||
|
|
||||||
def data(self, role):
|
def data(self, role):
|
||||||
"""Return object data (QT UI)"""
|
"""Return object data (QT UI)"""
|
||||||
|
@ -536,8 +525,6 @@ class Ui_AddressBookWidgetItem(BMAddressWidget):
|
||||||
sqlExecute(
|
sqlExecute(
|
||||||
'UPDATE subscriptions SET label=? WHERE address=?',
|
'UPDATE subscriptions SET label=? WHERE address=?',
|
||||||
self.label, self.address)
|
self.label, self.address)
|
||||||
else:
|
|
||||||
pass
|
|
||||||
return super(Ui_AddressBookWidgetItem, self).setData(role, value)
|
return super(Ui_AddressBookWidgetItem, self).setData(role, value)
|
||||||
|
|
||||||
def __lt__(self, other):
|
def __lt__(self, other):
|
||||||
|
|
Reference in New Issue
Block a user