Merge pull request #65 from navjotcis/codequalitykivy

mpybit fixes
This commit is contained in:
lakshyacis 2019-12-10 19:23:24 +05:30 committed by GitHub
commit 518e0a42c9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 15 deletions

View File

@ -4,7 +4,9 @@ Sql queries for bitmessagekivy
from helper_sql import sqlQuery
def search_sql(xAddress="toaddress", account=None, folder="inbox", where=None, what=None, unreadOnly=False, start_indx=0, end_indx=20):
def search_sql(
xAddress="toaddress", account=None, folder="inbox", where=None,
what=None, unreadOnly=False, start_indx=0, end_indx=20):
"""Method helping for searching mails"""
# pylint: disable=too-many-arguments, too-many-branches
if what is not None and what != "":
@ -14,14 +16,14 @@ def search_sql(xAddress="toaddress", account=None, folder="inbox", where=None, w
if folder == "sent" or folder == "draft":
sqlStatementBase = (
'''SELECT toaddress, fromaddress, subject, message, status, ackdata,'''
''' lastactiontime FROM sent ''')
'''SELECT toaddress, fromaddress, subject, message, status,'''
''' ackdata, lastactiontime FROM sent ''')
elif folder == "addressbook":
sqlStatementBase = '''SELECT label, address From addressbook '''
else:
sqlStatementBase = (
'''SELECT folder, msgid, toaddress, message, fromaddress, subject,'''
''' received, read FROM inbox ''')
'''SELECT folder, msgid, toaddress, message, fromaddress,'''
''' subject, received, read FROM inbox ''')
sqlStatementParts = []
sqlArguments = []
@ -59,9 +61,13 @@ def search_sql(xAddress="toaddress", account=None, folder="inbox", where=None, w
if sqlStatementParts:
sqlStatementBase += "WHERE " + " AND ".join(sqlStatementParts)
if folder == "sent" or folder == "draft":
sqlStatementBase += " ORDER BY lastactiontime DESC limit {0}, {1}".format(start_indx, end_indx)
sqlStatementBase += \
" ORDER BY lastactiontime DESC limit {0}, {1}".format(
start_indx, end_indx)
elif folder == "inbox":
sqlStatementBase += " ORDER BY received DESC limit {0}, {1}".format(start_indx, end_indx)
sqlStatementBase += \
" ORDER BY received DESC limit {0}, {1}".format(
start_indx, end_indx)
# elif folder == "addressbook":
# sqlStatementBase += " limit {0}, {1}".format(start_indx, end_indx)
return sqlQuery(sqlStatementBase, sqlArguments)

View File

@ -62,7 +62,7 @@ import state
from uikivysignaler import UIkivySignaler
import identiconGeneration
from addresses import addBMIfNotPresent, decodeAddress, encodeVarint
from addresses import addBMIfNotPresent, decodeAddress
def toast(text):
@ -590,7 +590,6 @@ class DropDownWidget(BoxLayout):
sendMessageToPeople = True
if sendMessageToPeople:
if toAddress != '' and subject and message:
from addresses import decodeAddress
status, addressVersionNumber, streamNumber, ripe = (
decodeAddress(toAddress))
if status == 'success':
@ -612,7 +611,6 @@ class DropDownWidget(BoxLayout):
state.detailPageType = ''
state.send_draft_mail = None
else:
from addresses import addBMIfNotPresent
toAddress = addBMIfNotPresent(toAddress)
statusIconColor = 'red'
if (addressVersionNumber > 4) or (
@ -1708,7 +1706,7 @@ class NavigateApp(App): # pylint: disable=too-many-public-methods
self.root.ids.scr_mngr.current = 'allmails'
try:
self.root.ids.sc17.children[1].active = True
except Exception as e:
except Exception:
self.root.ids.sc17.children[0].children[1].active = True
Clock.schedule_once(partial(self.load_screen_callback, instance), 1)
@ -1723,7 +1721,7 @@ class NavigateApp(App): # pylint: disable=too-many-public-methods
self.root.ids.sc17.add_widget(Allmails())
try:
self.root.ids.sc17.children[1].active = False
except Exception as e:
except Exception:
self.root.ids.sc17.children[0].children[1].active = False
@ -1843,7 +1841,8 @@ class GrashofPopup(Popup):
elif status == 'checksumfailed':
text = "The address is not typed or copied correctly(the checksum failed)."
elif status == 'versiontoohigh':
text = "The version number of this address is higher than this software can support. Please upgrade Bitmessage."
text = "The version number of this address is higher"\
" than this software can support. Please upgrade Bitmessage."
elif status == 'invalidcharacters':
text = "The address contains invalid characters."
elif status == 'ripetooshort':
@ -2311,9 +2310,7 @@ class Draft(Screen):
encoding = 3
sendMessageToPeople = True
if sendMessageToPeople:
from addresses import decodeAddress
streamNumber, ripe = decodeAddress(toAddress)[2:]
from addresses import addBMIfNotPresent
toAddress = addBMIfNotPresent(toAddress)
stealthLevel = BMConfigParser().safeGetInt(
'bitmessagesettings', 'ackstealthlevel')