From e5001934357123cd6c996462e4ce2a301c90665c Mon Sep 17 00:00:00 2001 From: sashacmc Date: Thu, 25 May 2023 21:27:10 +0200 Subject: [PATCH 1/2] Add python workflow and dependencies file --- .github/workflows/python.yml | 33 +++++++++++++++++++++++++++++++++ requirements.txt | 3 +++ 2 files changed, 36 insertions(+) create mode 100644 .github/workflows/python.yml create mode 100644 requirements.txt diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml new file mode 100644 index 0000000..4318799 --- /dev/null +++ b/.github/workflows/python.yml @@ -0,0 +1,33 @@ +name: Python package + +on: [push] + +jobs: + build: + + runs-on: ubuntu-latest + strategy: + matrix: + python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"] + + steps: + - uses: actions/checkout@v3 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install ruff pytest + if [ -f requirements.txt ]; then pip install -r requirements.txt; fi + sudo apt install exiftran exiftool pmount + - name: Lint with ruff + run: | + # stop the build if there are Python syntax errors or undefined names + ruff --format=github --select=E9,F63,F7,F82 --target-version=py37 . + # default set of ruff rules with GitHub Annotations + ruff --format=github --target-version=py37 . + - name: Test with pytest + run: | + pytest diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..9147e3a --- /dev/null +++ b/requirements.txt @@ -0,0 +1,3 @@ +progressbar==2.5 +psutil==5.9.5 +PyExifTool==0.5.5 From daff6acc403f1916ac7268d7d1da84249343e418 Mon Sep 17 00:00:00 2001 From: sashacmc Date: Thu, 25 May 2023 21:28:13 +0200 Subject: [PATCH 2/2] Fix import without config file and warning --- photo_importer/config.py | 12 +++++++----- photo_importer/importer.py | 2 +- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/photo_importer/config.py b/photo_importer/config.py index f608a3b..0510fe6 100755 --- a/photo_importer/config.py +++ b/photo_importer/config.py @@ -50,11 +50,13 @@ class Config(object): self.__config = configparser.ConfigParser() self.__config.read_dict(self.DEFAULTS) - self.__config.read( - [ - filename, - ] - ) + + if filename is not None: + self.__config.read( + [ + filename, + ] + ) if create: self.__create_if_not_exists() diff --git a/photo_importer/importer.py b/photo_importer/importer.py index 8b6be57..28b1d00 100755 --- a/photo_importer/importer.py +++ b/photo_importer/importer.py @@ -95,7 +95,7 @@ class Importer(threading.Thread): def __remove_empty_dirs(self, dirs): logging.info('Removing empty dirs') len_dirs = reversed(sorted([(len(d), d) for d in dirs])) - for l, d in len_dirs: + for _, d in len_dirs: try: os.rmdir(d) logging.info('Removed: %s', d)