Skip to content

Commit

Permalink
Renamed folder_fmt to match with naming conventions
Browse files Browse the repository at this point in the history
  • Loading branch information
mandarons committed Oct 7, 2023
1 parent eccced4 commit f5c9095
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
24 changes: 12 additions & 12 deletions src/sync_photos.py
Original file line number Diff line number Diff line change
Expand Up @@ -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, ""]
Expand All @@ -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,
Expand Down Expand Up @@ -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(
Expand All @@ -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:
Expand All @@ -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:
Expand All @@ -136,7 +136,7 @@ def sync_album(
file_sizes,
extensions,
files,
folder_fmt,
folder_format,
)
return True

Expand All @@ -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(
Expand All @@ -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"]):
Expand All @@ -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(
Expand All @@ -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):
Expand Down
4 changes: 2 additions & 2 deletions tests/test_sync_photos.py
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@ def versions(self):
file_size="medium",
destination_path=self.destination_path,
files=None,
folder_fmt=None,
folder_format=None,
)
)

Expand All @@ -545,7 +545,7 @@ def versions(self):
file_size="thumb",
destination_path=self.destination_path,
files=None,
folder_fmt=None,
folder_format=None,
)
)

Expand Down

0 comments on commit f5c9095

Please sign in to comment.