Runnable with both Python3 and Python2, with both PyQt5 and PyQt4 by using Qt.py #2250

Open
kashikoibumi wants to merge 127 commits from kashikoibumi/py3qt into v0.6
Showing only changes of commit 6fd07a079d - Show all commits

View File

@ -23,8 +23,8 @@ def getSortedAccounts():
configSections = BMConfigParser().addresses()
configSections.sort(
cmp=lambda x, y: cmp(
unicode(BMConfigParser().get(x, 'label'), 'utf-8').lower(),
unicode(BMConfigParser().get(y, 'label'), 'utf-8').lower())
BMConfigParser().get(x, 'label').decode('utf-8').lower(),
BMConfigParser().get(y, 'label').decode('utf-8').lower())
)
return configSections
@ -38,22 +38,21 @@ def getSortedSubscriptions(count=False):
:retuns: dict keys are addresses, values are dicts containing settings
:rtype: dict, default {}
"""
queryreturn = sqlQuery('SELECT label, address, enabled FROM subscriptions ORDER BY label COLLATE NOCASE ASC')
queryreturn = sqlQuery(
'SELECT label, address, enabled FROM subscriptions'
' ORDER BY label COLLATE NOCASE ASC')
ret = {}
for row in queryreturn:
label, address, enabled = row
ret[address] = {}
ret[address]["inbox"] = {}
ret[address]["inbox"]['label'] = label
ret[address]["inbox"]['enabled'] = enabled
ret[address]["inbox"]['count'] = 0
for label, address, enabled in queryreturn:
ret[address] = {'inbox': {}}
ret[address]['inbox'].update(label=label, enabled=enabled, count=0)
if count:
queryreturn = sqlQuery('''SELECT fromaddress, folder, count(msgid) as cnt
FROM inbox, subscriptions ON subscriptions.address = inbox.fromaddress
WHERE read = 0 AND toaddress = ?
GROUP BY inbox.fromaddress, folder''', str_broadcast_subscribers)
for row in queryreturn:
address, folder, cnt = row
queryreturn = sqlQuery(
'SELECT fromaddress, folder, count(msgid) AS cnt'
' FROM inbox, subscriptions'
' ON subscriptions.address = inbox.fromaddress WHERE read = 0'
' AND toaddress = ? GROUP BY inbox.fromaddress, folder',
str_broadcast_subscribers)
for address, folder, cnt in queryreturn:
if folder not in ret[address]:
ret[address][folder] = {
'label': ret[address]['inbox']['label'],
@ -105,7 +104,9 @@ class AccountColor(AccountMixin):
elif BMConfigParser().safeGetBoolean(self.address, 'chan'):
self.type = AccountMixin.CHAN
elif sqlQuery(
'''select label from subscriptions where address=?''', self.address):
'SELECT label FROM subscriptions WHERE address=?',
self.address
):
self.type = AccountMixin.SUBSCRIPTION
else:
self.type = AccountMixin.NORMAL
@ -149,28 +150,25 @@ class BMAccount(NoAccount):
self.type = AccountMixin.MAILINGLIST
elif self.address == str_broadcast_subscribers:
self.type = AccountMixin.BROADCAST
else:
queryreturn = sqlQuery(
'''select label from subscriptions where address=?''', self.address)
if queryreturn:
self.type = AccountMixin.SUBSCRIPTION
elif sqlQuery(
'SELECT label FROM subscriptions WHERE address=?', self.address
):
self.type = AccountMixin.SUBSCRIPTION
def getLabel(self, address=None):
"""Get a label for this bitmessage account"""
address = super(BMAccount, self).getLabel(address)
label = BMConfigParser().safeGet(address, 'label', address)
queryreturn = sqlQuery(
'''select label from addressbook where address=?''', address)
if queryreturn != []:
for row in queryreturn:
label, = row
'SELECT label FROM addressbook WHERE address=?', address)
if queryreturn:
label = queryreturn[-1][0]
else:
queryreturn = sqlQuery(
'''select label from subscriptions where address=?''', address)
if queryreturn != []:
for row in queryreturn:
label, = row
return unicode(label, 'utf-8')
'SELECT label FROM subscriptions WHERE address=?', address)
if queryreturn:
label = queryreturn[-1][0]
return label.decode('utf-8')
class SubscriptionAccount(BMAccount):