docstring and formatting mpybit

This commit is contained in:
lakshyacis 2019-11-29 17:42:38 +05:30
parent b90c9da0a4
commit e0536e7497
No known key found for this signature in database
GPG Key ID: D2C539C8EC63E9EB

View File

@ -1,12 +1,12 @@
""" """
Bitmessage kivy interface Bitmessage android(mobile) interface
""" """
# pylint: disable=relative-import, import-error, no-name-in-module # pylint: disable=relative-import, import-error, no-name-in-module
# pylint: disable=too-few-public-methods, 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 bmconfigparser import BMConfigParser from bmconfigparser import BMConfigParser
from functools import partial
from helper_sql import sqlExecute, sqlQuery from helper_sql import sqlExecute, sqlQuery
from kivy.app import App from kivy.app import App
from kivy.clock import Clock from kivy.clock import Clock
@ -65,7 +65,7 @@ import identiconGeneration
def toast(text): def toast(text):
"""Function displays 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,19 +73,19 @@ def toast(text):
class Navigatorss(MDNavigationDrawer): class Navigatorss(MDNavigationDrawer):
"""Navigator class contains image, title and logo.""" """Navigator class (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()
class Inbox(Screen): class Inbox(Screen):
"""Inbox Screen uses screen to show widgets of screens.""" """Inbox Screen uses screen to show widgets of screens"""
queryreturn = ListProperty() queryreturn = ListProperty()
has_refreshed = True has_refreshed = True
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
"""Method Parsing the address.""" """Method Parsing the address"""
super(Inbox, self).__init__(*args, **kwargs) super(Inbox, self).__init__(*args, **kwargs)
if state.association == '': if state.association == '':
if BMConfigParser().addresses(): if BMConfigParser().addresses():
@ -93,17 +93,17 @@ class Inbox(Screen):
Clock.schedule_once(self.init_ui, 0) Clock.schedule_once(self.init_ui, 0)
def init_ui(self, dt=0): def init_ui(self, dt=0):
"""Clock Schdule for method inbox accounts.""" """Clock schdule for method inbox accounts"""
self.inboxaccounts() self.inboxaccounts()
print dt print dt
def inboxaccounts(self): def inboxaccounts(self):
"""Load inbox accounts.""" """Load all inbox accounts"""
account = state.association account = state.association
self.loadMessagelist(account, 'All', '') self.loadMessagelist(account, 'All', '')
def loadMessagelist(self, account, where="", what=""): def loadMessagelist(self, account, where="", what=""):
"""Load Inbox list for Inbox messages.""" """Load inbox list for inbox messages"""
# pylint: disable=too-many-locals # pylint: disable=too-many-locals
if state.searcing_text: if state.searcing_text:
self.children[2].children[0].children[0].scroll_y = 1.0 self.children[2].children[0].children[0].scroll_y = 1.0
@ -149,10 +149,13 @@ class Inbox(Screen):
secondary_text=item['secondary_text'], secondary_text=item['secondary_text'],
theme_text_color='Custom', theme_text_color='Custom',
text_color=NavigateApp().theme_cls.primary_color) text_color=NavigateApp().theme_cls.primary_color)
meny.add_widget(AvatarSampleWidget( meny.add_widget(
AvatarSampleWidget(
source='./images/text_images/{}.png'.format( source='./images/text_images/{}.png'.format(
avatarImageFirstLetter(item['secondary_text'].strip())))) avatarImageFirstLetter(
meny.bind(on_press=partial( item['secondary_text'].strip()))))
meny.bind(
on_press=partial(
self.inbox_detail, item['msgid'])) self.inbox_detail, item['msgid']))
carousel = Carousel(direction='right') carousel = Carousel(direction='right')
carousel.height = meny.height carousel.height = meny.height
@ -163,13 +166,15 @@ class Inbox(Screen):
del_btn = Button(text='Delete') del_btn = Button(text='Delete')
del_btn.background_normal = '' del_btn.background_normal = ''
del_btn.background_color = (1, 0, 0, 1) del_btn.background_color = (1, 0, 0, 1)
del_btn.bind(on_press=partial( del_btn.bind(
on_press=partial(
self.delete, item['msgid'])) self.delete, item['msgid']))
carousel.add_widget(del_btn) carousel.add_widget(del_btn)
carousel.add_widget(meny) carousel.add_widget(meny)
ach_btn = Button(text='Achieve') ach_btn = Button(text='Achieve')
ach_btn.background_color = (0, 1, 0, 1) ach_btn.background_color = (0, 1, 0, 1)
ach_btn.bind(on_press=partial( ach_btn.bind(
on_press=partial(
self.archive, item['msgid'])) self.archive, item['msgid']))
carousel.add_widget(ach_btn) carousel.add_widget(ach_btn)
carousel.index = 1 carousel.index = 1
@ -192,7 +197,6 @@ 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', ' ')
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(
@ -202,7 +206,7 @@ class Inbox(Screen):
self.set_mdList(data) self.set_mdList(data)
def inbox_detail(self, msg_id, *args): def inbox_detail(self, msg_id, *args):
"""Load inbox page details.""" """Load inbox page details"""
state.detailPageType = 'inbox' state.detailPageType = 'inbox'
state.mail_id = msg_id state.mail_id = msg_id
if self.manager: if self.manager:
@ -214,7 +218,7 @@ class Inbox(Screen):
src_mng_obj.current = 'mailDetail' src_mng_obj.current = 'mailDetail'
def delete(self, data_index, instance, *args): def delete(self, data_index, instance, *args):
"""Delete inbox mail from inbox listing.""" """Delete inbox mail from inbox listing"""
sqlExecute( sqlExecute(
"UPDATE inbox SET folder = 'trash' WHERE msgid = ?;", str( "UPDATE inbox SET folder = 'trash' WHERE msgid = ?;", str(
data_index)) data_index))
@ -244,7 +248,7 @@ class Inbox(Screen):
self.update_trash() self.update_trash()
def archive(self, data_index, instance, *args): def archive(self, data_index, instance, *args):
"""Archive inbox mail from inbox listing.""" """Archive inbox mail from inbox listing"""
sqlExecute( sqlExecute(
"UPDATE inbox SET folder = 'trash' WHERE msgid = ?;", str( "UPDATE inbox SET folder = 'trash' WHERE msgid = ?;", str(
data_index)) data_index))
@ -252,7 +256,7 @@ class Inbox(Screen):
self.update_trash() self.update_trash()
def update_trash(self): def update_trash(self):
"""Update trash screen mails which is deleted from inbox.""" """Update trash screen mails which is deleted from inbox"""
try: try:
self.parent.screens[4].clear_widgets() self.parent.screens[4].clear_widgets()
self.parent.screens[4].add_widget(Trash()) self.parent.screens[4].add_widget(Trash())
@ -263,9 +267,9 @@ class Inbox(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, """Method updates the state of application,
While the spinner remains on the screen.""" While the spinner remains on the screen"""
def refresh_callback(interval): def refresh_callback(interval):
"""Method used for loading the inbox screen data.""" """Method used for loading the inbox screen data"""
state.searcing_text = '' state.searcing_text = ''
self.children[2].children[1].ids.search_field.text = '' self.children[2].children[1].ids.search_field.text = ''
self.ids.ml.clear_widgets() self.ids.ml.clear_widgets()
@ -282,17 +286,17 @@ class Inbox(Screen):
class MyAddress(Screen): class MyAddress(Screen):
"""MyAddress Screen uses screen to show widgets of screens.""" """MyAddress screen uses screen to show widgets of screens"""
addresses_list = ListProperty() addresses_list = ListProperty()
has_refreshed = True has_refreshed = True
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
"""Clock Schdule for method inbox accounts.""" """Clock schdule for method inbox accounts"""
super(MyAddress, self).__init__(*args, **kwargs) super(MyAddress, self).__init__(*args, **kwargs)
Clock.schedule_once(self.init_ui, 0) Clock.schedule_once(self.init_ui, 0)
def init_ui(self, dt=0): def init_ui(self, dt=0):
"""Clock Schdule for method inbox accounts.""" """Clock schdule for method inbox accounts"""
# pylint: disable=unnecessary-lambda, deprecated-lambda # pylint: disable=unnecessary-lambda, deprecated-lambda
self.addresses_list = state.kivyapp.variable_1 self.addresses_list = state.kivyapp.variable_1
if state.searcing_text: if state.searcing_text:
@ -324,7 +328,7 @@ class MyAddress(Screen):
pass pass
def set_mdList(self, first_index, last_index): def set_mdList(self, first_index, last_index):
"""This method is used to create the mdlist""" """Creating the mdlist"""
data = [] data = []
for address in self.addresses_list[first_index:last_index]: for address in self.addresses_list[first_index:last_index]:
data.append({ data.append({
@ -344,7 +348,7 @@ class MyAddress(Screen):
self.ids.ml.add_widget(meny) self.ids.ml.add_widget(meny)
def check_scroll_y(self, instance, somethingelse): def check_scroll_y(self, instance, somethingelse):
"""This method is used to load data on scroll""" """Load data on scroll down"""
if self.ids.refresh_layout.scroll_y <= -0.0 and self.has_refreshed: if self.ids.refresh_layout.scroll_y <= -0.0 and self.has_refreshed:
self.ids.refresh_layout.scroll_y = 0.06 self.ids.refresh_layout.scroll_y = 0.06
my_addresses = len(self.ids.ml.children) my_addresses = len(self.ids.ml.children)
@ -356,12 +360,12 @@ class MyAddress(Screen):
pass pass
def update_addressBook_on_scroll(self, my_addresses): def update_addressBook_on_scroll(self, my_addresses):
"""This method is used to load more data on scroll down""" """Loads more data on scroll down"""
self.set_mdList(my_addresses, my_addresses + 20) self.set_mdList(my_addresses, my_addresses + 20)
@staticmethod @staticmethod
def myadd_detail(fromaddress, label, *args): def myadd_detail(fromaddress, label, *args):
"""Myaddress Details.""" """Load myaddresses details"""
p = MyaddDetailPopup() p = MyaddDetailPopup()
p.open() p.open()
p.set_address(fromaddress, label) p.set_address(fromaddress, label)
@ -369,9 +373,9 @@ class MyAddress(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, """Method updates the state of application,
While the spinner remains on the screen.""" While the spinner remains on the screen"""
def refresh_callback(interval): def refresh_callback(interval):
"""Method used for loading the myaddress screen data.""" """Method used for loading the myaddress screen data"""
state.searcing_text = '' state.searcing_text = ''
state.kivyapp.root.ids.sc10.children[2].active = False state.kivyapp.root.ids.sc10.children[2].active = False
self.children[2].children[1].ids.search_field.text = '' self.children[2].children[1].ids.search_field.text = ''
@ -384,11 +388,11 @@ class MyAddress(Screen):
@staticmethod @staticmethod
def filter_address(address): def filter_address(address):
"""Method will filter the my address list data.""" """Method will filter the my address list data"""
# pylint: disable=deprecated-lambda # if filter(lambda x: (state.searcing_text).lower() in x, [
if filter(lambda x: (state.searcing_text).lower() in x, [ # BMConfigParser().get(
BMConfigParser().get( # address, 'label').lower(), address.lower()]):
address, 'label').lower(), address.lower()]): if [x for x in [BMConfigParser().get(address, 'label').lower(), address.lower()]]:
return True return True
return False return False
@ -398,22 +402,22 @@ class MyAddress(Screen):
class AddressBook(Screen): class AddressBook(Screen):
"""AddressBook Screen uses screen to show widgets of screens.""" """AddressBook Screen uses screen to show widgets of screens"""
queryreturn = ListProperty() queryreturn = ListProperty()
has_refreshed = True has_refreshed = True
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
"""Getting AddressBook Details.""" """Getting AddressBook Details"""
super(AddressBook, self).__init__(*args, **kwargs) super(AddressBook, self).__init__(*args, **kwargs)
Clock.schedule_once(self.init_ui, 0) Clock.schedule_once(self.init_ui, 0)
def init_ui(self, dt=0): def init_ui(self, dt=0):
"""Clock Schdule for method AddressBook.""" """Clock Schdule for method AddressBook"""
self.loadAddresslist(None, 'All', '') self.loadAddresslist(None, 'All', '')
print dt print dt
def loadAddresslist(self, account, where="", what=""): def loadAddresslist(self, account, where="", what=""):
"""Clock Schdule for method AddressBook.""" """Clock Schdule for method AddressBook"""
if state.searcing_text: if state.searcing_text:
self.ids.scroll_y.scroll_y = 1.0 self.ids.scroll_y.scroll_y = 1.0
where = ['label', 'address'] where = ['label', 'address']
@ -439,7 +443,7 @@ class AddressBook(Screen):
self.ids.ml.add_widget(content) self.ids.ml.add_widget(content)
def set_mdList(self, start_index, end_index): def set_mdList(self, start_index, end_index):
"""This method is used to create the mdList""" """Creating the mdList"""
for item in self.queryreturn[start_index:end_index]: for item in self.queryreturn[start_index:end_index]:
meny = TwoLineAvatarIconListItem( meny = TwoLineAvatarIconListItem(
text=item[0], text=item[0],
@ -467,7 +471,7 @@ class AddressBook(Screen):
self.ids.ml.add_widget(carousel) self.ids.ml.add_widget(carousel)
def check_scroll_y(self, instance, somethingelse): def check_scroll_y(self, instance, somethingelse):
"""This method is used to load data on scroll""" """Load data on scroll"""
if self.ids.scroll_y.scroll_y <= -0.0 and self.has_refreshed: if self.ids.scroll_y.scroll_y <= -0.0 and self.has_refreshed:
self.ids.scroll_y.scroll_y = 0.06 self.ids.scroll_y.scroll_y = 0.06
exist_addresses = len(self.ids.ml.children) exist_addresses = len(self.ids.ml.children)
@ -479,25 +483,25 @@ class AddressBook(Screen):
pass pass
def update_addressBook_on_scroll(self, exist_addresses): def update_addressBook_on_scroll(self, exist_addresses):
"""This method is used to load more data on scroll down""" """Load more data on scroll down"""
self.set_mdList(exist_addresses, exist_addresses + 5) self.set_mdList(exist_addresses, exist_addresses + 5)
@staticmethod @staticmethod
def refreshs(*args): def refreshs(*args):
"""Refresh the Widget.""" """Refresh the Widget"""
# state.navinstance.ids.sc11.ids.ml.clear_widgets() # state.navinstance.ids.sc11.ids.ml.clear_widgets()
# state.navinstance.ids.sc11.loadAddresslist(None, 'All', '') # state.navinstance.ids.sc11.loadAddresslist(None, 'All', '')
pass pass
@staticmethod @staticmethod
def addBook_detail(address, label, *args): def addBook_detail(address, label, *args):
"""Addressbook Details.""" """Addressbook details"""
p = AddbookDetailPopup() p = AddbookDetailPopup()
p.open() p.open()
p.set_addbook_data(address, label) p.set_addbook_data(address, label)
def delete_address(self, address, instance, *args): def delete_address(self, address, instance, *args):
"""Delete inbox mail from inbox listing.""" """Delete inbox mail from inbox listing"""
self.ids.ml.remove_widget(instance.parent.parent) self.ids.ml.remove_widget(instance.parent.parent)
sqlExecute( sqlExecute(
"DELETE FROM addressbook WHERE address = '{}';".format(address)) "DELETE FROM addressbook WHERE address = '{}';".format(address))
@ -505,34 +509,33 @@ class AddressBook(Screen):
class SelectableRecycleBoxLayout( class SelectableRecycleBoxLayout(
FocusBehavior, LayoutSelectionBehavior, RecycleBoxLayout): FocusBehavior, LayoutSelectionBehavior, RecycleBoxLayout):
"""Adds selection and focus behaviour to the view.""" """Adds selection and focus behaviour to the view"""
# pylint: disable = too-many-ancestors # pylint: disable = too-many-ancestors
pass pass
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)
def refresh_view_attrs(self, rv, index, data): def refresh_view_attrs(self, rv, index, data):
"""Catch and handle the view changes.""" """Catch and handle the view changes"""
self.index = index self.index = index
return super(SelectableLabel, self).refresh_view_attrs( return super(SelectableLabel, self).refresh_view_attrs(
rv, index, data) rv, index, data)
# pylint: disable=inconsistent-return-statements # pylint: disable=inconsistent-return-statements
def on_touch_down(self, touch): def on_touch_down(self, touch):
"""Add selection on touch down.""" """Add selection on touch down"""
if super(SelectableLabel, self).on_touch_down(touch): if super(SelectableLabel, self).on_touch_down(touch):
return True return True
if self.collide_point(*touch.pos) and self.selectable: if self.collide_point(*touch.pos) and self.selectable:
return self.parent.select_with_touch(self.index, touch) return self.parent.select_with_touch(self.index, touch)
def apply_selection(self, rv, index, is_selected): def apply_selection(self, rv, index, is_selected):
"""Respond to the selection of items in the view.""" """Respond to the selection of items in the view"""
self.selected = is_selected self.selected = is_selected
if is_selected: if is_selected:
print "selection changed to {0}".format(rv.data[index]) print "selection changed to {0}".format(rv.data[index])
@ -541,23 +544,22 @@ class SelectableLabel(RecycleDataViewBehavior, Label):
class RV(RecycleView): class RV(RecycleView):
"""Recycling View.""" """Recycling View"""
def __init__(self, **kwargs): def __init__(self, **kwargs): # pylint: disable=useless-super-delegation
"""Recycling Method.""" """Recycling Method"""
# pylint: disable=useless-super-delegation
super(RV, self).__init__(**kwargs) super(RV, self).__init__(**kwargs)
class DropDownWidget(BoxLayout): 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()
def send(self, navApp): def send(self, navApp):
"""Send message from one address to another.""" """Send message from one address to another"""
fromAddress = str(self.ids.ti.text) fromAddress = str(self.ids.ti.text)
toAddress = str(self.ids.txt_input.text) toAddress = str(self.ids.txt_input.text)
subject = self.ids.subject.text.encode('utf-8').strip() subject = self.ids.subject.text.encode('utf-8').strip()
@ -655,7 +657,7 @@ class DropDownWidget(BoxLayout):
# pylint: disable=attribute-defined-outside-init # pylint: disable=attribute-defined-outside-init
def address_error_message(self, msg): def address_error_message(self, msg):
"""Show Error Message.""" """Generates error message"""
msg_dialog = MDDialog( msg_dialog = MDDialog(
text=msg, text=msg,
title='', size_hint=(.8, .25), text_button_ok='Ok', title='', size_hint=(.8, .25), text_button_ok='Ok',
@ -664,11 +666,11 @@ class DropDownWidget(BoxLayout):
@staticmethod @staticmethod
def callback_for_menu_items(text_item): def callback_for_menu_items(text_item):
"""Method is used for getting the callback of alert box""" """Callback of alert box"""
toast(text_item) toast(text_item)
def reset_composer(self): def reset_composer(self):
"""Method will reset composer.""" """Method will reset composer"""
self.ids.ti.text = '' self.ids.ti.text = ''
self.ids.btn.text = 'Select' self.ids.btn.text = 'Select'
self.ids.txt_input.text = '' self.ids.txt_input.text = ''
@ -677,26 +679,25 @@ class DropDownWidget(BoxLayout):
toast("Reset message") toast("Reset message")
def auto_fill_fromaddr(self): def auto_fill_fromaddr(self):
"""Mehtod used to fill the text automatically From Address.""" """Fill the text automatically From Address"""
self.ids.ti.text = self.ids.btn.text self.ids.ti.text = self.ids.btn.text
self.ids.ti.focus = True self.ids.ti.focus = True
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()
starting_no = NumericProperty(3) starting_no = NumericProperty(3)
suggestion_text = '' suggestion_text = ''
def __init__(self, **kwargs): def __init__(self, **kwargs): # pylint: disable=useless-super-delegation
"""Getting Text Input.""" """Getting Text Input"""
# pylint: disable=useless-super-delegation
super(MyTextInput, self).__init__(**kwargs) super(MyTextInput, self).__init__(**kwargs)
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"""
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[
@ -711,7 +712,7 @@ class MyTextInput(TextInput):
self.parent.height = 400 self.parent.height = 400
def keyboard_on_key_down(self, window, keycode, text, modifiers): def keyboard_on_key_down(self, window, keycode, text, modifiers):
"""Key Down.""" """Key Down"""
if self.suggestion_text and keycode[1] == 'tab': if self.suggestion_text and keycode[1] == 'tab':
self.insert_text(self.suggestion_text + ' ') self.insert_text(self.suggestion_text + ' ')
return True return True
@ -720,11 +721,10 @@ class MyTextInput(TextInput):
class Payment(Screen): class Payment(Screen):
"""Payment Method.""" """Payment module"""
def get_available_credits(self, instance): def get_available_credits(self, instance): # pylint: disable=no-self-use
"""Method helps to get the available credits""" """Get the available credits"""
# pylint: disable=no-self-use
state.availabe_credit = instance.parent.children[1].text state.availabe_credit = instance.parent.children[1].text
existing_credits = ( existing_credits = (
state.kivyapp.root.ids.sc18.ids.ml.children[0].children[ state.kivyapp.root.ids.sc18.ids.ml.children[0].children[
@ -741,17 +741,17 @@ class Payment(Screen):
class Credits(Screen): class Credits(Screen):
"""Credits Method""" """Credits Module"""
available_credits = StringProperty('{0}'.format('0')) available_credits = StringProperty('{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(
@ -763,12 +763,12 @@ class NetworkStat(Screen):
'Processed {0} object to be synced'.format('0')) 'Processed {0} object to be synced'.format('0'))
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
"""Init method for network stat.""" """Init method for network stat"""
super(NetworkStat, self).__init__(*args, **kwargs) super(NetworkStat, self).__init__(*args, **kwargs)
Clock.schedule_interval(self.init_ui, 1) Clock.schedule_interval(self.init_ui, 1)
def init_ui(self, dt=0): def init_ui(self, dt=0):
"""Clock Schdule for method inbox accounts.""" """Clock Schdule for method inbox accounts"""
import network.stats import network.stats
import shared import shared
from network import objectracker from network import objectracker
@ -785,17 +785,17 @@ 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("")
def generateaddress(self, navApp): def generateaddress(self, navApp):
"""Method for Address Generator.""" """Method for Address Generator"""
entered_label = str(self.ids.label.text).strip() entered_label = str(self.ids.label.text).strip()
streamNumberForAddress = 1 streamNumberForAddress = 1
label = self.ids.label.text label = self.ids.label.text
@ -828,7 +828,7 @@ class Random(Screen):
toast('New address created') toast('New address created')
def add_validation(self, instance): def add_validation(self, instance):
"""Checking validation at address creation time.""" """Checking validation at address creation time"""
entered_label = str(instance.text.strip()) entered_label = str(instance.text.strip())
lables = [BMConfigParser().get(obj, 'label') lables = [BMConfigParser().get(obj, 'label')
for obj in BMConfigParser().addresses()] for obj in BMConfigParser().addresses()]
@ -846,12 +846,12 @@ class Random(Screen):
class Sent(Screen): class Sent(Screen):
"""Sent Screen uses screen to show widgets of screens.""" """Sent Screen uses screen to show widgets of screens"""
queryreturn = ListProperty() queryreturn = ListProperty()
has_refreshed = True has_refreshed = True
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
"""Association with the screen.""" """Association with the screen"""
super(Sent, self).__init__(*args, **kwargs) super(Sent, self).__init__(*args, **kwargs)
if state.association == '': if state.association == '':
if BMConfigParser().addresses(): if BMConfigParser().addresses():
@ -859,17 +859,17 @@ class Sent(Screen):
Clock.schedule_once(self.init_ui, 0) Clock.schedule_once(self.init_ui, 0)
def init_ui(self, dt=0): def init_ui(self, dt=0):
"""Clock Schdule for method sent accounts.""" """Clock Schdule for method sent accounts"""
self.sentaccounts() self.sentaccounts()
print dt print dt
def sentaccounts(self): def sentaccounts(self):
"""Load sent accounts.""" """Load sent accounts"""
account = state.association account = state.association
self.loadSent(account, 'All', '') self.loadSent(account, 'All', '')
def loadSent(self, account, where="", what=""): def loadSent(self, account, where="", what=""):
"""Load Sent list for Sent messages.""" """Load Sent list for Sent messages"""
if state.searcing_text: if state.searcing_text:
self.ids.scroll_y.scroll_y = 1.0 self.ids.scroll_y.scroll_y = 1.0
where = ['subject', 'message'] where = ['subject', 'message']
@ -967,7 +967,7 @@ class Sent(Screen):
self.set_mdlist(data, total_sent - 1) self.set_mdlist(data, total_sent - 1)
def check_scroll_y(self, instance, somethingelse): def check_scroll_y(self, instance, somethingelse):
"""This method is used to load data on scroll""" """Load data on scroll down"""
if self.ids.scroll_y.scroll_y <= -0.0 and self.has_refreshed: if self.ids.scroll_y.scroll_y <= -0.0 and self.has_refreshed:
self.ids.scroll_y.scroll_y = 0.06 self.ids.scroll_y.scroll_y = 0.06
total_sent_msg = len(self.ids.ml.children) total_sent_msg = len(self.ids.ml.children)
@ -979,7 +979,7 @@ class Sent(Screen):
pass pass
def update_sent_screen_on_scroll(self, total_sent_msg): def update_sent_screen_on_scroll(self, total_sent_msg):
"""This method is used to load more data on scroll down""" """Load more data on scroll down"""
data = [] data = []
for mail in self.queryreturn[total_sent_msg:total_sent_msg + 5]: for mail in self.queryreturn[total_sent_msg:total_sent_msg + 5]:
data.append({ data.append({
@ -998,7 +998,7 @@ class Sent(Screen):
state.sent_count = str(total_sent) state.sent_count = str(total_sent)
def sent_detail(self, ackdata, *args): def sent_detail(self, ackdata, *args):
"""Load sent mail details.""" """Load sent mail details"""
state.detailPageType = 'sent' state.detailPageType = 'sent'
state.mail_id = ackdata state.mail_id = ackdata
if self.manager: if self.manager:
@ -1010,7 +1010,7 @@ class Sent(Screen):
src_mng_obj.current = 'mailDetail' src_mng_obj.current = 'mailDetail'
def delete(self, data_index, instance, *args): def delete(self, data_index, instance, *args):
"""Delete sent mail from sent mail listing.""" """Delete sent mail from sent mail listing"""
try: try:
msg_count_objs = self.parent.parent.parent.parent.children[ msg_count_objs = self.parent.parent.parent.parent.children[
2].children[0].ids 2].children[0].ids
@ -1035,7 +1035,7 @@ class Sent(Screen):
self.update_trash() self.update_trash()
def archive(self, data_index, instance, *args): def archive(self, data_index, instance, *args):
"""Archive sent mail from sent mail listing.""" """Archive sent mail from sent mail listing"""
sqlExecute( sqlExecute(
"UPDATE sent SET folder = 'trash'" "UPDATE sent SET folder = 'trash'"
" WHERE ackdata = ?;", str(data_index)) " WHERE ackdata = ?;", str(data_index))
@ -1043,7 +1043,7 @@ class Sent(Screen):
self.update_trash() self.update_trash()
def update_trash(self): def update_trash(self):
"""Update trash screen mails which is deleted from inbox.""" """Update trash screen mails which is deleted from inbox"""
try: try:
self.parent.screens[4].clear_widgets() self.parent.screens[4].clear_widgets()
self.parent.screens[4].add_widget(Trash()) self.parent.screens[4].add_widget(Trash())
@ -1057,19 +1057,19 @@ class Sent(Screen):
class Trash(Screen): class Trash(Screen):
"""Trash Screen uses screen to show widgets of screens.""" """Trash Screen uses screen to show widgets of screens"""
trash_messages = ListProperty() trash_messages = ListProperty()
has_refreshed = True has_refreshed = True
delete_index = StringProperty() delete_index = StringProperty()
table_name = StringProperty() table_name = StringProperty()
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
"""Trash method, delete sent message and add in Trash.""" """Trash method, delete sent message and add in Trash"""
super(Trash, self).__init__(*args, **kwargs) super(Trash, self).__init__(*args, **kwargs)
Clock.schedule_once(self.init_ui, 0) Clock.schedule_once(self.init_ui, 0)
def init_ui(self, dt=0): def init_ui(self, dt=0):
"""Clock Schdule for method inbox accounts.""" """Clock Schdule for method inbox accounts"""
if state.association == '': if state.association == '':
if BMConfigParser().addresses(): if BMConfigParser().addresses():
state.association = BMConfigParser().addresses()[0] state.association = BMConfigParser().addresses()[0]
@ -1101,7 +1101,7 @@ class Trash(Screen):
self.ids.ml.add_widget(content) self.ids.ml.add_widget(content)
def set_mdList(self, first_index, last_index): def set_mdList(self, first_index, last_index):
"""This method is used to create the mdlist""" """Creating the mdlist"""
for item in self.trash_messages[first_index:last_index]: for item in self.trash_messages[first_index:last_index]:
meny = TwoLineAvatarIconListItem( meny = TwoLineAvatarIconListItem(
text=item[1], text=item[1],
@ -1131,7 +1131,7 @@ class Trash(Screen):
self.ids.ml.add_widget(carousel) self.ids.ml.add_widget(carousel)
def check_scroll_y(self, instance, somethingelse): def check_scroll_y(self, instance, somethingelse):
"""This method is used to load data on scroll""" """Load data on scroll"""
if self.ids.scroll_y.scroll_y <= -0.0 and self.has_refreshed: if self.ids.scroll_y.scroll_y <= -0.0 and self.has_refreshed:
self.ids.scroll_y.scroll_y = 0.06 self.ids.scroll_y.scroll_y = 0.06
total_trash_msg = len(self.ids.ml.children) total_trash_msg = len(self.ids.ml.children)
@ -1143,11 +1143,11 @@ class Trash(Screen):
pass pass
def update_trash_screen_on_scroll(self, total_trash_msg): def update_trash_screen_on_scroll(self, total_trash_msg):
"""This method is used to load more data on scroll down""" """Load more data on scroll down"""
self.set_mdList(total_trash_msg, total_trash_msg + 5) self.set_mdList(total_trash_msg, total_trash_msg + 5)
def delete_permanently(self, data_index, folder, instance, *args): def delete_permanently(self, data_index, folder, instance, *args):
"""Deleting trash mail permanently.""" """Deleting trash mail permanently"""
self.table_name = folder.split(',')[1] self.table_name = folder.split(',')[1]
self.delete_index = data_index self.delete_index = data_index
self.delete_confirmation() self.delete_confirmation()
@ -1160,7 +1160,7 @@ class Trash(Screen):
toast('Message is permanently deleted') toast('Message is permanently deleted')
def delete_confirmation(self): def delete_confirmation(self):
"""This method is used to show delete confirmation popup""" """Show confirmation delete popup"""
delete_msg_dialog = MDDialog( delete_msg_dialog = MDDialog(
text='Are you sure you want to delete this' / text='Are you sure you want to delete this' /
' message permanently from trash?', ' message permanently from trash?',
@ -1172,14 +1172,14 @@ class Trash(Screen):
delete_msg_dialog.open() delete_msg_dialog.open()
def callback_for_delete_msg(self, text_item): def callback_for_delete_msg(self, text_item):
"""Method is used for getting the callback of alert box""" """Getting the callback of alert box"""
if text_item == 'Yes': if text_item == 'Yes':
self.delete_message_from_trash() self.delete_message_from_trash()
else: else:
toast(text_item) toast(text_item)
def delete_message_from_trash(self): def delete_message_from_trash(self):
"""This method is used to delete """ """Deleting message from trash"""
self.children[1].active = True self.children[1].active = True
if self.table_name == 'inbox': if self.table_name == 'inbox':
sqlExecute("DELETE FROM inbox WHERE msgid = ?;", str( sqlExecute("DELETE FROM inbox WHERE msgid = ?;", str(
@ -1196,16 +1196,14 @@ class Trash(Screen):
class Page(Screen): class Page(Screen):
"""Page Screen show widgets of page.""" """Page Screen show widgets of page"""
pass pass
class Create(Screen): class Create(Screen):
"""Creates the screen widgets.""" """Creates the screen widgets"""
def __init__(self, **kwargs): def __init__(self, **kwargs):
"""Getting Labels and address from addressbook.""" """Getting Labels and address from addressbook"""
super(Create, self).__init__(**kwargs) super(Create, self).__init__(**kwargs)
widget_1 = DropDownWidget() widget_1 = DropDownWidget()
widget_1.ids.txt_input.word_list = [ widget_1.ids.txt_input.word_list = [
@ -1216,14 +1214,12 @@ class Create(Screen):
class Setting(Screen): class Setting(Screen):
"""Setting the Screen components.""" """Setting the Screen components"""
pass pass
class NavigateApp(App): class NavigateApp(App): # pylint: disable=too-many-public-methods
"""Navigation Layout of class.""" """Navigation Layout of class"""
# pylint: disable=too-many-public-methods
theme_cls = ThemeManager() theme_cls = ThemeManager()
previous_date = ObjectProperty() previous_date = ObjectProperty()
obj_1 = ObjectProperty() obj_1 = ObjectProperty()
@ -1252,7 +1248,7 @@ class NavigateApp(App):
] ]
def build(self): def build(self):
"""Method builds the widget.""" """Method builds the widget"""
main_widget = Builder.load_file( main_widget = Builder.load_file(
os.path.join(os.path.dirname(__file__), 'main.kv')) os.path.join(os.path.dirname(__file__), 'main.kv'))
self.nav_drawer = Navigatorss() self.nav_drawer = Navigatorss()
@ -1264,14 +1260,14 @@ class NavigateApp(App):
return main_widget return main_widget
def run(self): def run(self):
"""Running the widgets.""" """Running the widgets"""
kivyuisignaler.release() kivyuisignaler.release()
super(NavigateApp, self).run() super(NavigateApp, self).run()
# pylint: disable=inconsistent-return-statements # pylint: disable=inconsistent-return-statements
@staticmethod @staticmethod
def showmeaddresses(name="text"): def showmeaddresses(name="text"):
"""Show the addresses in spinner to make as dropdown.""" """Show the addresses in spinner to make as dropdown"""
if name == "text": if name == "text":
if BMConfigParser().addresses(): if BMConfigParser().addresses():
return BMConfigParser().addresses()[0][:16] + '..' return BMConfigParser().addresses()[0][:16] + '..'
@ -1283,7 +1279,7 @@ class NavigateApp(App):
return "valuesdemo" return "valuesdemo"
def getCurrentAccountData(self, text): def getCurrentAccountData(self, text):
"""Get Current Address Account Data.""" """Get Current Address Account Data"""
self.set_identicon(text) self.set_identicon(text)
address_label = self.current_address_label( address_label = self.current_address_label(
BMConfigParser().get(text, 'label'), text) BMConfigParser().get(text, 'label'), text)
@ -1338,19 +1334,19 @@ class NavigateApp(App):
@staticmethod @staticmethod
def getCurrentAccount(): def getCurrentAccount():
"""It uses to get current account label.""" """It uses to get current account label"""
if state.association: if state.association:
return state.association return state.association
return "Bitmessage Login" return "Bitmessage Login"
@staticmethod @staticmethod
def addingtoaddressbook(): def addingtoaddressbook():
"""Adding to address Book.""" """Adding to address Book"""
p = GrashofPopup() p = GrashofPopup()
p.open() p.open()
def getDefaultAccData(self): def getDefaultAccData(self):
"""Getting Default Account Data.""" """Getting Default Account Data"""
if BMConfigParser().addresses(): if BMConfigParser().addresses():
img = identiconGeneration.generate(BMConfigParser().addresses()[0]) img = identiconGeneration.generate(BMConfigParser().addresses()[0])
self.createFolder('./images/default_identicon/') self.createFolder('./images/default_identicon/')
@ -1370,7 +1366,7 @@ class NavigateApp(App):
@staticmethod @staticmethod
def createFolder(directory): def createFolder(directory):
"""This method is used to create the directory when app starts""" """Create directory when app starts"""
try: try:
if not os.path.exists(directory): if not os.path.exists(directory):
os.makedirs(directory) os.makedirs(directory)
@ -1387,13 +1383,13 @@ class NavigateApp(App):
@staticmethod @staticmethod
def addressexist(): def addressexist():
"""Checking address existence.""" """Checking address existence"""
if BMConfigParser().addresses(): if BMConfigParser().addresses():
return True return True
return False return False
def on_key(self, window, key, *args): def on_key(self, window, key, *args):
"""Method is used for going on previous screen.""" """Method is used for going on previous screen"""
if key == 27: if key == 27:
if state.in_search_mode and self.root.ids.scr_mngr.current != ( if state.in_search_mode and self.root.ids.scr_mngr.current != (
"mailDetail"): "mailDetail"):
@ -1432,7 +1428,7 @@ class NavigateApp(App):
Clock.schedule_once(self.search_callback, 0.5) Clock.schedule_once(self.search_callback, 0.5)
def search_callback(self, dt=0): def search_callback(self, dt=0):
"""This method is used to show data after loader is loaded""" """Show data after loader is loaded"""
if state.search_screen == 'inbox': if state.search_screen == 'inbox':
self.root.ids.sc1.ids.ml.clear_widgets() self.root.ids.sc1.ids.ml.clear_widgets()
self.root.ids.sc1.loadMessagelist(state.association) self.root.ids.sc1.loadMessagelist(state.association)
@ -1462,19 +1458,19 @@ class NavigateApp(App):
return return
def reset(self, *args): def reset(self, *args):
"""Method used to set transition direction.""" """Set transition direction"""
self.root.ids.scr_mngr.transition.direction = 'left' self.root.ids.scr_mngr.transition.direction = 'left'
self.root.ids.scr_mngr.transition.unbind(on_complete=self.reset) self.root.ids.scr_mngr.transition.unbind(on_complete=self.reset)
@staticmethod @staticmethod
def status_dispatching(data): def status_dispatching(data):
"""Method used for status dispatching acknowledgment.""" """Dispatching Status acknowledgment"""
ackData, message = data ackData, message = data
if state.ackdata == ackData: if state.ackdata == ackData:
state.status.status = message state.status.status = message
def clear_composer(self): def clear_composer(self):
"""If slow down the nwe will make new composer edit screen.""" """If slow down, the new composer edit screen"""
self.set_navbar_for_composer() self.set_navbar_for_composer()
composer_obj = self.root.ids.sc3.children[1].ids composer_obj = self.root.ids.sc3.children[1].ids
composer_obj.ti.text = '' composer_obj.ti.text = ''
@ -1486,7 +1482,7 @@ class NavigateApp(App):
state.in_sent_method = False state.in_sent_method = False
def set_navbar_for_composer(self): def set_navbar_for_composer(self):
"""This method is used for clearing toolbar data when composer open""" """Clearing toolbar data when composer open"""
self.root.ids.toolbar.left_action_items = [ self.root.ids.toolbar.left_action_items = [
['arrow-left', lambda x: self.back_press()]] ['arrow-left', lambda x: self.back_press()]]
self.root.ids.toolbar.right_action_items = [ self.root.ids.toolbar.right_action_items = [
@ -1496,7 +1492,7 @@ class NavigateApp(App):
lambda x: self.root.ids.sc3.children[1].send(self)]] lambda x: self.root.ids.sc3.children[1].send(self)]]
def set_common_header(self): def set_common_header(self):
"""Common for all window""" """Common header for all window"""
self.root.ids.toolbar.right_action_items = [ self.root.ids.toolbar.right_action_items = [
['account-plus', lambda x: self.addingtoaddressbook()]] ['account-plus', lambda x: self.addingtoaddressbook()]]
self.root.ids.toolbar.left_action_items = [ self.root.ids.toolbar.left_action_items = [
@ -1504,10 +1500,10 @@ class NavigateApp(App):
return return
def back_press(self): def back_press(self):
"""Method used for going back from composer to previous page.""" """Method for, reverting composer to previous page"""
self.save_draft() self.save_draft()
if self.root.ids.scr_mngr.current == 'mailDetail' \ if self.root.ids.scr_mngr.current == \
and state.in_search_mode: '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()]]
@ -1528,14 +1524,14 @@ class NavigateApp(App):
@staticmethod @staticmethod
def on_stop(): def on_stop():
"""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()
@staticmethod @staticmethod
def current_address_label(current_add_label=None, current_addr=None): def current_address_label(current_add_label=None, current_addr=None):
"""Getting current address labels.""" """Getting current address labels"""
if BMConfigParser().addresses(): if BMConfigParser().addresses():
if current_add_label: if current_add_label:
first_name = current_add_label first_name = current_add_label
@ -1551,7 +1547,7 @@ class NavigateApp(App):
return '' return ''
def searchQuery(self, instance): def searchQuery(self, instance):
"""Method used for showing searched mails.""" """Showing searched mails"""
state.search_screen = self.root.ids.scr_mngr.current state.search_screen = self.root.ids.scr_mngr.current
state.searcing_text = str(instance.text).strip() state.searcing_text = str(instance.text).strip()
if instance.focus and state.searcing_text: if instance.focus and state.searcing_text:
@ -1574,7 +1570,7 @@ class NavigateApp(App):
state.in_search_mode = False state.in_search_mode = False
def refreshScreen(self): # pylint: disable=unused-variable 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:
@ -1608,13 +1604,13 @@ class NavigateApp(App):
return return
def set_identicon(self, text): def set_identicon(self, text):
"""This method is use for showing identicon in address spinner""" """Show identicon in address spinner"""
img = identiconGeneration.generate(text) img = identiconGeneration.generate(text)
self.root.children[2].children[0].ids.btn.children[1].texture = ( self.root.children[2].children[0].ids.btn.children[1].texture = (
img.texture) img.texture)
def set_mail_detail_header(self): def set_mail_detail_header(self):
"""Method is used for setting the details of the page""" """Setting the details of the page"""
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.back_press()]] ['arrow-left', lambda x: self.back_press()]]
@ -1649,15 +1645,14 @@ class NavigateApp(App):
class GrashofPopup(Popup): class GrashofPopup(Popup):
"""Methods for saving contacts, error messages.""" """Moule for save contacts and error messages"""
def __init__(self, **kwargs): def __init__(self, **kwargs): # pylint: disable=useless-super-delegation
"""Grash of pop screen settings.""" """Grash of pop screen settings"""
# pylint: disable=useless-super-delegation
super(GrashofPopup, self).__init__(**kwargs) super(GrashofPopup, self).__init__(**kwargs)
def savecontact(self): def savecontact(self):
"""Method is used for Saving Contacts.""" """Method is used for saving contacts"""
label = self.ids.label.text.strip() label = self.ids.label.text.strip()
address = self.ids.address.text.strip() address = self.ids.address.text.strip()
if label == '' and address == '': if label == '' and address == '':
@ -1685,7 +1680,7 @@ class GrashofPopup(Popup):
# pylint: disable=attribute-defined-outside-init # pylint: disable=attribute-defined-outside-init
def show_error_message(self): def show_error_message(self):
"""Showing error message.""" """Showing error message"""
content = MDLabel( content = MDLabel(
font_style='Body1', font_style='Body1',
theme_text_color='Secondary', theme_text_color='Secondary',
@ -1705,7 +1700,7 @@ class GrashofPopup(Popup):
@staticmethod @staticmethod
def close_pop(): def close_pop():
"""Pop is Canceled.""" """Pop is Canceled"""
toast('Canceled') toast('Canceled')
def checkAddress_valid(self, instance): def checkAddress_valid(self, instance):
@ -1730,7 +1725,7 @@ class GrashofPopup(Popup):
self.ids.address.helper_text = 'This field is required' self.ids.address.helper_text = 'This field is required'
def checkLabel_valid(self, instance): def checkLabel_valid(self, instance):
"""Checking address label is unique of not""" """Checking address label is unique or not"""
entered_label = instance.text.strip() entered_label = instance.text.strip()
addr_labels = [labels[0] for labels in kivy_helper_search.search_sql( addr_labels = [labels[0] for labels in kivy_helper_search.search_sql(
folder="addressbook")] folder="addressbook")]
@ -1745,36 +1740,36 @@ 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):
"""Method for Navigation Drawer.""" """Method for Navigation Drawer"""
super(NavigationDrawerTwoLineListItem, self).__init__(**kwargs) super(NavigationDrawerTwoLineListItem, self).__init__(**kwargs)
Clock.schedule_once(lambda dt: self.setup()) Clock.schedule_once(lambda dt: self.setup())
def setup(self): def setup(self):
"""Bind Controller.current_account property.""" """Bind Controller.current_account property"""
pass pass
def on_current_account(self, account): def on_current_account(self, account):
"""Account detail.""" """Account detail"""
pass pass
def _update_specific_text_color(self, instance, value): def _update_specific_text_color(self, instance, value):
@ -1785,7 +1780,7 @@ 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()
@ -1794,12 +1789,12 @@ class MailDetail(Screen):
page_type = StringProperty() page_type = StringProperty()
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
"""Mail Details method.""" """Mail Details method"""
super(MailDetail, self).__init__(*args, **kwargs) super(MailDetail, self).__init__(*args, **kwargs)
Clock.schedule_once(self.init_ui, 0) Clock.schedule_once(self.init_ui, 0)
def init_ui(self, dt=0): def init_ui(self, dt=0):
"""Clock Schdule for method MailDetail mails.""" """Clock Schdule for method MailDetail mails"""
self.page_type = state.detailPageType if state.detailPageType else '' self.page_type = state.detailPageType if state.detailPageType else ''
if state.detailPageType == 'sent' or state.detailPageType == 'draft': if state.detailPageType == 'sent' or state.detailPageType == 'draft':
data = sqlQuery( data = sqlQuery(
@ -1817,7 +1812,7 @@ class MailDetail(Screen):
state.kivyapp.set_mail_detail_header() state.kivyapp.set_mail_detail_header()
def assign_mail_details(self, data): def assign_mail_details(self, data):
"""Assigning mail details.""" """Assigning mail details"""
self.to_addr = data[0][0] self.to_addr = data[0][0]
self.from_addr = data[0][1] self.from_addr = data[0][1]
self.subject = data[0][2].upper( self.subject = data[0][2].upper(
@ -1831,7 +1826,7 @@ class MailDetail(Screen):
'message': self.message} 'message': self.message}
def delete_mail(self): def delete_mail(self):
"""Method for mail delete.""" """Method for mail delete"""
msg_count_objs = state.kivyapp.root.children[2].children[0].ids msg_count_objs = state.kivyapp.root.children[2].children[0].ids
state.searcing_text = '' state.searcing_text = ''
self.children[0].children[0].active = True self.children[0].children[0].active = True
@ -1893,7 +1888,7 @@ class MailDetail(Screen):
toast('Deleted') toast('Deleted')
def inbox_reply(self): def inbox_reply(self):
"""Method used for replying inbox messages.""" """Reply inbox messages"""
data = sqlQuery( data = sqlQuery(
"select toaddress, fromaddress, subject, message from inbox where" "select toaddress, fromaddress, subject, message from inbox where"
" msgid = ?;", str(state.mail_id)) " msgid = ?;", str(state.mail_id))
@ -1908,7 +1903,7 @@ class MailDetail(Screen):
state.kivyapp.set_navbar_for_composer() state.kivyapp.set_navbar_for_composer()
def write_msg(self, navApp): def write_msg(self, navApp):
"""Method used to write on draft mail.""" """Write on draft mail"""
state.send_draft_mail = state.mail_id state.send_draft_mail = state.mail_id
composer_ids = ( composer_ids = (
self.parent.parent.parent.parent.parent.ids.sc3.children[1].ids) self.parent.parent.parent.parent.parent.ids.sc3.children[1].ids)
@ -1923,7 +1918,7 @@ class MailDetail(Screen):
@staticmethod @staticmethod
def copy_composer_text(instance, *args): def copy_composer_text(instance, *args):
"""This method is used for copying the data from mail detail page""" """Copy the data from mail detail page"""
if len(instance.parent.text.split(':')) > 1: if len(instance.parent.text.split(':')) > 1:
cpy_text = instance.parent.text.split(':')[1].strip() cpy_text = instance.parent.text.split(':')[1].strip()
else: else:
@ -1933,22 +1928,21 @@ 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()
def __init__(self, **kwargs): def __init__(self, **kwargs): # pylint: disable=useless-super-delegation
"""My Address Details screen setting.""" """My Address Details screen setting"""
# pylint: disable=useless-super-delegation
super(MyaddDetailPopup, self).__init__(**kwargs) super(MyaddDetailPopup, self).__init__(**kwargs)
def set_address(self, address, label): def set_address(self, address, label):
"""Getting address for displaying details on popup.""" """Getting address for displaying details on popup"""
self.address_label = label self.address_label = label
self.address = address self.address = address
def send_message_from(self): def send_message_from(self):
"""Method used to fill from address of composer autofield.""" """Method used to fill from address of composer autofield"""
state.kivyapp.set_navbar_for_composer() state.kivyapp.set_navbar_for_composer()
window_obj = self.parent.children[1].ids window_obj = self.parent.children[1].ids
window_obj.sc3.children[1].ids.ti.text = self.address window_obj.sc3.children[1].ids.ti.text = self.address
@ -1961,27 +1955,27 @@ class MyaddDetailPopup(Popup):
@staticmethod @staticmethod
def close_pop(): def close_pop():
"""Pop is Canceled.""" """Pop is Canceled"""
toast('Canceled') toast('Canceled')
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()
def __init__(self, **kwargs): def __init__(self, **kwargs):
"""Method used set screen of address detail page.""" """Set screen of address detail page"""
# pylint: disable=useless-super-delegation # pylint: disable=useless-super-delegation
super(AddbookDetailPopup, self).__init__(**kwargs) super(AddbookDetailPopup, self).__init__(**kwargs)
def set_addbook_data(self, address, label): def set_addbook_data(self, address, label):
"""Getting address book data for detial dipaly.""" """Getting address book data for detial dipaly"""
self.address_label = label self.address_label = label
self.address = address self.address = address
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"""
address_list = kivy_helper_search.search_sql(folder="addressbook") address_list = kivy_helper_search.search_sql(folder="addressbook")
stored_labels = [labels[0] for labels in address_list] stored_labels = [labels[0] for labels in address_list]
add_dict = dict(address_list) add_dict = dict(address_list)
@ -1999,7 +1993,7 @@ class AddbookDetailPopup(Popup):
toast('Saved') toast('Saved')
def send_message_to(self): def send_message_to(self):
"""Method used to fill to_address of composer autofield.""" """Method used to fill to_address of composer autofield"""
state.kivyapp.set_navbar_for_composer() state.kivyapp.set_navbar_for_composer()
window_obj = self.parent.children[1].ids window_obj = self.parent.children[1].ids
window_obj.sc3.children[1].ids.txt_input.text = self.address window_obj.sc3.children[1].ids.txt_input.text = self.address
@ -2012,7 +2006,7 @@ class AddbookDetailPopup(Popup):
@staticmethod @staticmethod
def close_pop(): def close_pop():
"""Pop is Canceled.""" """Pop is Canceled"""
toast('Canceled') toast('Canceled')
def checkLabel_valid(self, instance): def checkLabel_valid(self, instance):
@ -2033,10 +2027,10 @@ class AddbookDetailPopup(Popup):
class ShowQRCode(Screen): class ShowQRCode(Screen):
"""ShowQRCode Screen uses to show the detail of mails.""" """ShowQRCode Screen uses to show the detail of mails"""
def qrdisplay(self): def qrdisplay(self):
"""Method used for showing QR Code.""" """Showing QR Code"""
# self.manager.parent.parent.parent.ids.search_bar.clear_widgets() # self.manager.parent.parent.parent.ids.search_bar.clear_widgets()
self.ids.qr.clear_widgets() self.ids.qr.clear_widgets()
from kivy.garden.qrcode import QRCodeWidget from kivy.garden.qrcode import QRCodeWidget
@ -2046,13 +2040,13 @@ 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
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
"""Method used for storing draft messages.""" """Method used for storing draft messages"""
super(Draft, self).__init__(*args, **kwargs) super(Draft, self).__init__(*args, **kwargs)
if state.association == '': if state.association == '':
if BMConfigParser().addresses(): if BMConfigParser().addresses():
@ -2060,17 +2054,17 @@ class Draft(Screen):
Clock.schedule_once(self.init_ui, 0) Clock.schedule_once(self.init_ui, 0)
def init_ui(self, dt=0): def init_ui(self, dt=0):
"""Clock Schdule for method draft accounts.""" """Clock Schdule for method draft accounts"""
self.sentaccounts() self.sentaccounts()
print dt print dt
def sentaccounts(self): def sentaccounts(self):
"""Load draft accounts.""" """Load draft accounts"""
account = state.association account = state.association
self.loadDraft(account, 'All', '') self.loadDraft(account, 'All', '')
def loadDraft(self, account, where="", what=""): def loadDraft(self, account, where="", what=""):
"""Load draft list for Draft messages.""" """Load draft list for Draft messages"""
xAddress = 'fromaddress' xAddress = 'fromaddress'
self.queryreturn = kivy_helper_search.search_sql( self.queryreturn = kivy_helper_search.search_sql(
xAddress, account, "draft", where, what, False) xAddress, account, "draft", where, what, False)
@ -2095,7 +2089,7 @@ class Draft(Screen):
self.ids.ml.add_widget(content) self.ids.ml.add_widget(content)
def set_mdList(self, first_index, last_index): def set_mdList(self, first_index, last_index):
"""This method is used to create mdlist""" """Create mdlist"""
data = [] data = []
for mail in self.queryreturn[first_index:last_index]: for mail in self.queryreturn[first_index:last_index]:
third_text = mail[3].replace('\n', ' ') third_text = mail[3].replace('\n', ' ')
@ -2133,7 +2127,7 @@ class Draft(Screen):
self.ids.ml.add_widget(carousel) self.ids.ml.add_widget(carousel)
def check_scroll_y(self, instance, somethingelse): def check_scroll_y(self, instance, somethingelse):
"""This method is used to load data on scroll""" """Load data on scroll"""
if self.ids.scroll_y.scroll_y <= -0.0 and self.has_refreshed: if self.ids.scroll_y.scroll_y <= -0.0 and self.has_refreshed:
self.ids.scroll_y.scroll_y = 0.06 self.ids.scroll_y.scroll_y = 0.06
total_draft_msg = len(self.ids.ml.children) total_draft_msg = len(self.ids.ml.children)
@ -2145,11 +2139,11 @@ class Draft(Screen):
pass pass
def update_draft_screen_on_scroll(self, total_draft_msg): def update_draft_screen_on_scroll(self, total_draft_msg):
"""This method is used to load more data on scroll down""" """Load more data on scroll down"""
self.set_mdList(total_draft_msg, total_draft_msg + 5) self.set_mdList(total_draft_msg, total_draft_msg + 5)
def draft_detail(self, ackdata, *args): def draft_detail(self, ackdata, *args):
"""Method used to show draft Details.""" """Show draft Details"""
state.detailPageType = 'draft' state.detailPageType = 'draft'
state.mail_id = ackdata state.mail_id = ackdata
if self.manager: if self.manager:
@ -2161,7 +2155,7 @@ class Draft(Screen):
src_mng_obj.current = 'mailDetail' src_mng_obj.current = 'mailDetail'
def delete_draft(self, data_index, instance, *args): def delete_draft(self, data_index, instance, *args):
"""Method used to delete draft message permanently.""" """Delete draft message permanently"""
sqlExecute("DELETE FROM sent WHERE ackdata = ?;", str( sqlExecute("DELETE FROM sent WHERE ackdata = ?;", str(
data_index)) data_index))
try: try:
@ -2178,9 +2172,8 @@ class Draft(Screen):
toast('Deleted') toast('Deleted')
@staticmethod @staticmethod
def draft_msg(src_object): def draft_msg(src_object): # pylint: disable=too-many-locals
"""Method used for saving draft mails.""" """Save draft mails"""
# pylint: disable=too-many-locals
composer_object = state.kivyapp.root.ids.sc3.children[1].ids composer_object = state.kivyapp.root.ids.sc3.children[1].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)
@ -2225,22 +2218,22 @@ class Draft(Screen):
class CustomSpinner(Spinner): class CustomSpinner(Spinner):
"""This class is used for setting spinner size.""" """This class is used for setting spinner size"""
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
"""Method used for setting size of spinner.""" """Setting size of spinner"""
super(CustomSpinner, self).__init__(*args, **kwargs) super(CustomSpinner, self).__init__(*args, **kwargs)
self.dropdown_cls.max_height = Window.size[1] / 3 self.dropdown_cls.max_height = Window.size[1] / 3
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()
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
"""Method Parsing the address.""" """Method Parsing the address"""
super(Allmails, self).__init__(*args, **kwargs) super(Allmails, self).__init__(*args, **kwargs)
if state.association == '': if state.association == '':
if BMConfigParser().addresses(): if BMConfigParser().addresses():
@ -2248,17 +2241,17 @@ class Allmails(Screen):
Clock.schedule_once(self.init_ui, 0) Clock.schedule_once(self.init_ui, 0)
def init_ui(self, dt=0): def init_ui(self, dt=0):
"""Clock Schdule for method all mails.""" """Clock Schdule for method all mails"""
self.mailaccounts() self.mailaccounts()
print dt print dt
def mailaccounts(self): def mailaccounts(self):
"""Load all mails for account.""" """Load all mails for account"""
account = state.association account = state.association
self.loadMessagelist(account, 'All', '') self.loadMessagelist(account, 'All', '')
def loadMessagelist(self, account, where="", what=""): def loadMessagelist(self, account, where="", what=""):
"""Load Inbox, Sent anf Draft list of messages.""" """Load Inbox, Sent anf Draft list of messages"""
self.all_mails = sqlQuery( self.all_mails = sqlQuery(
"SELECT toaddress, fromaddress, subject, message, folder, ackdata" "SELECT toaddress, fromaddress, subject, message, folder, ackdata"
" As id, DATE(lastactiontime) As actionTime FROM sent WHERE" " As id, DATE(lastactiontime) As actionTime FROM sent WHERE"
@ -2286,7 +2279,7 @@ class Allmails(Screen):
self.ids.ml.add_widget(content) self.ids.ml.add_widget(content)
def set_mdlist(self, start_pnt, end_pnt): def set_mdlist(self, start_pnt, end_pnt):
"""This method is used to create mdList for allmaills""" """Create mdList for allmaills"""
for item in self.all_mails[start_pnt:end_pnt]: for item in self.all_mails[start_pnt:end_pnt]:
meny = TwoLineAvatarIconListItem( meny = TwoLineAvatarIconListItem(
text=item[1], text=item[1],
@ -2318,7 +2311,7 @@ class Allmails(Screen):
self.ids.ml.add_widget(carousel) self.ids.ml.add_widget(carousel)
def check_scroll_y(self, instance, somethingelse): def check_scroll_y(self, instance, somethingelse):
"""This method is used for scrolling on fixing length""" """Scroll fixed length"""
if self.ids.refresh_layout.scroll_y <= -0.00 and self.has_refreshed: if self.ids.refresh_layout.scroll_y <= -0.00 and self.has_refreshed:
self.ids.refresh_layout.scroll_y = .06 self.ids.refresh_layout.scroll_y = .06
load_more = len(self.ids.ml.children) load_more = len(self.ids.ml.children)
@ -2327,8 +2320,7 @@ class Allmails(Screen):
pass pass
def updating_allmail(self, load_more): def updating_allmail(self, load_more):
"""This method is used to update the all mail """Update the all mail listing value on the scroll of screen"""
listing value on the scroll of screen"""
if self.all_mails and load_more != len(self.all_mails): if self.all_mails and load_more != len(self.all_mails):
state.all_count = str(len(self.all_mails)) state.all_count = str(len(self.all_mails))
self.set_mdlist(load_more, load_more + 5) self.set_mdlist(load_more, load_more + 5)
@ -2336,7 +2328,7 @@ class Allmails(Screen):
self.all_mails) else False self.all_mails) else False
def mail_detail(self, unique_id, folder, *args): def mail_detail(self, unique_id, folder, *args):
"""Load sent and inbox mail details.""" """Load sent and inbox mail details"""
state.detailPageType = folder state.detailPageType = folder
state.is_allmail = True state.is_allmail = True
state.mail_id = unique_id state.mail_id = unique_id
@ -2349,7 +2341,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.""" """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(
@ -2393,9 +2385,9 @@ 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, """Method updates the state of application,
While the spinner remains on the screen.""" While the spinner remains on the screen"""
def refresh_callback(interval): def refresh_callback(interval):
"""Method used for loading the allmails screen data.""" """Load the allmails screen data"""
self.ids.ml.clear_widgets() self.ids.ml.clear_widgets()
self.remove_widget(self.children[1]) self.remove_widget(self.children[1])
try: try:
@ -2427,17 +2419,17 @@ def avatarImageFirstLetter(letter_string):
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