From f5c90955f02422ed35eef5f485bf1a140e926e50 Mon Sep 17 00:00:00 2001 From: Mandar Patil Date: Sat, 7 Oct 2023 09:03:15 -0700 Subject: [PATCH] Renamed folder_fmt to match with naming conventions --- src/sync_photos.py | 24 ++++++++++++------------ tests/test_sync_photos.py | 4 ++-- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/sync_photos.py b/src/sync_photos.py index cc7501e19..da9de1713 100644 --- a/src/sync_photos.py +++ b/src/sync_photos.py @@ -22,7 +22,7 @@ def photo_wanted(photo, extensions): return False -def generate_file_name(photo, file_size, destination_path, folder_fmt): +def generate_file_name(photo, file_size, destination_path, folder_format): """Generate full path to file.""" filename = photo.filename name, extension = filename.rsplit(".", 1) if "." in filename else [filename, ""] @@ -40,8 +40,8 @@ def generate_file_name(photo, file_size, destination_path, folder_fmt): else f'{"__".join([name, file_size, base64.urlsafe_b64encode(photo.id.encode()).decode()])}.{extension}', ) - if folder_fmt is not None: - folder = photo.created.strftime(folder_fmt) + if folder_format is not None: + folder = photo.created.strftime(folder_format) file_size_id_path = os.path.join( destination_path, folder, @@ -94,13 +94,13 @@ def download_photo(photo, file_size, destination_path): return True -def process_photo(photo, file_size, destination_path, files, folder_fmt): +def process_photo(photo, file_size, destination_path, files, folder_format): """Process photo details.""" photo_path = generate_file_name( photo=photo, file_size=file_size, destination_path=destination_path, - folder_fmt=folder_fmt, + folder_format=folder_format, ) if file_size not in photo.versions: LOGGER.warning( @@ -116,7 +116,7 @@ def process_photo(photo, file_size, destination_path, files, folder_fmt): def sync_album( - album, destination_path, file_sizes, extensions=None, files=None, folder_fmt=None + album, destination_path, file_sizes, extensions=None, files=None, folder_format=None ): """Sync given album.""" if album is None or destination_path is None or file_sizes is None: @@ -126,7 +126,7 @@ def sync_album( for photo in album: if photo_wanted(photo, extensions): for file_size in file_sizes: - process_photo(photo, file_size, destination_path, files, folder_fmt) + process_photo(photo, file_size, destination_path, files, folder_format) else: LOGGER.debug(f"Skipping the unwanted photo {photo.filename}.") for subalbum in album.subalbums: @@ -136,7 +136,7 @@ def sync_album( file_sizes, extensions, files, - folder_fmt, + folder_format, ) return True @@ -162,7 +162,7 @@ def sync_photos(config, photos): filters = config_parser.get_photos_filters(config=config) files = set() download_all = config_parser.get_photos_all_albums(config=config) - folder_fmt = config_parser.get_photos_folder_format(config=config) + folder_format = config_parser.get_photos_folder_format(config=config) if download_all: for album in photos.albums.keys(): sync_album( @@ -171,7 +171,7 @@ def sync_photos(config, photos): file_sizes=filters["file_sizes"], extensions=filters["extensions"], files=files, - folder_fmt=folder_fmt, + folder_format=folder_format, ) elif filters["albums"]: for album in iter(filters["albums"]): @@ -181,7 +181,7 @@ def sync_photos(config, photos): file_sizes=filters["file_sizes"], extensions=filters["extensions"], files=files, - folder_fmt=folder_fmt, + folder_format=folder_format, ) else: sync_album( @@ -190,7 +190,7 @@ def sync_photos(config, photos): file_sizes=filters["file_sizes"], extensions=filters["extensions"], files=files, - folder_fmt=folder_fmt, + folder_format=folder_format, ) if config_parser.get_photos_remove_obsolete(config=config): diff --git a/tests/test_sync_photos.py b/tests/test_sync_photos.py index 3bed5002a..e2483b8d2 100644 --- a/tests/test_sync_photos.py +++ b/tests/test_sync_photos.py @@ -519,7 +519,7 @@ def versions(self): file_size="medium", destination_path=self.destination_path, files=None, - folder_fmt=None, + folder_format=None, ) ) @@ -545,7 +545,7 @@ def versions(self): file_size="thumb", destination_path=self.destination_path, files=None, - folder_fmt=None, + folder_format=None, ) )