From 17447683fee8ec0d265bb4b0af2c8bca989c5ead Mon Sep 17 00:00:00 2001 From: navjot Date: Mon, 31 May 2021 13:24:40 +0530 Subject: [PATCH] fixed pylint CQ issues --- src/bitmessagekivy/baseclass/addressbook.py | 1 + src/bitmessagekivy/baseclass/common.py | 50 +++--- src/bitmessagekivy/baseclass/login.py | 2 +- src/bitmessagekivy/baseclass/msg_composer.py | 176 +++++++++---------- src/bitmessagekivy/baseclass/myaddress.py | 6 +- src/bitmessagekivy/baseclass/network.py | 6 +- src/bitmessagekivy/baseclass/payment.py | 4 +- src/bitmessagekivy/baseclass/popup.py | 2 - src/bitmessagekivy/baseclass/trash.py | 8 +- src/bitmessagekivy/mpybit.py | 6 +- 10 files changed, 126 insertions(+), 135 deletions(-) diff --git a/src/bitmessagekivy/baseclass/addressbook.py b/src/bitmessagekivy/baseclass/addressbook.py index bb6672d2..0b476d8d 100644 --- a/src/bitmessagekivy/baseclass/addressbook.py +++ b/src/bitmessagekivy/baseclass/addressbook.py @@ -32,6 +32,7 @@ class AddressBook(Screen): def __init__(self, *args, **kwargs): """Getting AddressBook Details""" super(AddressBook, self).__init__(*args, **kwargs) + self.addbook_popup = None Clock.schedule_once(self.init_ui, 0) def init_ui(self, dt=0): diff --git a/src/bitmessagekivy/baseclass/common.py b/src/bitmessagekivy/baseclass/common.py index 857ba09a..70b750fd 100644 --- a/src/bitmessagekivy/baseclass/common.py +++ b/src/bitmessagekivy/baseclass/common.py @@ -1,4 +1,3 @@ -import os from datetime import datetime from kivy.core.window import Window from kivy.lang import Builder @@ -10,6 +9,7 @@ from kivymd.uix.list import ( from kivy.uix.image import Image from kivymd.uix.label import MDLabel from bitmessagekivy.get_platform import platform +from kivymd.toast import kivytoast from kivymd.uix.card import MDCardSwipe from kivymd.uix.chip import MDChip from kivy.properties import ( @@ -49,34 +49,29 @@ def chipTag(text): return obj -def initailize_detail_page(manager): - if not manager.has_screen( - data_screens['MailDetail']["name_screen"] - ): - Builder.load_file( - os.path.join( - # os.environ["KITCHEN_SINK_ROOT"], - os.path.dirname(os.path.dirname(__file__)), - "kv", - "maildetail.kv", - ) - ) - if "Import" in data_screens['MailDetail']: - exec(data_screens['MailDetail']["Import"]) - screen_object = eval(data_screens['MailDetail']["Factory"]) - data_screens['MailDetail']["object"] = screen_object - manager.add_widget(screen_object) - manager.current = data_screens['MailDetail']["name_screen"] +# def initailize_detail_page(manager): +# if not manager.has_screen( +# data_screens['MailDetail']["name_screen"] +# ): +# Builder.load_file( +# os.path.join( +# # os.environ["KITCHEN_SINK_ROOT"], +# os.path.dirname(os.path.dirname(__file__)), +# "kv", +# "maildetail.kv", +# ) +# ) +# if "Import" in data_screens['MailDetail']: +# exec(data_screens['MailDetail']["Import"]) +# screen_object = eval(data_screens['MailDetail']["Factory"]) +# data_screens['MailDetail']["object"] = screen_object +# manager.add_widget(screen_object) +# manager.current = data_screens['MailDetail']["name_screen"] def toast(text): """Method will display the toast message""" - # pylint: disable=redefined-outer-name - from kivymd.toast.kivytoast import toast - - toast(text) - return None - + kivytoast.toast(text) def showLimitedCnt(total_msg): """This method set the total count limit in badge_text""" @@ -97,7 +92,7 @@ def avatarImageFirstLetter(letter_string): return img_latter if img_latter else '!' -def AddTimeWidget(time): # pylint: disable=redefined-outer-name +def AddTimeWidget(time): # pylint: disable=redefined-outer-name, W0201 """This method is used to create TimeWidget""" action_time = TimeTagRightSampleWidget( text=str(ShowTimeHistoy(time)), @@ -123,6 +118,7 @@ def ShowTimeHistoy(act_time): return display_data +# pylint: disable=too-few-public-methods class AvatarSampleWidget(ILeftBody, Image): """AvatarSampleWidget class for kivy Ui""" @@ -132,6 +128,7 @@ class TimeTagRightSampleWidget(IRightBodyTouch, MDLabel): class SwipeToDeleteItem(MDCardSwipe): + """Swipe delete class for App UI""" text = StringProperty() cla = Window.size[0] / 2 # cla = 800 @@ -140,6 +137,7 @@ class SwipeToDeleteItem(MDCardSwipe): class CutsomSwipeToDeleteItem(MDCardSwipe): + """Custom swipe delete class for App UI""" text = StringProperty() cla = Window.size[0] / 2 swipe_distance = NumericProperty(cla) diff --git a/src/bitmessagekivy/baseclass/login.py b/src/bitmessagekivy/baseclass/login.py index 6ddd0369..e3857806 100644 --- a/src/bitmessagekivy/baseclass/login.py +++ b/src/bitmessagekivy/baseclass/login.py @@ -60,7 +60,7 @@ class Random(Screen): self.manager.current = 'myaddress' Clock.schedule_once(self.address_created_callback, 6) - def address_created_callback(self, dt=0): # pylint: disable=unused-argument + def address_created_callback(self, dt=0): # pylint: disable=unused-argument """New address created""" state.kivyapp.loadMyAddressScreen(False) state.kivyapp.root.ids.sc10.ids.ml.clear_widgets() diff --git a/src/bitmessagekivy/baseclass/msg_composer.py b/src/bitmessagekivy/baseclass/msg_composer.py index a2fb0ce9..fc8e1b39 100644 --- a/src/bitmessagekivy/baseclass/msg_composer.py +++ b/src/bitmessagekivy/baseclass/msg_composer.py @@ -48,7 +48,7 @@ class Create(Screen): self.add_widget(widget_1) self.children[0].ids.id_scroll.bind(scroll_y=self.check_scroll_y) - def check_scroll_y(self, instance, somethingelse): # pylint: disable=unused-argument + def check_scroll_y(self, instance, somethingelse): # pylint: disable=unused-argument """show data on scroll down""" if self.children[1].ids.btn.is_open: self.children[1].ids.btn.is_open = False @@ -84,100 +84,94 @@ class DropDownWidget(BoxLayout): toAddress = self.ids.txt_input.text.strip() subject = self.ids.subject.text.strip() message = self.ids.body.text.strip() - encoding = 3 print("message: ", self.ids.body.text) - sendMessageToPeople = True - if sendMessageToPeople: - if toAddress != "" and subject and message: - status, addressVersionNumber, streamNumber, ripe = decodeAddress( - toAddress - ) - if status == "success": - navApp.root.ids.sc3.children[0].active = True - if state.detailPageType == "draft" and state.send_draft_mail: - sqlExecute( - "UPDATE sent SET toaddress = ?" - ", fromaddress = ? , subject = ?" - ", message = ?, folder = 'sent'" - ", senttime = ?, lastactiontime = ?" - " WHERE ackdata = ?;", - toAddress, - fromAddress, - subject, - message, - int(time.time()), - int(time.time()), - state.send_draft_mail) - self.parent.parent.screens[13].clear_widgets() - self.parent.parent.screens[13].add_widget(Factory.Draft()) - # state.detailPageType = '' - # state.send_draft_mail = None - else: - from addresses import addBMIfNotPresent - toAddress = addBMIfNotPresent(toAddress) - statusIconColor = 'red' - if (addressVersionNumber > 4) or ( - addressVersionNumber <= 1): - print( - "addressVersionNumber > 4" - " or addressVersionNumber <= 1") - if streamNumber > 1 or streamNumber == 0: - print("streamNumber > 1 or streamNumber == 0") - if statusIconColor == 'red': - print("shared.statusIconColor == 'red'") - stealthLevel = BMConfigParser().safeGetInt( - 'bitmessagesettings', 'ackstealthlevel') - from helper_ackPayload import genAckPayload - ackdata = genAckPayload(streamNumber, stealthLevel) - # t = () - sqlExecute( - '''INSERT INTO sent VALUES - (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)''', - '', - toAddress, - ripe, - fromAddress, - subject, - message, - ackdata, - int(time.time()), - int(time.time()), - 0, - 'msgqueued', - 0, - 'sent', - encoding, - BMConfigParser().safeGetInt( - 'bitmessagesettings', 'ttl')) - state.check_sent_acc = fromAddress - # state.msg_counter_objs = self.parent.parent.parent.parent\ - # .parent.parent.children[2].children[0].ids - if state.detailPageType == 'draft' \ - and state.send_draft_mail: - state.draft_count = str(int(state.draft_count) - 1) - # state.msg_counter_objs.draft_cnt.badge_text = ( - # state.draft_count) - state.detailPageType = '' - state.send_draft_mail = None - self.parent.parent.parent.ids.sc4.update_sent_messagelist() - allmailCnt_obj = state.kivyapp.root.ids.content_drawer.ids.allmail_cnt - allmailCnt_obj.ids.badge_txt.text = showLimitedCnt(int(state.all_count) + 1) - state.all_count = str(int(state.all_count) + 1) - Clock.schedule_once(self.callback_for_msgsend, 3) - queues.workerQueue.put(('sendmessage', toAddress)) - print("sqlExecute successfully #######################") - state.in_composer = True - return + if toAddress != "" and subject and message: + status, addressVersionNumber, streamNumber, ripe = decodeAddress( + toAddress + ) + if status == "success": + navApp.root.ids.sc3.children[0].active = True + if state.detailPageType == "draft" and state.send_draft_mail: + sqlExecute( + "UPDATE sent SET toaddress = ?" + ", fromaddress = ? , subject = ?" + ", message = ?, folder = 'sent'" + ", senttime = ?, lastactiontime = ?" + " WHERE ackdata = ?;", + toAddress, + fromAddress, + subject, + message, + int(time.time()), + int(time.time()), + state.send_draft_mail) + self.parent.parent.screens[13].clear_widgets() + self.parent.parent.screens[13].add_widget(Factory.Draft()) + # state.detailPageType = '' + # state.send_draft_mail = None else: - msg = 'Enter a valid recipients address' - elif not toAddress: - msg = 'Please fill the form completely' + from addresses import addBMIfNotPresent + # toAddress = addBMIfNotPresent(toAddress) + if (addressVersionNumber > 4) or ( + addressVersionNumber <= 1): + print( + "addressVersionNumber > 4" + " or addressVersionNumber <= 1") + if streamNumber > 1 or streamNumber == 0: + print("streamNumber > 1 or streamNumber == 0") + stealthLevel = BMConfigParser().safeGetInt( + 'bitmessagesettings', 'ackstealthlevel') + from helper_ackPayload import genAckPayload + # ackdata = genAckPayload(streamNumber, stealthLevel) + # t = () + sqlExecute( + '''INSERT INTO sent VALUES + (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)''', + '', + addBMIfNotPresent(toAddress), + ripe, + fromAddress, + subject, + message, + genAckPayload(streamNumber, stealthLevel), #ackdata + int(time.time()), + int(time.time()), + 0, + 'msgqueued', + 0, + 'sent', + 3, #encoding + BMConfigParser().safeGetInt( + 'bitmessagesettings', 'ttl')) + state.check_sent_acc = fromAddress + # state.msg_counter_objs = self.parent.parent.parent.parent\ + # .parent.parent.children[2].children[0].ids + if state.detailPageType == 'draft' \ + and state.send_draft_mail: + state.draft_count = str(int(state.draft_count) - 1) + # state.msg_counter_objs.draft_cnt.badge_text = ( + # state.draft_count) + state.detailPageType = '' + state.send_draft_mail = None + self.parent.parent.parent.ids.sc4.update_sent_messagelist() + allmailCnt_obj = state.kivyapp.root.ids.content_drawer.ids.allmail_cnt + allmailCnt_obj.ids.badge_txt.text = showLimitedCnt(int(state.all_count) + 1) + state.all_count = str(int(state.all_count) + 1) + Clock.schedule_once(self.callback_for_msgsend, 3) + queues.workerQueue.put(('sendmessage', addBMIfNotPresent(toAddress))) + print("sqlExecute successfully #######################") + state.in_composer = True + return else: - msg = 'Please fill the form completely' - self.address_error_message(msg) + msg = 'Enter a valid recipients address' + elif not toAddress: + msg = 'Please fill the form completely' + else: + msg = 'Please fill the form completely' + self.address_error_message(msg) @staticmethod - def callback_for_msgsend(dt=0): # pylint: disable=unused-argument + def callback_for_msgsend(dt=0): # pylint: disable=unused-argument """Callback method for messagesend""" state.kivyapp.root.ids.sc3.children[0].active = False state.in_sent_method = True @@ -259,7 +253,7 @@ class MyTextInput(TextInput): super(MyTextInput, self).__init__(**kwargs) self.__lineBreak__ = 0 - def on_text(self, instance, value): # pylint: disable=unused-argument + def on_text(self, instance, value): # pylint: disable=unused-argument """Find all the occurrence of the word""" self.parent.parent.parent.parent.parent.ids.rv.data = [] matches = [self.word_list[i] for i in range( diff --git a/src/bitmessagekivy/baseclass/myaddress.py b/src/bitmessagekivy/baseclass/myaddress.py index 3f497611..09cc0774 100644 --- a/src/bitmessagekivy/baseclass/myaddress.py +++ b/src/bitmessagekivy/baseclass/myaddress.py @@ -2,7 +2,7 @@ from bitmessagekivy.get_platform import platform from functools import partial from bmconfigparser import BMConfigParser from kivy.clock import Clock -from kivy.metrics import dp +# from kivy.metrics import dp from kivy.properties import ( ListProperty, StringProperty @@ -100,7 +100,7 @@ class MyAddress(Screen): text=item['text'], secondary_text=item['secondary_text'], theme_text_color='Custom' if is_enable == 'true' else 'Primary', text_color=ThemeClsColor,) - meny._txt_right_pad = dp(70) + # meny._txt_right_pad = dp(70) try: meny.canvas.children[3].rgba = [0, 0, 0, 0] if is_enable == 'true' else [0.5, 0.5, 0.5, 0.5] except Exception: @@ -191,7 +191,7 @@ class MyAddress(Screen): self.ids.ml.clear_widgets() self.init_ui() self.ids.refresh_layout.refresh_done() - self.tick = 0 + # self.tick = 0 Clock.schedule_once(self.address_permision_callback, 0) Clock.schedule_once(refresh_callback, 1) diff --git a/src/bitmessagekivy/baseclass/network.py b/src/bitmessagekivy/baseclass/network.py index 978ec65e..bdc79068 100644 --- a/src/bitmessagekivy/baseclass/network.py +++ b/src/bitmessagekivy/baseclass/network.py @@ -4,6 +4,8 @@ from kivy.clock import Clock from kivy.properties import StringProperty from kivy.uix.screenmanager import Screen +from network import objectracker, stats + class NetworkStat(Screen): """NetworkStat class for kivy Ui""" @@ -26,10 +28,8 @@ class NetworkStat(Screen): def init_ui(self, dt=0): """Clock Schdule for method networkstat screen""" - import network.stats - from network import objectracker self.text_variable_1 = '{0} :: {1}'.format( - 'Total Connections', str(len(network.stats.connectedHostsList()))) + 'Total Connections', str(len(stats.connectedHostsList()))) self.text_variable_2 = 'Processed {0} per-to-per messages'.format( str(state.numberOfMessagesProcessed)) self.text_variable_3 = 'Processed {0} brodcast messages'.format( diff --git a/src/bitmessagekivy/baseclass/payment.py b/src/bitmessagekivy/baseclass/payment.py index d26fbe8e..0e9777ca 100644 --- a/src/bitmessagekivy/baseclass/payment.py +++ b/src/bitmessagekivy/baseclass/payment.py @@ -11,10 +11,10 @@ from kivymd.uix.list import ( OneLineAvatarIconListItem ) -from bmconfigparser import BMConfigParser +# from bmconfigparser import BMConfigParser from bitmessagekivy.baseclass.common import toast -import queues +# import queues import state diff --git a/src/bitmessagekivy/baseclass/popup.py b/src/bitmessagekivy/baseclass/popup.py index 3cfa587a..de6441d3 100644 --- a/src/bitmessagekivy/baseclass/popup.py +++ b/src/bitmessagekivy/baseclass/popup.py @@ -203,7 +203,6 @@ class SenderDetailPopup(Popup): device_type = 2 if platform == 'android' else 1.5 pop_height = 1.2 * device_type * (self.ids.sd_label.height + self.ids.dismiss_btn.height) if len(to_addr) > 3: - self.height = 0 self.height = pop_height self.ids.to_addId.size_hint_y = None self.ids.to_addId.height = 50 @@ -215,7 +214,6 @@ class SenderDetailPopup(Popup): self.ids.space_1.height = dp(0) self.ids.space_2.height = dp(0) self.ids.myadd_popup_box.spacing = dp(8 if platform == 'android' else 3) - self.height = 0 self.height = pop_height / 1.2 diff --git a/src/bitmessagekivy/baseclass/trash.py b/src/bitmessagekivy/baseclass/trash.py index c65ce2b5..aeb648eb 100644 --- a/src/bitmessagekivy/baseclass/trash.py +++ b/src/bitmessagekivy/baseclass/trash.py @@ -26,7 +26,7 @@ class Trash(Screen): trash_messages = ListProperty() has_refreshed = True - # delete_index = StringProperty() + delete_index = None table_name = StringProperty() def __init__(self, *args, **kwargs): @@ -106,10 +106,8 @@ class Trash(Screen): self.ids.ml.children) else False def on_swipe_complete(self, instance, *args): - if instance.state == 'closed': - instance.ids.delete_msg.disabled = True - else: - instance.ids.delete_msg.disabled = False + """call on swipe left""" + instance.ids.delete_msg.disabled = bool(instance.state == 'closed') def check_scroll_y(self, instance, somethingelse): """Load data on scroll""" diff --git a/src/bitmessagekivy/mpybit.py b/src/bitmessagekivy/mpybit.py index 5096f2f5..001b14c0 100644 --- a/src/bitmessagekivy/mpybit.py +++ b/src/bitmessagekivy/mpybit.py @@ -235,7 +235,8 @@ class NavigateApp(MDApp): os.path.join( os.path.dirname(__file__), 'kv', - f'{all_data[kv]["kv_string"]}.kv', + # f'{all_data[kv]["kv_string"]}.kv', + '{0}.kv'.format(all_data[kv]["kv_string"]), ) ) # self.obj_1 = AddressBook() @@ -957,7 +958,8 @@ class NavigateApp(MDApp): add_obj.content_cls.ids.address.text = text Clock.schedule_once(partial(self.open_popup, add_obj), .5) - def open_popup(self, instance, dt): + @staticmethod + def open_popup(instance, dt): """This method is used for opening popup""" instance.open()