From ced75a7b3d9aebbce7d2dfed815b535604b74d24 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Fri, 19 Aug 2022 17:00:33 +0100 Subject: [PATCH] Less indentation --- inbox.py | 43 ++++++++++++++++++++++--------------------- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/inbox.py b/inbox.py index 8224e0a77..91a06acc1 100644 --- a/inbox.py +++ b/inbox.py @@ -201,28 +201,29 @@ def cache_svg_images(session, base_dir: str, http_prefix: str, image_data = fp_svg.read() except OSError: print('EX: unable to read svg file data') - if image_data: - image_data = image_data.decode() - cleaned_up = \ - remove_script(image_data, log_filename, actor, url) - if cleaned_up != image_data: - # write the cleaned up svg image - svg_written = False - cleaned_up = cleaned_up.encode('utf-8') - try: - with open(image_filename, 'wb') as im_file: - im_file.write(cleaned_up) - svg_written = True - except OSError: - print('EX: unable to write cleaned up svg ' + url) - if svg_written: - # change the url to be the local version - obj['attachment'][index]['url'] = \ - http_prefix + '://' + domain_full + '/media/' + \ - post_id + '_' + filename - cached = True - else: + if not image_data: + continue + image_data = image_data.decode() + cleaned_up = \ + remove_script(image_data, log_filename, actor, url) + if cleaned_up != image_data: + # write the cleaned up svg image + svg_written = False + cleaned_up = cleaned_up.encode('utf-8') + try: + with open(image_filename, 'wb') as im_file: + im_file.write(cleaned_up) + svg_written = True + except OSError: + print('EX: unable to write cleaned up svg ' + url) + if svg_written: + # change the url to be the local version + obj['attachment'][index]['url'] = \ + http_prefix + '://' + domain_full + '/media/' + \ + post_id + '_' + filename cached = True + else: + cached = True return cached