DeepSource Fixing Antipatterns

This commit is contained in:
Michał Gdula 2023-04-02 16:50:52 +00:00
parent 1152856f2a
commit 7b97b8e0ef
11 changed files with 177 additions and 185 deletions

View file

@ -64,7 +64,7 @@ def generate_thumbnail(file_name, resolution, ext=None):
# Save image to cache directory
try:
image.save(os.path.join(CACHE_PATH,f'{file_name}_{res_x}x{res_y}.{ext}'),
image.save(os.path.join(CACHE_PATH, f'{file_name}_{res_x}x{res_y}.{ext}'),
icc_profile=image_icc)
except OSError:
# This usually happens when saving a JPEG with an ICC profile,

View file

@ -279,7 +279,7 @@ def lens_specification(value):
"""
try:
return str(value[0] / value[1]) + 'mm - ' + str(value[2] / value[3]) + 'mm'
except Exception:
except ValueError:
return None

View file

@ -45,19 +45,11 @@ def compile_theme(theme_name, app_path):
# If the destination folder exists, remove it
if os.path.exists(os.path.join(theme_destination, 'fonts')):
try:
shutil.rmtree(os.path.join(theme_destination, 'fonts'))
except Exception as err:
print("Failed to remove old fonts!\n", err)
sys.exit(1)
shutil.rmtree(os.path.join(theme_destination, 'fonts'))
# Copy the fonts
try:
shutil.copytree(os.path.join(theme_source, 'fonts'),
os.path.join(theme_destination, 'fonts'))
print("Fonts copied successfully!")
except Exception as err:
print("Failed to copy fonts!\n", err)
sys.exit(1)
shutil.copytree(os.path.join(theme_source, 'fonts'),
os.path.join(theme_destination, 'fonts'))
print("Fonts copied successfully!")
print(f"{datetime.now().hour}:{datetime.now().minute}:{datetime.now().second} - Done!\n")