Skip to content

Commit

Permalink
Renamed functions 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 eff34eb commit eccced4
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/config_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ def get_region(config):
return region


def get_folder_format(config):
def get_photos_folder_format(config):
"""Return filename format or None."""
fmt = None
config_path = ["photos", "folder_format"]
Expand Down
13 changes: 9 additions & 4 deletions src/sync_photos.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,10 @@ def download_photo(photo, file_size, destination_path):
def process_photo(photo, file_size, destination_path, files, folder_fmt):
"""Process photo details."""
photo_path = generate_file_name(
photo=photo, file_size=file_size, destination_path=destination_path, folder_fmt=folder_fmt
photo=photo,
file_size=file_size,
destination_path=destination_path,
folder_fmt=folder_fmt,
)
if file_size not in photo.versions:
LOGGER.warning(
Expand All @@ -112,7 +115,9 @@ def process_photo(photo, file_size, destination_path, files, folder_fmt):
return True


def sync_album(album, destination_path, file_sizes, extensions=None, files=None, folder_fmt=None):
def sync_album(
album, destination_path, file_sizes, extensions=None, files=None, folder_fmt=None
):
"""Sync given album."""
if album is None or destination_path is None or file_sizes is None:
return None
Expand All @@ -131,7 +136,7 @@ def sync_album(album, destination_path, file_sizes, extensions=None, files=None,
file_sizes,
extensions,
files,
folder_fmt
folder_fmt,
)
return True

Expand All @@ -157,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_folder_format(config=config)
folder_fmt = config_parser.get_photos_folder_format(config=config)
if download_all:
for album in photos.albums.keys():
sync_album(
Expand Down
9 changes: 4 additions & 5 deletions tests/test_config_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -417,14 +417,13 @@ def test_get_all_albums_false(self):
config["photos"]["all_albums"] = False
self.assertFalse(config_parser.get_photos_all_albums(config=config))

def test_folder_fmt_empty(self):
def test_get_photos_folder_format_empty(self):
"""Empty folder_format."""
config = read_config(config_path=tests.CONFIG_PATH)
self.assertIsNone(config_parser.get_folder_format(config=config))
self.assertIsNone(config_parser.get_photos_folder_format(config=config))

def test_folder_fmt_set(self):
def test_get_photos_folder_format_valid(self):
"""folder_format is set."""
config = read_config(config_path=tests.CONFIG_PATH)
config["photos"]["folder_format"] = "%Y/%m"
self.assertEqual(config_parser.get_folder_format(config=config), "%Y/%m")

self.assertEqual(config_parser.get_photos_folder_format(config=config), "%Y/%m")

0 comments on commit eccced4

Please sign in to comment.