Skip to content

Commit e284221

Browse files
committed
chore: Satisfy pylint
1 parent 940d60a commit e284221

File tree

1 file changed

+27
-27
lines changed

1 file changed

+27
-27
lines changed

immich_auto_album.py

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ def parse_album_properties_file(album_properties_file_path: str):
244244
# Backward compatibility, remove when archive is removed:
245245
if album_props_template.archive is not None:
246246
logging.warning("Found deprecated property archive in %s! This will be removed in the future, use visibility: archive instead!", album_properties_file_path)
247-
if album_props_template.visibility == None:
247+
if album_props_template.visibility is None:
248248
album_props_template.visibility = 'archive'
249249
# End backward compatibility
250250
return album_props_template
@@ -739,13 +739,13 @@ def fetch_assets(is_not_in_album: bool, visibility_options: list[str]) -> list:
739739
"""
740740
if version['major'] == 1 and version ['minor'] < 133:
741741
return fetch_assets_with_options({'isNotInAlbum': is_not_in_album, 'withArchived': 'archive' in visibility_options})
742-
else:
743-
asset_list = fetch_assets_with_options({'isNotInAlbum': is_not_in_album})
744-
for visiblity_option in visibility_options:
745-
# Do not fetch agin for 'timeline', that's the default!
746-
if visiblity_option != 'timeline':
747-
asset_list += fetch_assets_with_options({'isNotInAlbum': is_not_in_album, 'visibility': visiblity_option})
748-
return asset_list
742+
743+
asset_list = fetch_assets_with_options({'isNotInAlbum': is_not_in_album})
744+
for visiblity_option in visibility_options:
745+
# Do not fetch agin for 'timeline', that's the default!
746+
if visiblity_option != 'timeline':
747+
asset_list += fetch_assets_with_options({'isNotInAlbum': is_not_in_album, 'visibility': visiblity_option})
748+
return asset_list
749749

750750
def check_for_and_remove_live_photo_video_components(asset_list: list[dict], is_not_in_album: bool, find_archived: bool) -> list[dict]:
751751
"""
@@ -1452,7 +1452,7 @@ def update_album_properties(album_to_update: AlbumModel):
14521452
response = requests.patch(root_url+api_endpoint, json=data, **requests_kwargs, timeout=api_timeout)
14531453
check_api_response(response)
14541454

1455-
def set_assets_visibility(asset_ids_for_visibility: list[str], visibility: str):
1455+
def set_assets_visibility(asset_ids_for_visibility: list[str], visibility_setting: str):
14561456
"""
14571457
Sets the visibility of assets identified by the passed list of UUIDs.
14581458
@@ -1468,22 +1468,20 @@ def set_assets_visibility(asset_ids_for_visibility: list[str], visibility: str):
14681468
Exception if the API call fails
14691469
"""
14701470
api_endpoint = 'assets'
1471-
data = dict()
1472-
data["ids"] = asset_ids_for_visibility
1471+
data = {"ids": asset_ids_for_visibility}
14731472
# Remove when minimum supported version is >= 133
14741473
if version['major'] == 1 and version ['minor'] < 133:
1475-
if visibility is not None and visibility not in ['archive', 'timeline']:
1474+
if visibility_setting is not None and visibility_setting not in ['archive', 'timeline']:
14761475
# Warnings have been logged earlier, silently abort
14771476
return
1478-
else:
1479-
is_archived = True
1480-
if visibility == 'timeline':
1481-
is_archived = False
1482-
data["isArchived"] = is_archived
1477+
is_archived = True
1478+
if visibility_setting == 'timeline':
1479+
is_archived = False
1480+
data["isArchived"] = is_archived
14831481
# Up-to-date Immich Server versions
14841482
else:
1485-
data["visibility"] = visibility
1486-
1483+
data["visibility"] = visibility_setting
1484+
14871485
r = requests.put(root_url+api_endpoint, json=data, **requests_kwargs, timeout=api_timeout)
14881486
check_api_response(r)
14891487

@@ -1826,7 +1824,7 @@ def find_user_by_name_or_email(name_or_email: str, user_list: list[dict]) -> dic
18261824
Set this option to automatically archive all assets that were newly added to albums.
18271825
If this option is set in combination with --mode = CLEANUP or DELETE_ALL, archived images of deleted albums will be unarchived.
18281826
Archiving hides the assets from Immich's timeline.""")
1829-
# End Backward compaibility
1827+
# End Backward compaibility
18301828
parser.add_argument("--visibility", choices=['archive', 'hidden', 'locked', 'timeline'],
18311829
help="""Set this option to automatically set the visibility of all assets that are discovered by the script and assigned to albums.
18321830
Exception for value 'locked': Assets will not be added to any albums, but to the 'locked' folder only.
@@ -1900,10 +1898,11 @@ def find_user_by_name_or_email(name_or_email: str, user_list: list[dict]) -> dic
19001898
unattended = False
19011899

19021900
# Backward compatibility, remove when archive is removed
1903-
if visibility == None and archive:
1901+
if visibility is None and archive:
1902+
# pylint: disable=C0103
19041903
visibility = 'archive'
19051904
logging.warning('-v/--archive is DEPRECATED! Use --visibility=archive instead! This option will be removed in the future!')
1906-
# End Backward compaibility
1905+
# End Backward compaibility
19071906

19081907
is_docker = os.environ.get(ENV_IS_DOCKER, False)
19091908

@@ -1931,7 +1930,7 @@ def find_user_by_name_or_email(name_or_email: str, user_list: list[dict]) -> dic
19311930
logging.debug("set_album_thumbnail = %s", set_album_thumbnail)
19321931
# Backward compatibility, remove when archive is removed
19331932
logging.debug("archive = %s", archive)
1934-
# End Backward compaibility
1933+
# End Backward compaibility
19351934
logging.debug("visibility = %s", visibility)
19361935
logging.debug("find_archived_assets = %s", find_archived_assets)
19371936
logging.debug("read_album_properties = %s", read_album_properties)
@@ -2050,7 +2049,8 @@ def find_user_by_name_or_email(name_or_email: str, user_list: list[dict]) -> dic
20502049
albums_to_create = dict(sorted(albums_to_create.items(), key=lambda item: item[0]))
20512050

20522051
if version['major'] == 1 and version ['minor'] < 133:
2053-
albums_with_visibility = [album_check_to_check for album_check_to_check in albums_to_create.values() if album_check_to_check.visibility is not None and album_check_to_check.visibility != 'archive']
2052+
albums_with_visibility = [album_check_to_check for album_check_to_check in albums_to_create.values()
2053+
if album_check_to_check.visibility is not None and album_check_to_check.visibility != 'archive']
20542054
if len(albums_with_visibility) > 0:
20552055
logging.warning("Option 'visibility' is only supported in Immich Server v1.133.x and newer! Option will be ignored!")
20562056

@@ -2099,11 +2099,11 @@ def find_user_by_name_or_email(name_or_email: str, user_list: list[dict]) -> dic
20992099
for album in albums_to_create.values():
21002100
# Special case: Add assets to Locked folder
21012101
# Locked assets cannot be part of an album, so don't create albums in the first place
2102-
if(album.visibility == 'locked'):
2102+
if album.visibility == 'locked':
21032103
set_assets_visibility(album.get_asset_uuids(), album.visibility)
21042104
logging.info("Added %d assets to locked folder", len(album.get_asset_uuids()))
21052105
continue
2106-
2106+
21072107
# Create album if inexistent:
21082108
if not album.id:
21092109
album.id = create_album(album.get_final_name())
@@ -2117,7 +2117,7 @@ def find_user_by_name_or_email(name_or_email: str, user_list: list[dict]) -> dic
21172117
logging.info("%d new assets added to %s", len(assets_added), album.get_final_name())
21182118

21192119
# Set assets visibility
2120-
if(album.visibility is not None):
2120+
if album.visibility is not None:
21212121
set_assets_visibility(assets_added, album.visibility)
21222122
logging.info("Set visibility for %d assets to %s", len(assets_added), album.visibility)
21232123

0 commit comments

Comments
 (0)