From e92fef862da395dd9c44b647cf45669effc4e192 Mon Sep 17 00:00:00 2001 From: Mandar Patil Date: Tue, 29 Aug 2023 14:11:24 +0000 Subject: [PATCH] Fixes for lint error --- src/sync_drive.py | 12 ++++++------ src/sync_photos.py | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/sync_drive.py b/src/sync_drive.py index aa975d665..1c4243ff5 100644 --- a/src/sync_drive.py +++ b/src/sync_drive.py @@ -79,7 +79,7 @@ def process_folder(item, destination_path, filters, ignore, root): if not (item and destination_path and root): return None new_directory = os.path.join(destination_path, item.name) - new_directory_norm = unicodedata.normalize('NFC', new_directory) + new_directory_norm = unicodedata.normalize("NFC", new_directory) if not wanted_folder( filters=filters, ignore=ignore, folder_path=new_directory_norm, root=root ): @@ -155,9 +155,9 @@ def process_package(local_file): LOGGER.info(f"Unpacking {archive_file} to {os.path.dirname(archive_file)}") unpack_archive(filename=archive_file, extract_dir=os.path.dirname(archive_file)) try: - os.rename(unicodedata.normalize('NFD', local_file), local_file) - except: - LOGGER.warning("Normalizing failed") + os.rename(unicodedata.normalize("NFD", local_file), local_file) + except Exception as e: + LOGGER.warning("Normalizing failed - " + str(e)) os.remove(archive_file) elif "application/gzip" == magic_object.from_file(filename=local_file): archive_file += ".gz" @@ -209,7 +209,7 @@ def process_file(item, destination_path, filters, ignore, files): if not (item and destination_path and files is not None): return False local_file = os.path.join(destination_path, item.name) - local_file = unicodedata.normalize('NFC', local_file) + local_file = unicodedata.normalize("NFC", local_file) if not wanted_file(filters=filters, ignore=ignore, file_path=local_file): return False files.add(local_file) @@ -274,7 +274,7 @@ def sync_directory( if not new_folder: continue try: - files.add(unicodedata.normalize('NFC', new_folder)) + files.add(unicodedata.normalize("NFC", new_folder)) files.update( sync_directory( drive=item, diff --git a/src/sync_photos.py b/src/sync_photos.py index 8438e2924..d89aca5c3 100644 --- a/src/sync_photos.py +++ b/src/sync_photos.py @@ -40,7 +40,7 @@ def generate_file_name(photo, file_size, destination_path): else f'{"__".join([name, file_size, base64.urlsafe_b64encode(photo.id.encode()).decode()])}.{extension}', ) - file_size_id_path_norm = unicodedata.normalize('NFC', file_size_id_path) + file_size_id_path_norm = unicodedata.normalize("NFC", file_size_id_path) if os.path.isfile(file_path): os.rename(file_path, file_size_id_path)