Skip to content

Commit d567d89

Browse files
authored
Merge pull request #113 from Salvoxia/chore/lint
Chore/lint
2 parents 7defe06 + 8672758 commit d567d89

File tree

3 files changed

+40
-10
lines changed

3 files changed

+40
-10
lines changed

.github/workflows/build-image.yaml

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: build-image
22

3-
on:
3+
'on':
44
push:
55
paths-ignore:
66
- 'README.md'
@@ -11,7 +11,29 @@ on:
1111
- '[0-9]+\.[0-9]+\.[0-9]+'
1212

1313
jobs:
14+
lint:
15+
runs-on: ubuntu-latest
16+
name: Lint
17+
strategy:
18+
matrix:
19+
python-version: ["3.10", "3.11", "3.12"]
20+
steps:
21+
- uses: actions/checkout@v4
22+
- name: Set up Python ${{ matrix.python-version }}
23+
uses: actions/setup-python@v3
24+
with:
25+
python-version: ${{ matrix.python-version }}
26+
- name: Install dependencies
27+
run: |
28+
python -m pip install --upgrade pip
29+
pip install pylint
30+
pip install -r requirements.txt
31+
- name: Analysing the code with pylint
32+
run: |
33+
pylint $(git ls-files '*.py')
1434
docker:
35+
name: Build Docker Image
36+
needs: lint
1537
runs-on: ubuntu-latest
1638
steps:
1739
- name: Checkout

.github/workflows/ci.yaml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
name: CI
22

3-
on: [push]
3+
'on':
4+
pull_request:
5+
push:
6+
paths-ignore:
7+
- 'README.md'
48

59
jobs:
6-
build:
10+
lint:
711
runs-on: ubuntu-latest
12+
name: Lint
813
strategy:
914
matrix:
1015
python-version: ["3.10", "3.11", "3.12"]

immich_auto_album.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -600,16 +600,19 @@ def parse_separated_strings(items: list[str]) -> dict:
600600
parsed_strings_dict[key] = value
601601
return parsed_strings_dict
602602

603-
def create_album_name(asset_path_chunks: list[str], album_separator: str, album_name_post_regex: list = [str]) -> str:
603+
# pylint: disable=R0912
604+
def create_album_name(asset_path_chunks: list[str], album_separator: str, album_name_postprocess_regex: list) -> str:
604605
"""
605606
Create album names from provided path_chunks string array.
606607
607608
The method uses global variables album_levels_range_arr or album_levels to
608609
generate album names either by level range or absolute album levels. If multiple
609610
album path chunks are used for album names they are separated by album_separator.
610611
611-
album_name_post_regex is list of pairs of regex and replace, this is optional
612+
album_name_postprocess_regex is list of pairs of regex and replace, this is optional
612613
"""
614+
if album_name_postprocess_regex is None:
615+
album_name_postprocess_regex = [str]
613616

614617
album_name_chunks = ()
615618
logging.debug("path chunks = %s", list(asset_path_chunks))
@@ -654,15 +657,15 @@ def create_album_name(asset_path_chunks: list[str], album_separator: str, album_
654657

655658
# final album name before regex
656659
album_name = album_separator.join(album_name_chunks)
657-
logging.debug(f"Album Name {album_name}")
660+
logging.debug("Album Name %s", album_name)
658661

659662
# apply regex if any
660-
if album_name_post_regex:
661-
for pattern, *repl in album_name_post_regex:
663+
if album_name_postprocess_regex:
664+
for pattern, *repl in album_name_postprocess_regex:
662665
# If no replacement string provided, default to empty string
663666
replace = repl[0] if repl else ''
664-
album_name = re.sub(pattern, replace, album_name)
665-
logging.debug(f"Album Post Regex s/{pattern}/{replace}/g --> {album_name}")
667+
album_name = re.sub(pattern, replace, album_name)
668+
logging.debug("Album Post Regex s/%s/%s/g --> %s", pattern, replace, album_name)
666669

667670
return album_name.strip()
668671

0 commit comments

Comments
 (0)