From 8576e9244f0a40b0cc2d370d74e93e56949464f0 Mon Sep 17 00:00:00 2001 From: navjot Date: Fri, 21 May 2021 17:06:11 +0530 Subject: [PATCH] CQ fixes for pylint --- .../recipes/bitmsghash/__init__.py | 5 +-- src/bitmessagekivy/baseclass/addressbook.py | 2 +- src/bitmessagekivy/baseclass/login.py | 9 +++-- src/bitmessagekivy/baseclass/msg_composer.py | 14 ++++--- src/bitmessagekivy/baseclass/payment.py | 37 +++++++++++-------- src/bitmessagekivy/baseclass/scan_screen.py | 4 ++ src/bitmessagekivy/kv/login.kv | 2 +- src/bitmessagekivy/mpybit.py | 10 ++--- src/bitmessagekivy/tests/common.py | 12 ++++-- .../tests/test_create_random_address.py | 1 + .../tests/test_network_screen.py | 2 +- 11 files changed, 60 insertions(+), 38 deletions(-) diff --git a/src/bitmessagekivy/android/python-for-android/recipes/bitmsghash/__init__.py b/src/bitmessagekivy/android/python-for-android/recipes/bitmsghash/__init__.py index 4566ebfb..15c8f935 100644 --- a/src/bitmessagekivy/android/python-for-android/recipes/bitmsghash/__init__.py +++ b/src/bitmessagekivy/android/python-for-android/recipes/bitmsghash/__init__.py @@ -1,7 +1,5 @@ -from pythonforandroid.toolchain import Recipe, shprint, shutil, current_directory +from pythonforandroid.toolchain import Recipe, shprint, current_directory from os.path import exists, join -import os -import sys from multiprocessing import cpu_count import sh @@ -47,4 +45,5 @@ class BitmsghashRecipe(Recipe): self.install_libs(arch, '{}/libbitmsghash.so'.format(dst_dir), 'libbitmsghash.so') + recipe = BitmsghashRecipe() diff --git a/src/bitmessagekivy/baseclass/addressbook.py b/src/bitmessagekivy/baseclass/addressbook.py index a31b1e36..bb6672d2 100644 --- a/src/bitmessagekivy/baseclass/addressbook.py +++ b/src/bitmessagekivy/baseclass/addressbook.py @@ -15,7 +15,7 @@ from kivy.uix.screenmanager import Screen import state from bitmessagekivy.baseclass.common import ( - AvatarSampleWidget, avatarImageFirstLetter, toast, + avatarImageFirstLetter, toast, ThemeClsColor, SwipeToDeleteItem ) from bitmessagekivy.baseclass.popup import AddbookDetailPopup diff --git a/src/bitmessagekivy/baseclass/login.py b/src/bitmessagekivy/baseclass/login.py index 58f56a6c..6ddd0369 100644 --- a/src/bitmessagekivy/baseclass/login.py +++ b/src/bitmessagekivy/baseclass/login.py @@ -14,6 +14,7 @@ from bitmessagekivy.baseclass.common import toast class Login(Screen): """Login Screeen class for kivy Ui""" + # pylint: disable=too-few-public-methods log_text1 = ( 'You may generate addresses by using either random numbers' ' or by using a passphrase If you use a passphrase, the address' @@ -35,7 +36,7 @@ class Random(Screen): is_active = BooleanProperty(False) checked = StringProperty("") - def generateaddress(self, navApp): + def generateaddress(self): """Method for Address Generator""" # entered_label = str(self.ids.lab.text).strip() entered_label = str(self.ids.add_random_bx.children[0].ids.lab.text).strip() @@ -59,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): + 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() @@ -94,7 +95,7 @@ class Random(Screen): instance.error = False instance.helper_text = 'This field is required' - def reset_address_label(self, n): + def reset_address_label(self): """Resetting address labels""" if not self.ids.add_random_bx.children: self.ids.add_random_bx.add_widget(RandomBoxlayout()) @@ -102,7 +103,9 @@ class Random(Screen): class InfoLayout(BoxLayout, RectangularElevationBehavior): """InfoLayout class for kivy Ui""" + # pylint: disable=too-few-public-methods class RandomBoxlayout(BoxLayout): """RandomBoxlayout class for BoxLayout behaviour""" + # pylint: disable=too-few-public-methods diff --git a/src/bitmessagekivy/baseclass/msg_composer.py b/src/bitmessagekivy/baseclass/msg_composer.py index 50739791..a2fb0ce9 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): + 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 @@ -177,14 +177,15 @@ class DropDownWidget(BoxLayout): self.address_error_message(msg) @staticmethod - def callback_for_msgsend(dt=0): + 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 state.kivyapp.back_press() toast("sent") - def address_error_message(self, msg): + @staticmethod + def address_error_message(msg): """Generates error message""" width = .8 if platform == 'android' else .55 dialog_box = MDDialog( @@ -217,11 +218,14 @@ class DropDownWidget(BoxLayout): self.ids.ti.focus = True def is_camara_attached(self): + """Checks the camera availability in device""" self.parent.parent.parent.ids.sc23.check_camera() is_available = self.parent.parent.parent.ids.sc23.camera_avaialbe return is_available - def camera_alert(self): + @staticmethod + def camera_alert(): + """Show camera availability alert message""" width = .8 if platform == 'android' else .55 altet_txt = 'Currently this feature is not avaialbe!'if platform == 'android' else 'Camera is not available!' dialog_box = MDDialog( @@ -255,7 +259,7 @@ class MyTextInput(TextInput): super(MyTextInput, self).__init__(**kwargs) self.__lineBreak__ = 0 - def on_text(self, instance, value): + 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/payment.py b/src/bitmessagekivy/baseclass/payment.py index 3023b1df..d26fbe8e 100644 --- a/src/bitmessagekivy/baseclass/payment.py +++ b/src/bitmessagekivy/baseclass/payment.py @@ -1,15 +1,19 @@ -from bmconfigparser import BMConfigParser - -from bitmessagekivy.baseclass.common import toast +''' + This is for pamyent related part +''' from kivy.uix.boxlayout import BoxLayout from kivymd.uix.behaviors.elevation import RectangularElevationBehavior from kivy.uix.screenmanager import Screen + from kivymd.uix.label import MDLabel from kivymd.uix.list import ( IRightBodyTouch, OneLineAvatarIconListItem ) +from bmconfigparser import BMConfigParser +from bitmessagekivy.baseclass.common import toast + import queues import state @@ -31,20 +35,21 @@ class Payment(Screen): state.kivyapp.root.ids.sc18.ids.cred.text = '{0}'.format( state.availabe_credit) - def create_hidden_payment_address(self, instance): + @staticmethod + def create_hidden_payment_address(): """This is basically used for creating hidden address used in payment for purchasing credits""" - if BMConfigParser().paymentaddress(): - toast('hidden payment address already exist for buying subscription...') - else: - streamNumberForAddress = 1 - eighteenByteRipe = False - nonceTrialsPerByte = 1000 - payloadLengthExtraBytes = 1000 - queues.addressGeneratorQueue.put(( - 'createPaymentAddress', 4, streamNumberForAddress, '', 1, - "", eighteenByteRipe, nonceTrialsPerByte, - payloadLengthExtraBytes)) - toast('hidden payment address Creating for buying subscription....') + # if BMConfigParser().paymentaddress(): + # toast('hidden payment address already exist for buying subscription...') + # else: + # streamNumberForAddress = 1 + # eighteenByteRipe = False + # nonceTrialsPerByte = 1000 + # payloadLengthExtraBytes = 1000 + # queues.addressGeneratorQueue.put(( + # 'createPaymentAddress', 4, streamNumberForAddress, '', 1, + # "", eighteenByteRipe, nonceTrialsPerByte, + # payloadLengthExtraBytes)) + # toast('hidden payment address Creating for buying subscription....') class Category(BoxLayout, RectangularElevationBehavior): diff --git a/src/bitmessagekivy/baseclass/scan_screen.py b/src/bitmessagekivy/baseclass/scan_screen.py index 67246ca3..cc90be91 100644 --- a/src/bitmessagekivy/baseclass/scan_screen.py +++ b/src/bitmessagekivy/baseclass/scan_screen.py @@ -36,6 +36,9 @@ from kivy.uix.screenmanager import Screen class ScanScreen(Screen): + """ScanScreen is for scaning Qr code""" + # pylint: disable=unused-argument + # pylint: disable=W0212 camera_avaialbe = BooleanProperty(False) previous_open_screen = StringProperty() pop_up_instance = ObjectProperty() @@ -88,6 +91,7 @@ class ScanScreen(Screen): Clock.schedule_once(self.start_camera, 0) def on_leave(self): + """this methos will call on leave""" # pass Clock.schedule_once(self.stop_camera, 0) diff --git a/src/bitmessagekivy/kv/login.kv b/src/bitmessagekivy/kv/login.kv index 6c78d847..e7c3b9a6 100644 --- a/src/bitmessagekivy/kv/login.kv +++ b/src/bitmessagekivy/kv/login.kv @@ -186,7 +186,7 @@ MDFillRoundFlatIconButton: icon: "chevron-double-right" text: app.tr._("Proceed Next") - on_release: app.root.ids.sc7.generateaddress(app) + on_release: app.root.ids.sc7.generateaddress() Widget: diff --git a/src/bitmessagekivy/mpybit.py b/src/bitmessagekivy/mpybit.py index a3f253e2..07539379 100644 --- a/src/bitmessagekivy/mpybit.py +++ b/src/bitmessagekivy/mpybit.py @@ -51,9 +51,9 @@ import state from kivymd.uix.bottomsheet import MDCustomBottomSheet from kivy.lang import Observable -import gettext -import l10n -import locale +# import gettext +# import l10n +# import locale import ast from bitmessagekivy.baseclass.common import toast @@ -234,8 +234,8 @@ class NavigateApp(MDApp): Builder.load_file( os.path.join( os.path.dirname(__file__), - "kv", - f"{all_data[kv]['kv_string']}.kv", + 'kv', + f'{all_data[kv]["kv_string"]}.kv', ) ) # self.obj_1 = AddressBook() diff --git a/src/bitmessagekivy/tests/common.py b/src/bitmessagekivy/tests/common.py index c072aea5..18f3bb00 100644 --- a/src/bitmessagekivy/tests/common.py +++ b/src/bitmessagekivy/tests/common.py @@ -1,17 +1,23 @@ +""" +This module is used for running test cases ui order. +""" import unittest def make_ordered_test(): + """this method is for compairing and arranging in order""" order = {} - def ordered(f): + def ordered_method(f): + """method for ordering""" order[f.__name__] = len(order) return f - def compare(a, b): + def compare_method(a, b): + """method for compairing order of methods""" return [1, -1][order[a] < order[b]] - return ordered, compare + return ordered_method, compare_method ordered, compare = make_ordered_test() diff --git a/src/bitmessagekivy/tests/test_create_random_address.py b/src/bitmessagekivy/tests/test_create_random_address.py index df572afa..c5d4589b 100644 --- a/src/bitmessagekivy/tests/test_create_random_address.py +++ b/src/bitmessagekivy/tests/test_create_random_address.py @@ -8,6 +8,7 @@ from string import ascii_lowercase class CreateRandomAddress(TeleniumTestProcess): + """This is for testing randrom address creation""" @classmethod def setUpClass(cls): diff --git a/src/bitmessagekivy/tests/test_network_screen.py b/src/bitmessagekivy/tests/test_network_screen.py index d0185389..cb708559 100644 --- a/src/bitmessagekivy/tests/test_network_screen.py +++ b/src/bitmessagekivy/tests/test_network_screen.py @@ -10,7 +10,7 @@ class NetwrokStatusScreen(TeleniumTestProcess): self.cli.sleep(4) self.cli.execute('app.clickNavDrawer()') self.cli.sleep(3) - self.cli.drag("//NavigationItem[@text=\"Sent\"]","//NavigationItem[@text=\"Inbox\"]",1) + self.cli.drag("//NavigationItem[@text=\"Sent\"]", "//NavigationItem[@text=\"Inbox\"]", 1) self.cli.sleep(3) self.cli.click_on('//NavigationItem[10]') self.cli.sleep(4)