Autopep8 part 2

This commit is contained in:
lakshyacis 2019-08-06 15:35:03 +05:30
parent 481becf969
commit dbe69348f4
No known key found for this signature in database
GPG Key ID: D2C539C8EC63E9EB

View File

@ -519,7 +519,6 @@ class MyTextInput(TextInput):
def on_text(self, instance, value): def on_text(self, instance, value):
"""Find all the occurrence of the word.""" """Find all the occurrence of the word."""
import pdb;pdb.set_trace()
self.parent.parent.parent.parent.ids.rv.data = [] self.parent.parent.parent.parent.ids.rv.data = []
matches = [self.word_list[i] for i in range( matches = [self.word_list[i] for i in range(
len(self.word_list)) if self.word_list[ len(self.word_list)) if self.word_list[
@ -909,7 +908,8 @@ class NavigateApp(App):
return "textdemo" return "textdemo"
elif name == "values": elif name == "values":
if BMConfigParser().addresses(): if BMConfigParser().addresses():
return [address[:16] + '..' for address in BMConfigParser().addresses()] return [address[:16] + '..'
for address in BMConfigParser().addresses()]
else: else:
return "valuesdemo" return "valuesdemo"
@ -929,24 +929,24 @@ class NavigateApp(App):
self.root.ids.sc16.add_widget(Draft()) self.root.ids.sc16.add_widget(Draft())
self.root.ids.scr_mngr.current = 'inbox' self.root.ids.scr_mngr.current = 'inbox'
msg_counter_objs = self.root_window.children[1].children[2].children[0].ids msg_counter_objs = \
self.root_window.children[1].children[2].children[0].ids
state.sent_count = str( state.sent_count = str(
sqlQuery( sqlQuery(
"SELECT COUNT(*) FROM sent WHERE fromaddress = '{}' and folder = 'sent' ;".format( "SELECT COUNT(*) FROM sent WHERE fromaddress = '{}' and \
state.association))[0][0]) folder = 'sent' ;".format(state.association))[0][0])
state.inbox_count = str( state.inbox_count = str(
sqlQuery( sqlQuery(
"SELECT COUNT(*) FROM inbox WHERE fromaddress = '{}' and folder = 'inbox' ;".format( "SELECT COUNT(*) FROM inbox WHERE fromaddress = '{}' and \
state.association))[0][0]) folder = 'inbox' ;".format(state.association))[0][0])
state.trash_count = str( state.trash_count = str(sqlQuery("SELECT (SELECT count(*) FROM sent \
sqlQuery( where fromaddress = '{0}' and folder = 'trash' ) \
"SELECT (SELECT count(*) FROM sent where fromaddress = '{0}' and folder = 'trash' )\ +(SELECT count(*) FROM inbox where fromaddress = '{0}' and \
+(SELECT count(*) FROM inbox where fromaddress = '{0}' and folder = 'trash') AS SumCount".format( folder = 'trash') AS SumCount".format(state.association))[0][0])
state.association))[0][0])
state.draft_count = str( state.draft_count = str(
sqlQuery( sqlQuery(
"SELECT COUNT(*) FROM sent WHERE fromaddress = '{}' and folder = 'draft' ;".format( "SELECT COUNT(*) FROM sent WHERE fromaddress = '{}' and \
state.association))[0][0]) folder = 'draft' ;".format(state.association))[0][0])
if msg_counter_objs: if msg_counter_objs:
msg_counter_objs.send_cnt.badge_text = state.sent_count msg_counter_objs.send_cnt.badge_text = state.sent_count
@ -955,7 +955,7 @@ class NavigateApp(App):
msg_counter_objs.draft_cnt.badge_text = state.draft_count msg_counter_objs.draft_cnt.badge_text = state.draft_count
def getInboxMessageDetail(self, instance): def getInboxMessageDetail(self, instance):
"""It will get message detail after make selected message description.""" """Getting message detail after selected message description."""
try: try:
self.root.ids._mngr.current = 'page' self.root.ids._mngr.current = 'page'
except AttributeError: except AttributeError:
@ -991,14 +991,15 @@ class NavigateApp(App):
"""Method is used for going on previous screen.""" """Method is used for going on previous screen."""
if key == 27: if key == 27:
if self.root.ids.scr_mngr.current == "mailDetail": if self.root.ids.scr_mngr.current == "mailDetail":
self.root.ids.scr_mngr.current = 'sent' if state.detailPageType == 'sent' else 'inbox' self.root.ids.scr_mngr.current = \
'sent' if state.detailPageType == 'sent' else 'inbox'
show_search_btn(self) show_search_btn(self)
elif self.root.ids.scr_mngr.current == "create": elif self.root.ids.scr_mngr.current == "create":
composer_objs = self.root composer_objs = self.root
from_addr = str( from_addr = str(self.root.children[1].children[0].children[
self.root.children[1].children[0].children[0].children[0].children[0].ids.ti.text) 0].children[0].children[0].ids.ti.text)
to_addr = str( to_addr = str(self.root.children[1].children[0].children[
self.root.children[1].children[0].children[0].children[0].children[0].ids.txt_input.text) 0].children[0].children[0].ids.txt_input.text)
if from_addr and to_addr: if from_addr and to_addr:
Draft().draft_msg(composer_objs) Draft().draft_msg(composer_objs)
self.root.ids.serch_btn.opacity = 1 self.root.ids.serch_btn.opacity = 1
@ -1038,7 +1039,7 @@ class NavigateApp(App):
def on_stop(self): def on_stop(self):
"""On stop methos is used for stoping the runing script.""" """On stop methos is used for stoping the runing script."""
print("**************************EXITING FROM APPLICATION*****************************") print("*******************EXITING FROM APPLICATION*******************")
import shutdown import shutdown
shutdown.doCleanShutdown() shutdown.doCleanShutdown()
@ -1047,27 +1048,28 @@ class NavigateApp(App):
if BMConfigParser().addresses(): if BMConfigParser().addresses():
state.association = BMConfigParser().addresses()[0] state.association = BMConfigParser().addresses()[0]
if text == 'Sent': if text == 'Sent':
state.sent_count = str( state.sent_count = str(sqlQuery(
sqlQuery("SELECT COUNT(*) FROM {0} WHERE fromaddress = '{1}' and folder = '{0}' ;".format( "SELECT COUNT(*) FROM {0} WHERE fromaddress = '{1}' and \
folder = '{0}' ;".format(
text.lower(), state.association))[0][0]) text.lower(), state.association))[0][0])
return state.sent_count return state.sent_count
elif text == 'Inbox': elif text == 'Inbox':
state.inbox_count = str( state.inbox_count = str(sqlQuery(
sqlQuery( "SELECT COUNT(*) FROM {0} WHERE fromaddress = '{1}' and \
"SELECT COUNT(*) FROM {0} WHERE fromaddress = '{1}' and folder = '{0}' ;".format( folder = '{0}' ;".format(
text.lower(), state.association))[0][0]) text.lower(), state.association))[0][0])
return state.inbox_count return state.inbox_count
elif text == 'Trash': elif text == 'Trash':
state.trash_count = str( state.trash_count = str(sqlQuery(
sqlQuery( "SELECT (SELECT count(*) FROM sent where fromaddress = '{0}' \
"SELECT (SELECT count(*) FROM sent where fromaddress = '{0}' and folder = 'trash' )\ and folder = 'trash' )+(SELECT count(*) FROM inbox where \
+(SELECT count(*) FROM inbox where fromaddress = '{0}' and folder = 'trash') AS SumCount".format( fromaddress = '{0}' and folder = 'trash') AS SumCount".format(
state.association))[0][0]) state.association))[0][0])
return state.trash_count return state.trash_count
elif text == 'Draft': elif text == 'Draft':
state.draft_count = str( state.draft_count = str(sqlQuery(
sqlQuery( "SELECT COUNT(*) FROM sent WHERE fromaddress = '{1}' and \
"SELECT COUNT(*) FROM sent WHERE fromaddress = '{1}' and folder = '{0}' ;".format( folder = '{0}' ;".format(
text.lower(), state.association))[0][0]) text.lower(), state.association))[0][0])
return state.draft_count return state.draft_count
@ -1129,7 +1131,7 @@ class NavigateApp(App):
self.root.ids.sc4.add_widget(Sent()) self.root.ids.sc4.add_widget(Sent())
def check_search_screen(self, instance): def check_search_screen(self, instance):
"""Method used for showing search button only on inbox or sent screen.""" """Method shows search button on inbox and sent screen only."""
if instance.text == 'Inbox' or instance.text == 'Sent': if instance.text == 'Inbox' or instance.text == 'Sent':
self.root.ids.serch_btn.opacity = 1 self.root.ids.serch_btn.opacity = 1
self.root.ids.serch_btn.disabled = False self.root.ids.serch_btn.disabled = False
@ -1159,7 +1161,8 @@ class GrashofPopup(Popup):
def savecontact(self): def savecontact(self):
"""Method is used for Saving Contacts.""" """Method is used for Saving Contacts."""
my_addresses = self.parent.children[1].children[2].children[0].ids.btn.values my_addresses = \
self.parent.children[1].children[2].children[0].ids.btn.values
entered_text = str(self.ids.label.text) entered_text = str(self.ids.label.text)
if entered_text in my_addresses: if entered_text in my_addresses:
self.ids.label.focus = True self.ids.label.focus = True
@ -1181,7 +1184,8 @@ class GrashofPopup(Popup):
def show_error_message(self): def show_error_message(self):
"""Showing error message.""" """Showing error message."""
content = MDLabel(font_style='Body1', content = MDLabel(
font_style='Body1',
theme_text_color='Secondary', theme_text_color='Secondary',
text="Hey you are not allowed to save blank address contact. " text="Hey you are not allowed to save blank address contact. "
"That's wrong!", "That's wrong!",
@ -1262,15 +1266,16 @@ class MailDetail(Screen):
self.page_type = state.detailPageType if state.detailPageType else '' self.page_type = state.detailPageType if state.detailPageType else ''
if state.detailPageType == 'sent': if state.detailPageType == 'sent':
data = sqlQuery( data = sqlQuery(
"select toaddress, fromaddress, subject, message , status, ackdata from sent \ "select toaddress, fromaddress, subject, message, status, \
where lastactiontime = {};".format(state.sentMailTime)) ackdata from sent where lastactiontime = {};".format(
state.sentMailTime))
state.status = self state.status = self
state.ackdata = data[0][5] state.ackdata = data[0][5]
self.assign_mail_details(data) self.assign_mail_details(data)
elif state.detailPageType == 'inbox': elif state.detailPageType == 'inbox':
data = sqlQuery( data = sqlQuery(
"select toaddress, fromaddress, subject, message from inbox where received = {};".format( "select toaddress, fromaddress, subject, message from inbox \
state.sentMailTime)) where received = {};".format(state.sentMailTime))
self.assign_mail_details(data) self.assign_mail_details(data)
def assign_mail_details(self, data): def assign_mail_details(self, data):
@ -1284,18 +1289,21 @@ class MailDetail(Screen):
def delete_mail(self): def delete_mail(self):
"""Method for mail delete.""" """Method for mail delete."""
msg_count_objs = self.parent.parent.parent.parent.parent.children[2].children[0].ids msg_count_objs = \
self.parent.parent.parent.parent.parent.children[2].children[0].ids
if state.detailPageType == 'sent': if state.detailPageType == 'sent':
sqlExecute("UPDATE sent SET folder = 'trash' WHERE lastactiontime = {};".format( sqlExecute(
state.sentMailTime)) "UPDATE sent SET folder = 'trash' WHERE \
lastactiontime = {};".format(state.sentMailTime))
msg_count_objs.send_cnt.badge_text = str(int(state.sent_count) - 1) msg_count_objs.send_cnt.badge_text = str(int(state.sent_count) - 1)
state.sent_count = str(int(state.sent_count) - 1) state.sent_count = str(int(state.sent_count) - 1)
self.parent.parent.screens[3].clear_widgets() self.parent.parent.screens[3].clear_widgets()
self.parent.parent.screens[3].add_widget(Sent()) self.parent.parent.screens[3].add_widget(Sent())
self.parent.parent.current = 'sent' self.parent.parent.current = 'sent'
elif state.detailPageType == 'inbox': elif state.detailPageType == 'inbox':
sqlExecute("UPDATE inbox SET folder = 'trash' WHERE received = {};".format( sqlExecute(
state.sentMailTime)) "UPDATE inbox SET folder = 'trash' WHERE \
received = {};".format(state.sentMailTime))
msg_count_objs.inbox_cnt.badge_text = str( msg_count_objs.inbox_cnt.badge_text = str(
int(state.inbox_count) - 1) int(state.inbox_count) - 1)
state.inbox_count = str(int(state.inbox_count) - 1) state.inbox_count = str(int(state.inbox_count) - 1)
@ -1312,8 +1320,8 @@ class MailDetail(Screen):
def inbox_reply(self): def inbox_reply(self):
"""Method used for replying inbox messages.""" """Method used for replying inbox messages."""
data = sqlQuery( data = sqlQuery(
"select toaddress, fromaddress, subject, message from inbox where received = {};".format( "select toaddress, fromaddress, subject, message from inbox where \
state.sentMailTime)) received = {};".format(state.sentMailTime))
composer_obj = self.parent.parent.screens[2].children[0].ids composer_obj = self.parent.parent.screens[2].children[0].ids
composer_obj.ti.text = data[0][1] composer_obj.ti.text = data[0][1]
composer_obj.btn.text = data[0][1] composer_obj.btn.text = data[0][1]
@ -1383,10 +1391,8 @@ class AddbookDetailPopup(Popup):
def update_addbook_label(self, address): def update_addbook_label(self, address):
"""Updating the label of address book address.""" """Updating the label of address book address."""
if str(self.ids.add_label.text): if str(self.ids.add_label.text):
sqlExecute( sqlExecute("UPDATE addressbook SET label = '{}' WHERE \
"UPDATE addressbook SET label = '{}' WHERE address = '{}';".format( address = '{}';".format(str(self.ids.add_label.text), address))
str(
self.ids.add_label.text), address))
self.parent.children[1].ids.sc11.clear_widgets() self.parent.children[1].ids.sc11.clear_widgets()
self.parent.children[1].ids.sc11.add_widget(AddressBook()) self.parent.children[1].ids.sc11.add_widget(AddressBook())
self.dismiss() self.dismiss()
@ -1483,7 +1489,8 @@ class Draft(Screen):
carousel.index = 1 carousel.index = 1
self.ids.ml.add_widget(carousel) self.ids.ml.add_widget(carousel)
else: else:
content = MDLabel(font_style='Body1', content = MDLabel(
font_style='Body1',
theme_text_color='Primary', theme_text_color='Primary',
text="yet no message for this account!!!!!!!!!!!!!", text="yet no message for this account!!!!!!!!!!!!!",
halign='center', halign='center',
@ -1494,12 +1501,14 @@ class Draft(Screen):
def delete_draft(self, data_index, instance, *args): def delete_draft(self, data_index, instance, *args):
"""Method used to delete draft message permanently.""" """Method used to delete draft message permanently."""
sqlExecute( sqlExecute("DELETE FROM sent WHERE lastactiontime = '{}';".format(
"DELETE FROM sent WHERE lastactiontime = '{}';".format(data_index)) data_index))
try: try:
msg_count_objs = self.parent.parent.parent.parent.children[2].children[0].ids msg_count_objs = \
self.parent.parent.parent.parent.children[2].children[0].ids
except Exception as e: except Exception as e:
msg_count_objs = self.parent.parent.parent.parent.parent.children[2].children[0].ids msg_count_objs = self.parent.parent.parent.parent.parent.children[
2].children[0].ids
if int(state.draft_count) > 0: if int(state.draft_count) > 0:
msg_count_objs.draft_cnt.badge_text = str( msg_count_objs.draft_cnt.badge_text = str(
int(state.draft_count) - 1) int(state.draft_count) - 1)
@ -1508,7 +1517,8 @@ class Draft(Screen):
def draft_msg(self, src_object): def draft_msg(self, src_object):
"""Method used for saving draft mails.""" """Method used for saving draft mails."""
composer_object = src_object.children[1].children[0].children[0].children[0].children[0].ids composer_object = src_object.children[1].children[0].children[
0].children[0].children[0].ids
fromAddress = str(composer_object.ti.text) fromAddress = str(composer_object.ti.text)
toAddress = str(composer_object.txt_input.text) toAddress = str(composer_object.txt_input.text)
subject = str(composer_object.subject.text) subject = str(composer_object.subject.text)
@ -1517,8 +1527,8 @@ 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 = \
toAddress) decodeAddress(toAddress)
from addresses import addBMIfNotPresent from addresses import addBMIfNotPresent
toAddress = addBMIfNotPresent(toAddress) toAddress = addBMIfNotPresent(toAddress)
statusIconColor = 'red' statusIconColor = 'red'
@ -1528,7 +1538,8 @@ class Draft(Screen):
ackdata = genAckPayload(streamNumber, stealthLevel) ackdata = genAckPayload(streamNumber, stealthLevel)
t = () t = ()
sqlExecute( sqlExecute(
'''INSERT INTO sent VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)''', '''INSERT INTO sent VALUES
(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)''',
'', '',
toAddress, toAddress,
ripe, ripe,
@ -1560,6 +1571,7 @@ def show_search_btn(self):
def hide_search_btn(mgr_objs): def hide_search_btn(mgr_objs):
"""Method used to hide search button and search box.""" """Method used to hide search button and search box."""
mgr_objs.parent.parent.parent.ids.serch_btn.opacity = 0 mgr_objs.parent.parent.parent.ids.serch_btn.opacity = 0
mgr_objs.parent.parent.parent.ids.serch_btn.disabled = True mgr_objs.parent.parent.parent.ids.serch_btn.disabled = True
mgr_objs.parent.parent.parent.ids.search_input.size_hint = 1, None mgr_objs.parent.parent.parent.ids.search_input.size_hint = 1, None
@ -1567,7 +1579,8 @@ def hide_search_btn(mgr_objs):
mgr_objs.parent.parent.parent.ids.search_input.opacity = 0 mgr_objs.parent.parent.parent.ids.search_input.opacity = 0
mgr_objs.parent.parent.parent.ids.toolbar.left_action_items = \ mgr_objs.parent.parent.parent.ids.toolbar.left_action_items = \
[['menu', lambda x: mgr_objs.parent.parent.parent.toggle_nav_drawer()]] [['menu', lambda x: mgr_objs.parent.parent.parent.toggle_nav_drawer()]]
mgr_objs.parent.parent.parent.ids.toolbar.title = NavigateApp().current_address_label() mgr_objs.parent.parent.parent.ids.toolbar.title = \
NavigateApp().current_address_label()
mgr_objs.parent.parent.parent.ids.myButton.opacity = 1 mgr_objs.parent.parent.parent.ids.myButton.opacity = 1
mgr_objs.parent.parent.parent.ids.myButton.disabled = False mgr_objs.parent.parent.parent.ids.myButton.disabled = False
mgr_objs.parent.parent.parent.ids.reset_navbar.opacity = 0 mgr_objs.parent.parent.parent.ids.reset_navbar.opacity = 0
@ -1582,3 +1595,4 @@ class CustomSpinner(Spinner):
super(CustomSpinner, self).__init__(*args, **kwargs) super(CustomSpinner, self).__init__(*args, **kwargs)
max = 2.8 max = 2.8
self.dropdown_cls.max_height = self.height * max + max * 4 self.dropdown_cls.max_height = self.height * max + max * 4
print(args)