From 48f1889ee961200670cc323baa06072f1ff9eec5 Mon Sep 17 00:00:00 2001 From: crunk Date: Fri, 15 Nov 2024 14:23:29 +0100 Subject: [PATCH] refactor the image function from hell --- distribusi/distribusi.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/distribusi/distribusi.py b/distribusi/distribusi.py index 91145c7..eaef912 100644 --- a/distribusi/distribusi.py +++ b/distribusi/distribusi.py @@ -141,21 +141,21 @@ def handle_image_files(name, full_path, args): thumbnail_filename = thumbnail(full_path, name, args) if thumbnail_filename is None: return - if args.alttexts: - image_alttext = add_alttext(full_path) - if args.alttexts: - image_description = add_description(full_path) - if image_alttext is None: - if image_description is None: - return image_no_description.format( - name=name, thumbnail_filename=thumbnail_filename - ) + + image_alttext = add_alttext(full_path) + image_description = add_description(full_path) + + if not image_alttext and not image_description: + return image_no_description.format( + name=name, thumbnail_filename=thumbnail_filename + ) + if not image_alttext: return image_with_description.format( name=name, thumbnail_filename=thumbnail_filename, image_description=image_description, ) - if image_description is None: + if not image_description: return image_with_alttext.format( name=name, thumbnail_filename=thumbnail_filename,