mpybit quality fixes

This commit is contained in:
lakshyacis 2019-11-22 17:03:20 +05:30
parent c08a49aec2
commit 912a0a0a1e
No known key found for this signature in database
GPG Key ID: D2C539C8EC63E9EB

View File

@ -1,8 +1,8 @@
""" """
Bitmessage kivy interface Bitmessage kivy interface
""" """
# pylint: disable=relative-import, unused-variable, import-error # pylint: disable=relative-import, import-error, no-name-in-module
# pylint: disable=no-name-in-module, too-many-lines, unused-argument # pylint: disable=too-few-public-methods, too-many-lines, unused-argument
import os import os
import time import time
from functools import partial from functools import partial
@ -65,7 +65,7 @@ import identiconGeneration
def toast(text): def toast(text):
"""Method will display the toast message.""" """Function displays toast message."""
# pylint: disable=redefined-outer-name # pylint: disable=redefined-outer-name
from kivymd.toast.kivytoast import toast from kivymd.toast.kivytoast import toast
toast(text) toast(text)
@ -73,8 +73,7 @@ def toast(text):
class Navigatorss(MDNavigationDrawer): class Navigatorss(MDNavigationDrawer):
"""Navigators class contains image, title and logo.""" """Navigator class contains image, title and logo."""
image_source = StringProperty('images/qidenticon_two.png') image_source = StringProperty('images/qidenticon_two.png')
title = StringProperty('Navigation') title = StringProperty('Navigation')
drawer_logo = StringProperty() drawer_logo = StringProperty()
@ -118,7 +117,7 @@ class Inbox(Screen):
src_mng_obj.inbox_cnt.badge_text = str(len(self.queryreturn)) src_mng_obj.inbox_cnt.badge_text = str(len(self.queryreturn))
state.inbox_count = str(len(self.queryreturn)) state.inbox_count = str(len(self.queryreturn))
for mail in self.queryreturn[:20]: for mail in self.queryreturn[:20]:
third_text = mail[3].replace('\n', ' ') # third_text = mail[3].replace('\n', ' ')
data.append({ data.append({
'text': mail[4].strip(), 'text': mail[4].strip(),
'secondary_text': mail[5][:50] + '........' if len( 'secondary_text': mail[5][:50] + '........' if len(
@ -192,7 +191,7 @@ class Inbox(Screen):
"""This method is used to load more data on scroll down""" """This method is used to load more data on scroll down"""
data = [] data = []
for mail in self.queryreturn[total_message:total_message + 5]: for mail in self.queryreturn[total_message:total_message + 5]:
third_text = mail[3].replace('\n', ' ') # third_text = mail[3].replace('\n', ' ')
data.append({ data.append({
'text': mail[4].strip(), 'text': mail[4].strip(),
'secondary_text': mail[5][:50] + '........' if len( 'secondary_text': mail[5][:50] + '........' if len(
@ -511,7 +510,6 @@ class SelectableRecycleBoxLayout(
class SelectableLabel(RecycleDataViewBehavior, Label): class SelectableLabel(RecycleDataViewBehavior, Label):
"""Add selection support to the Label.""" """Add selection support to the Label."""
index = None index = None
selected = BooleanProperty(False) selected = BooleanProperty(False)
selectable = BooleanProperty(True) selectable = BooleanProperty(True)
@ -552,7 +550,6 @@ class DropDownWidget(BoxLayout):
"""Adding Dropdown Widget.""" """Adding Dropdown Widget."""
# pylint: disable=too-many-statements, too-many-locals # pylint: disable=too-many-statements, too-many-locals
# pylint: disable=inconsistent-return-statements # pylint: disable=inconsistent-return-statements
txt_input = ObjectProperty() txt_input = ObjectProperty()
rv = ObjectProperty() rv = ObjectProperty()
@ -572,7 +569,8 @@ class DropDownWidget(BoxLayout):
decodeAddress(toAddress)) decodeAddress(toAddress))
if status == 'success': if status == 'success':
navApp.root.ids.sc3.children[0].active = True navApp.root.ids.sc3.children[0].active = True
if state.detailPageType == 'draft' and state.send_draft_mail: if state.detailPageType == 'draft' \
and state.send_draft_mail:
sqlExecute( sqlExecute(
"UPDATE sent SET toaddress = ?" "UPDATE sent SET toaddress = ?"
", fromaddress = ? , subject = ?" ", fromaddress = ? , subject = ?"
@ -603,7 +601,7 @@ class DropDownWidget(BoxLayout):
'bitmessagesettings', 'ackstealthlevel') 'bitmessagesettings', 'ackstealthlevel')
from helper_ackPayload import genAckPayload from helper_ackPayload import genAckPayload
ackdata = genAckPayload(streamNumber, stealthLevel) ackdata = genAckPayload(streamNumber, stealthLevel)
t = () # t = ()
sqlExecute( sqlExecute(
'''INSERT INTO sent VALUES '''INSERT INTO sent VALUES
(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)''', (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)''',
@ -635,7 +633,7 @@ class DropDownWidget(BoxLayout):
self.parent.parent.screens[16].add_widget(Allmails()) self.parent.parent.screens[16].add_widget(Allmails())
# toast('sending...') # toast('sending...')
Clock.schedule_once(self.callback_for_msgsend, 3) Clock.schedule_once(self.callback_for_msgsend, 3)
toLabel = '' # toLabel = ''
queues.workerQueue.put(('sendmessage', toAddress)) queues.workerQueue.put(('sendmessage', toAddress))
print "sqlExecute successfully #######################" print "sqlExecute successfully #######################"
state.in_composer = True state.in_composer = True
@ -687,7 +685,6 @@ class DropDownWidget(BoxLayout):
class MyTextInput(TextInput): class MyTextInput(TextInput):
"""Takes the text input in the field.""" """Takes the text input in the field."""
txt_input = ObjectProperty() txt_input = ObjectProperty()
flt_list = ObjectProperty() flt_list = ObjectProperty()
word_list = ListProperty() word_list = ListProperty()
@ -746,19 +743,16 @@ class Payment(Screen):
class Credits(Screen): class Credits(Screen):
"""Credits Method""" """Credits Method"""
available_credits = StringProperty( available_credits = StringProperty('{0}'.format('0'))
'{0}'.format('0'))
class Login(Screen): class Login(Screen):
"""Login Screeen.""" """Login Screeen."""
pass pass
class NetworkStat(Screen): class NetworkStat(Screen):
"""Method used to show network stat.""" """Method used to show network stat."""
text_variable_1 = StringProperty( text_variable_1 = StringProperty(
'{0}::{1}'.format('Total Connections', '0')) '{0}::{1}'.format('Total Connections', '0'))
text_variable_2 = StringProperty( text_variable_2 = StringProperty(
@ -793,13 +787,11 @@ class NetworkStat(Screen):
class ContentNavigationDrawer(Navigatorss): class ContentNavigationDrawer(Navigatorss):
"""Navigate Content Drawer.""" """Navigate Content Drawer."""
pass pass
class Random(Screen): class Random(Screen):
"""Generates Random Address.""" """Generates Random Address."""
is_active = BooleanProperty(False) is_active = BooleanProperty(False)
checked = StringProperty("") checked = StringProperty("")
@ -1179,7 +1171,6 @@ class Setting(Screen):
class NavigateApp(App): class NavigateApp(App):
"""Navigation Layout of class.""" """Navigation Layout of class."""
# pylint: disable=too-many-public-methods # pylint: disable=too-many-public-methods
theme_cls = ThemeManager() theme_cls = ThemeManager()
previous_date = ObjectProperty() previous_date = ObjectProperty()
obj_1 = ObjectProperty() obj_1 = ObjectProperty()
@ -1412,7 +1403,8 @@ class NavigateApp(App):
composer_objs = self.root composer_objs = self.root
from_addr = str(self.root.ids.sc3.children[1].ids.ti.text) from_addr = str(self.root.ids.sc3.children[1].ids.ti.text)
to_addr = str(self.root.ids.sc3.children[1].ids.txt_input.text) to_addr = str(self.root.ids.sc3.children[1].ids.txt_input.text)
if from_addr and to_addr and state.detailPageType != 'draft' and not state.in_sent_method: if from_addr and to_addr and state.detailPageType != 'draft' \
and not state.in_sent_method:
Draft().draft_msg(composer_objs) Draft().draft_msg(composer_objs)
return return
@ -1461,7 +1453,8 @@ class NavigateApp(App):
def back_press(self): def back_press(self):
"""Method used for going back from composer to previous page.""" """Method used for going back from composer to previous page."""
self.save_draft() self.save_draft()
if self.root.ids.scr_mngr.current == 'mailDetail' and state.in_search_mode: if self.root.ids.scr_mngr.current == 'mailDetail' \
and state.in_search_mode:
toolbar_obj = self.root.ids.toolbar toolbar_obj = self.root.ids.toolbar
toolbar_obj.left_action_items = [ toolbar_obj.left_action_items = [
['arrow-left', lambda x: self.closeSearchScreen()]] ['arrow-left', lambda x: self.closeSearchScreen()]]
@ -1527,29 +1520,36 @@ class NavigateApp(App):
self.refreshScreen() self.refreshScreen()
state.in_search_mode = False state.in_search_mode = False
def refreshScreen(self): def refreshScreen(self): # pylint: disable=unused-variable
"""Method show search button only on inbox or sent screen.""" """Method show search button only on inbox or sent screen."""
state.searcing_text = '' state.searcing_text = ''
if state.search_screen == 'inbox': if state.search_screen == 'inbox':
try: try:
self.root.ids.sc1.children[3].children[1].ids.search_field.text = '' self.root.ids.sc1.children[
3].children[1].ids.search_field.text = ''
except Exception: except Exception:
self.root.ids.sc1.children[2].children[1].ids.search_field.text = '' self.root.ids.sc1.children[
2].children[1].ids.search_field.text = ''
self.root.ids.sc1.children[1].active = True self.root.ids.sc1.children[1].active = True
Clock.schedule_once(self.search_callback, 0.5) Clock.schedule_once(self.search_callback, 0.5)
elif state.search_screen == 'addressbook': elif state.search_screen == 'addressbook':
self.root.ids.sc11.children[2].children[1].ids.search_field.text = '' self.root.ids.sc11.children[
self.root.ids.sc11.children[1].active = True 2].children[1].ids.search_field.text = ''
self.root.ids.sc11.children[
1].active = True
Clock.schedule_once(self.search_callback, 0.5) Clock.schedule_once(self.search_callback, 0.5)
elif state.search_screen == 'myaddress': elif state.search_screen == 'myaddress':
try: try:
self.root.ids.sc10.children[3].children[1].ids.search_field.text = '' self.root.ids.sc10.children[
3].children[1].ids.search_field.text = ''
except Exception: except Exception:
self.root.ids.sc10.children[2].children[1].ids.search_field.text = '' self.root.ids.sc10.children[
2].children[1].ids.search_field.text = ''
self.root.ids.sc10.children[1].active = True self.root.ids.sc10.children[1].active = True
Clock.schedule_once(self.search_callback, 0.5) Clock.schedule_once(self.search_callback, 0.5)
else: else:
self.root.ids.sc4.children[2].children[1].ids.search_field.text = '' self.root.ids.sc4.children[
2].children[1].ids.search_field.text = ''
self.root.ids.sc4.children[1].active = True self.root.ids.sc4.children[1].active = True
Clock.schedule_once(self.search_callback, 0.5) Clock.schedule_once(self.search_callback, 0.5)
return return
@ -1605,7 +1605,8 @@ class GrashofPopup(Popup):
folder="addressbook")] folder="addressbook")]
stored_labels = [labels[0] for labels in kivy_helper_search.search_sql( stored_labels = [labels[0] for labels in kivy_helper_search.search_sql(
folder="addressbook")] folder="addressbook")]
if label and address and address not in stored_address and label not in stored_labels: if label and address and address not in stored_address \
and label not in stored_labels:
# state.navinstance = self.parent.children[1] # state.navinstance = self.parent.children[1]
queues.UISignalQueue.put(('rerenderAddressBook', '')) queues.UISignalQueue.put(('rerenderAddressBook', ''))
self.dismiss() self.dismiss()
@ -1664,8 +1665,7 @@ class GrashofPopup(Popup):
def checkLabel_valid(self, instance): def checkLabel_valid(self, instance):
"""Checking address label is unique of not""" """Checking address label is unique of not"""
entered_label = instance.text.strip() entered_label = instance.text.strip()
addr_labels = [labels[0] addr_labels = [labels[0] for labels in kivy_helper_search.search_sql(
for labels in kivy_helper_search.search_sql(
folder="addressbook")] folder="addressbook")]
if entered_label in addr_labels: if entered_label in addr_labels:
self.ids.label.error = True self.ids.label.error = True
@ -1679,26 +1679,22 @@ class GrashofPopup(Popup):
class AvatarSampleWidget(ILeftBody, Image): class AvatarSampleWidget(ILeftBody, Image):
"""Avatar Sample Widget.""" """Avatar Sample Widget."""
pass pass
class IconLeftSampleWidget(ILeftBodyTouch, MDIconButton): class IconLeftSampleWidget(ILeftBodyTouch, MDIconButton):
"""Left icon sample widget.""" """Left icon sample widget."""
pass pass
class IconRightSampleWidget(IRightBodyTouch, MDCheckbox): class IconRightSampleWidget(IRightBodyTouch, MDCheckbox):
"""Right icon sample widget.""" """Right icon sample widget."""
pass pass
class NavigationDrawerTwoLineListItem( class NavigationDrawerTwoLineListItem(
TwoLineListItem, NavigationDrawerHeaderBase): TwoLineListItem, NavigationDrawerHeaderBase):
"""Navigation Drawer in Listitems.""" """Navigation Drawer in Listitems."""
address_property = StringProperty() address_property = StringProperty()
def __init__(self, **kwargs): def __init__(self, **kwargs):
@ -1723,7 +1719,6 @@ class NavigationDrawerTwoLineListItem(
class MailDetail(Screen): class MailDetail(Screen):
"""MailDetail Screen uses to show the detail of mails.""" """MailDetail Screen uses to show the detail of mails."""
to_addr = StringProperty() to_addr = StringProperty()
from_addr = StringProperty() from_addr = StringProperty()
subject = StringProperty() subject = StringProperty()
@ -1798,7 +1793,8 @@ class MailDetail(Screen):
self.parent.screens[15].clear_widgets() self.parent.screens[15].clear_widgets()
self.parent.screens[15].add_widget(Draft()) self.parent.screens[15].add_widget(Draft())
self.parent.current = 'allmails' if state.is_allmail else state.detailPageType self.parent.current = 'allmails' \
if state.is_allmail else state.detailPageType
if state.detailPageType != 'draft': if state.detailPageType != 'draft':
msg_count_objs.trash_cnt.badge_text = str( msg_count_objs.trash_cnt.badge_text = str(
int(state.trash_count) + 1) int(state.trash_count) + 1)
@ -1859,7 +1855,6 @@ class MailDetail(Screen):
class MyaddDetailPopup(Popup): class MyaddDetailPopup(Popup):
"""MyaddDetailPopup pop is used for showing my address detail.""" """MyaddDetailPopup pop is used for showing my address detail."""
address_label = StringProperty() address_label = StringProperty()
address = StringProperty() address = StringProperty()
@ -1893,7 +1888,6 @@ class MyaddDetailPopup(Popup):
class AddbookDetailPopup(Popup): class AddbookDetailPopup(Popup):
"""AddbookDetailPopup pop is used for showing my address detail.""" """AddbookDetailPopup pop is used for showing my address detail."""
address_label = StringProperty() address_label = StringProperty()
address = StringProperty() address = StringProperty()
@ -1948,7 +1942,8 @@ class AddbookDetailPopup(Popup):
address_list = kivy_helper_search.search_sql(folder="addressbook") address_list = kivy_helper_search.search_sql(folder="addressbook")
addr_labels = [labels[0] for labels in address_list] addr_labels = [labels[0] for labels in address_list]
add_dict = dict(address_list) add_dict = dict(address_list)
if self.address and entered_label in addr_labels and self.address != add_dict[entered_label]: if self.address and entered_label in addr_labels \
and self.address != add_dict[entered_label]:
self.ids.add_label.error = True self.ids.add_label.error = True
self.ids.add_label.helper_text = 'label name already exists.' self.ids.add_label.helper_text = 'label name already exists.'
elif entered_label: elif entered_label:
@ -1973,7 +1968,6 @@ class ShowQRCode(Screen):
class Draft(Screen): class Draft(Screen):
"""Draft screen is used to show the list of draft messages.""" """Draft screen is used to show the list of draft messages."""
data = ListProperty() data = ListProperty()
queryreturn = ListProperty() queryreturn = ListProperty()
has_refreshed = True has_refreshed = True
@ -2117,16 +2111,17 @@ class Draft(Screen):
sendMessageToPeople = True sendMessageToPeople = True
if sendMessageToPeople: if sendMessageToPeople:
from addresses import decodeAddress from addresses import decodeAddress
status, addressVersionNumber, streamNumber, ripe = decodeAddress( # status, addressVersionNumber, streamNumber, ripe = decodeAddress(
toAddress) # toAddress)
streamNumber, ripe = decodeAddress(toAddress)[2:]
from addresses import addBMIfNotPresent from addresses import addBMIfNotPresent
toAddress = addBMIfNotPresent(toAddress) toAddress = addBMIfNotPresent(toAddress)
statusIconColor = 'red' # statusIconColor = 'red'
stealthLevel = BMConfigParser().safeGetInt( stealthLevel = BMConfigParser().safeGetInt(
'bitmessagesettings', 'ackstealthlevel') 'bitmessagesettings', 'ackstealthlevel')
from helper_ackPayload import genAckPayload from helper_ackPayload import genAckPayload
ackdata = genAckPayload(streamNumber, stealthLevel) ackdata = genAckPayload(streamNumber, stealthLevel)
t = () # t = ()
sqlExecute( sqlExecute(
'''INSERT INTO sent VALUES '''INSERT INTO sent VALUES
(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)''', (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)''',
@ -2165,7 +2160,6 @@ class CustomSpinner(Spinner):
class Allmails(Screen): class Allmails(Screen):
"""all mails Screen uses screen to show widgets of screens.""" """all mails Screen uses screen to show widgets of screens."""
data = ListProperty() data = ListProperty()
has_refreshed = True has_refreshed = True
all_mails = ListProperty() all_mails = ListProperty()
@ -2197,7 +2191,8 @@ class Allmails(Screen):
" message, folder, msgid As id, DATE(received) As actionTime" " message, folder, msgid As id, DATE(received) As actionTime"
" FROM inbox WHERE folder = 'inbox' ORDER BY actionTime DESC") " FROM inbox WHERE folder = 'inbox' ORDER BY actionTime DESC")
if self.all_mails: if self.all_mails:
state.kivyapp.root.children[2].children[0].ids.allmail_cnt.badge_text = str( state.kivyapp.root.children[2].children[
0].ids.allmail_cnt.badge_text = str(
len(self.all_mails)) len(self.all_mails))
state.all_count = str(len(self.all_mails)) state.all_count = str(len(self.all_mails))
self.set_mdlist(0, 20) self.set_mdlist(0, 20)
@ -2277,7 +2272,7 @@ class Allmails(Screen):
src_mng_obj.current = 'mailDetail' src_mng_obj.current = 'mailDetail'
def swipe_delete(self, unique_id, folder, instance, *args): def swipe_delete(self, unique_id, folder, instance, *args):
"""Delete inbox mail from all mail listing listing.""" """Delete inbox mail from all mail listing."""
if folder == 'inbox': if folder == 'inbox':
sqlExecute( sqlExecute(
"UPDATE inbox SET folder = 'trash' WHERE msgid = ?;", str( "UPDATE inbox SET folder = 'trash' WHERE msgid = ?;", str(
@ -2320,7 +2315,8 @@ class Allmails(Screen):
# pylint: disable=attribute-defined-outside-init # pylint: disable=attribute-defined-outside-init
def refresh_callback(self, *args): def refresh_callback(self, *args):
"""Method updates the state of application, While the spinner remains on the screen.""" """Method updates the state of application,
While the spinner remains on the screen."""
def refresh_callback(interval): def refresh_callback(interval):
"""Method used for loading the allmails screen data.""" """Method used for loading the allmails screen data."""
self.ids.ml.clear_widgets() self.ids.ml.clear_widgets()
@ -2338,42 +2334,38 @@ class Allmails(Screen):
"""Setting root layout""" """Setting root layout"""
try: try:
return self.manager.parent.parent return self.manager.parent.parent
except Exception as e: except Exception:
return state.kivyapp.root.ids.float_box return state.kivyapp.root.ids.float_box
def avatarImageFirstLetter(letter_string): def avatarImageFirstLetter(letter_string):
"""This method is used to the first letter for the avatar image""" """This function is used to the first letter for the avatar image"""
if letter_string[0].upper() >= 'A' and letter_string[0].upper() <= 'Z': if letter_string[0].upper() >= 'A' and letter_string[0].upper() <= 'Z':
img_latter = letter_string[0].upper() img_latter = letter_string[0].upper()
elif int(letter_string[0]) >= 0 and int(letter_string[0]) <= 9: elif int(letter_string[0]) >= 0 and int(letter_string[0]) <= 9:
img_latter = letter_string[0] img_latter = letter_string[0]
else: else:
img_latter = '!' img_latter = '!'
return img_latter return img_latter
class Starred(Screen): class Starred(Screen):
"""Starred Screen show widgets of page.""" """Starred Screen show widgets of page."""
pass pass
class Archieve(Screen): class Archieve(Screen):
"""Archieve Screen show widgets of page.""" """Archieve Screen show widgets of page."""
pass pass
class Spam(Screen): class Spam(Screen):
"""Spam Screen show widgets of page.""" """Spam Screen show widgets of page."""
pass pass
class LoadingPopup(Popup): class LoadingPopup(Popup):
"""Load Popup""" """Class for loading Popup"""
def __init__(self, **kwargs): def __init__(self, **kwargs):
super(LoadingPopup, self).__init__(**kwargs) super(LoadingPopup, self).__init__(**kwargs)
@ -2381,5 +2373,5 @@ class LoadingPopup(Popup):
Clock.schedule_once(self.dismiss_popup, 0.5) Clock.schedule_once(self.dismiss_popup, 0.5)
def dismiss_popup(self, dt): def dismiss_popup(self, dt):
"""Dismissing popup""" """Dismiss popups"""
self.dismiss() self.dismiss()