From 41ce3ef1ba8b7c2a0a281c34f7b9ef604c7ecb31 Mon Sep 17 00:00:00 2001 From: surbhi Date: Mon, 9 Sep 2024 09:26:57 +0530 Subject: [PATCH 1/4] code-quality: Update code quality kivy/baseclass/draft --- src/bitmessagekivy/baseclass/draft.py | 36 ++++++++++++--------------- 1 file changed, 16 insertions(+), 20 deletions(-) diff --git a/src/bitmessagekivy/baseclass/draft.py b/src/bitmessagekivy/baseclass/draft.py index 1b3ddf21..8fe7f2ce 100644 --- a/src/bitmessagekivy/baseclass/draft.py +++ b/src/bitmessagekivy/baseclass/draft.py @@ -5,54 +5,50 @@ draft.py ============== -Draft screen - +Draft screen for managing draft messages in Kivy UI. """ from kivy.clock import Clock -from kivy.properties import ( - ListProperty, - StringProperty -) +from kivy.properties import ListProperty, StringProperty from kivy.uix.screenmanager import Screen from kivy.app import App from pybitmessage.bitmessagekivy.baseclass.common import ( - show_limited_cnt, empty_screen_label, - kivy_state_variables + show_limited_cnt, empty_screen_label, kivy_state_variables ) import logging + logger = logging.getLogger('default') class Draft(Screen): - """Draft screen class for kivy Ui""" + """Draft screen class for Kivy UI""" data = ListProperty() account = StringProperty() queryreturn = ListProperty() has_refreshed = True - label_str = "yet no message for this account!!!!!!!!!!!!!" + label_str = "Yet no message for this account!" def __init__(self, *args, **kwargs): - """Method used for storing draft messages""" - super(Draft, self).__init__(*args, **kwargs) + """Initialize the Draft screen and set the default account""" + super().__init__(*args, **kwargs) self.kivy_state = kivy_state_variables() - if self.kivy_state.selected_address == '': + if not self.kivy_state.selected_address: if App.get_running_app().identity_list: self.kivy_state.selected_address = App.get_running_app().identity_list[0] Clock.schedule_once(self.init_ui, 0) def init_ui(self, dt=0): - """Clock Schedule for method draft accounts""" + """Initialize the UI and load draft messages""" self.load_draft() - logger.debug(dt) + logger.debug(f"UI initialized with dt: {dt}") def load_draft(self, where="", what=""): - """Load draft list for Draft messages""" + """Load the list of draft messages""" self.set_draft_count('0') self.ids.ml.add_widget(empty_screen_label(self.label_str)) @staticmethod - def set_draft_count(Count): - """Set the count of draft mails""" - draftCnt_obj = App.get_running_app().root.ids.content_drawer.ids.draft_cnt - draftCnt_obj.ids.badge_txt.text = show_limited_cnt(int(Count)) + def set_draft_count(count): + """Set the count of draft messages in the UI""" + draft_count_obj = App.get_running_app().root.ids.content_drawer.ids.draft_cnt + draft_count_obj.ids.badge_txt.text = show_limited_cnt(int(count)) -- 2.45.1 From 3eec0da2046a732cc17a5d485e4fe35eed145c4e Mon Sep 17 00:00:00 2001 From: surbhi Date: Thu, 12 Sep 2024 08:44:31 +0530 Subject: [PATCH 2/4] code-quality: Update code quality kivy/baseclass/inbox --- src/bitmessagekivy/baseclass/inbox.py | 31 +++++++++++---------------- 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/src/bitmessagekivy/baseclass/inbox.py b/src/bitmessagekivy/baseclass/inbox.py index 2e145871..f9bd6f2d 100644 --- a/src/bitmessagekivy/baseclass/inbox.py +++ b/src/bitmessagekivy/baseclass/inbox.py @@ -6,18 +6,14 @@ Kivy UI for inbox screen """ from kivy.clock import Clock -from kivy.properties import ( - ListProperty, - StringProperty -) +from kivy.properties import ListProperty, StringProperty from kivy.app import App from kivy.uix.screenmanager import Screen - from pybitmessage.bitmessagekivy.baseclass.common import kivy_state_variables, load_image_path class Inbox(Screen): - """Inbox Screen class for kivy Ui""" + """Inbox Screen class for Kivy UI""" queryreturn = ListProperty() has_refreshed = True @@ -26,33 +22,32 @@ class Inbox(Screen): label_str = "Yet no message for this account!" def __init__(self, *args, **kwargs): - """Initialize kivy variables""" - super(Inbox, self).__init__(*args, **kwargs) + """Initialize Kivy variables and set up the UI""" + super().__init__(*args, **kwargs) self.kivy_running_app = App.get_running_app() self.kivy_state = kivy_state_variables() self.image_dir = load_image_path() Clock.schedule_once(self.init_ui, 0) - def set_defaultAddress(self): - """Set default address""" - if self.kivy_state.selected_address == "": - if self.kivy_running_app.identity_list: - self.kivy_state.selected_address = self.kivy_running_app.identity_list[0] + def set_default_address(self): + """Set the default address if none is selected""" + if not self.kivy_state.selected_address and self.kivy_running_app.identity_list: + self.kivy_state.selected_address = self.kivy_running_app.identity_list[0] def init_ui(self, dt=0): - """loadMessagelist() call at specific interval""" + """Initialize UI and load message list""" self.loadMessagelist() def loadMessagelist(self, where="", what=""): - """Load inbox list for inbox messages""" - self.set_defaultAddress() + """Load inbox messages""" + self.set_default_address() self.account = self.kivy_state.selected_address def refresh_callback(self, *args): - """Load inbox messages while wating-loader spins & called in inbox.kv""" + """Refresh the inbox messages while showing a loading spinner""" def refresh_on_scroll_down(interval): - """Reset fields and load data on scrolling upside down""" + """Reset search fields and reload data on scroll""" self.kivy_state.searching_text = "" self.children[2].children[1].ids.search_field.text = "" self.ids.ml.clear_widgets() -- 2.45.1 From 79ba94bc7fd3e3923b94fa5914d64479b95982ad Mon Sep 17 00:00:00 2001 From: surbhi Date: Thu, 17 Oct 2024 11:44:02 +0530 Subject: [PATCH 3/4] supress pylint super complaint --- src/bitmessagekivy/baseclass/inbox.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bitmessagekivy/baseclass/inbox.py b/src/bitmessagekivy/baseclass/inbox.py index f9bd6f2d..17ea9a9b 100644 --- a/src/bitmessagekivy/baseclass/inbox.py +++ b/src/bitmessagekivy/baseclass/inbox.py @@ -23,7 +23,7 @@ class Inbox(Screen): def __init__(self, *args, **kwargs): """Initialize Kivy variables and set up the UI""" - super().__init__(*args, **kwargs) + super().__init__(*args, **kwargs) # pylint: disable=missing-super-argument self.kivy_running_app = App.get_running_app() self.kivy_state = kivy_state_variables() self.image_dir = load_image_path() -- 2.45.1 From 1ee388389854d665c6987207ccc5ca6559d4e6e9 Mon Sep 17 00:00:00 2001 From: Peter Surda Date: Sun, 20 Oct 2024 10:33:37 +0800 Subject: [PATCH 4/4] Suppress flake8 error - python3-only code --- src/bitmessagekivy/baseclass/draft.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bitmessagekivy/baseclass/draft.py b/src/bitmessagekivy/baseclass/draft.py index 8fe7f2ce..50f883d6 100644 --- a/src/bitmessagekivy/baseclass/draft.py +++ b/src/bitmessagekivy/baseclass/draft.py @@ -40,7 +40,7 @@ class Draft(Screen): def init_ui(self, dt=0): """Initialize the UI and load draft messages""" self.load_draft() - logger.debug(f"UI initialized with dt: {dt}") + logger.debug(f"UI initialized with dt: {dt}") # noqa: E999 def load_draft(self, where="", what=""): """Load the list of draft messages""" -- 2.45.1