From d545630ac77e10df77cc4daff67d719a51cfe81f Mon Sep 17 00:00:00 2001 From: Peter Surda Date: Thu, 22 Feb 2024 13:27:21 +0800 Subject: [PATCH] Code quality --- src/bitmessagekivy/baseclass/myaddress.py | 6 ++---- src/bitmessagekivy/identiconGeneration.py | 2 +- src/bitmessagekivy/mpybit.py | 11 ++++------- src/class_objectProcessor.py | 2 +- 4 files changed, 8 insertions(+), 13 deletions(-) diff --git a/src/bitmessagekivy/baseclass/myaddress.py b/src/bitmessagekivy/baseclass/myaddress.py index fd30cc76..0a46bae9 100644 --- a/src/bitmessagekivy/baseclass/myaddress.py +++ b/src/bitmessagekivy/baseclass/myaddress.py @@ -116,10 +116,8 @@ class MyAddress(Screen, HelperMyAddress): text=item['text'], secondary_text=item['secondary_text'], theme_text_color='Custom' if is_enable else 'Primary', text_color=ThemeClsColor,) - try: - meny.canvas.children[3].rgba = self.canvas_color_black if is_enable else self.canvas_color - except Exception: - pass + meny.canvas.children[3].rgba = \ + self.canvas_color_black if is_enable else self.canvas_color meny.add_widget(AvatarSampleWidget( source=os.path.join( self.image_dir, "text_images", "{}.png".format(avatar_image_first_letter( diff --git a/src/bitmessagekivy/identiconGeneration.py b/src/bitmessagekivy/identiconGeneration.py index 2d6578a7..52042602 100644 --- a/src/bitmessagekivy/identiconGeneration.py +++ b/src/bitmessagekivy/identiconGeneration.py @@ -40,7 +40,7 @@ def generate_hash(string): try: # make input case insensitive string = str.lower(string) - hash_object = hashlib.md5(str.encode(string)) + hash_object = hashlib.md5(str.encode(string)) # nosec B303 print(hash_object.hexdigest()) # returned object is a hex string return hash_object.hexdigest() diff --git a/src/bitmessagekivy/mpybit.py b/src/bitmessagekivy/mpybit.py index bd398ab9..4c024e52 100644 --- a/src/bitmessagekivy/mpybit.py +++ b/src/bitmessagekivy/mpybit.py @@ -405,13 +405,10 @@ class NavigateApp(MDApp): img_path = os.path.join( self.image_dir, 'default_identicon', '{}.png'.format(self.kivy_state_obj.selected_address) ) - try: - if os.path.exists(img_path): - os.remove(img_path) - self.root.ids.content_drawer.ids.reset_image.opacity = 0 - self.root.ids.content_drawer.ids.reset_image.disabled = True - except Exception as e: - pass + if os.path.exists(img_path): + os.remove(img_path) + self.root.ids.content_drawer.ids.reset_image.opacity = 0 + self.root.ids.content_drawer.ids.reset_image.disabled = True toast('Avatar reset') def get_default_logo(self, instance): diff --git a/src/class_objectProcessor.py b/src/class_objectProcessor.py index 2e1f5891..bab181b8 100644 --- a/src/class_objectProcessor.py +++ b/src/class_objectProcessor.py @@ -479,7 +479,7 @@ class objectProcessor(threading.Thread): logger.info( 'EC decryption successful using key associated' ' with ripe hash: %s.', hexlify(key)) - except Exception: + except Exception: # nosec B110 pass if not initialDecryptionSuccessful: # This is not a message bound for me. -- 2.45.1