diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 7e7b7ba..7e95a73 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,5 +1,5 @@ pytest: - image: python:3.10-alpine + image: python:3.12-alpine only: - main script: diff --git a/README.md b/README.md index 036241e..3f5a77f 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,6 @@ # AutoPicture V3 -Dies ist die dritte Version von AutoPicture. - +Bildersortierprogramm geschrieben in Python3.12. Beispiel Struktur der Sortierung: ```bash @@ -44,6 +43,14 @@ app/Bilder/ # Erste Schritte +## Python + +## Pip + +## Config + +## Starten + # Tests ```bash diff --git a/requirements.txt b/requirements.txt index 899e52b..52779a4 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,8 +1,9 @@ -pillow -python-magic -progressbar -virtualenv -requests +pillow==10.1.* +pyyaml==6.0.* +python-magic==0.4.* +progressbar==2.5 +virtualenv==20.25.* +requests==2.31.* pytest==7.4.* pytest-cov==4.1.* pytest-factoryboy==2.5.* \ No newline at end of file diff --git a/src/config.py b/src/config.py new file mode 100644 index 0000000..003cbfe --- /dev/null +++ b/src/config.py @@ -0,0 +1,14 @@ +import yaml + +config_file = "config.yml" + + +def get_config(): + with open(file=config_file, mode='r') as file: + return Config(yaml.safe_load(file)) + + +class Config: + def __init__(self, data): + self.src = data['src'] + self.dst = data['dst'] diff --git a/src/config.yml b/src/config.yml new file mode 100644 index 0000000..a0bfb57 --- /dev/null +++ b/src/config.yml @@ -0,0 +1,2 @@ +src: "../app/Temp" +dst: "../app/Bilder" \ No newline at end of file diff --git a/src/main.py b/src/main.py index e40638f..275edbf 100644 --- a/src/main.py +++ b/src/main.py @@ -1,14 +1,9 @@ import sys import logging - -from meta_data_handler import get_meta_data -from file_handler import sort_pictures -from scan_folder import * +from process import start_process sys.path.append("../") log_folder = "." -src = "../app/TempPic" -dst = "../app/Bilder" logger = logging.getLogger('AutoPicture') logger.setLevel(logging.DEBUG) @@ -16,19 +11,4 @@ handler = logging.FileHandler(filename=f'{log_folder}/AutoPicture.log', encoding handler.setFormatter(logging.Formatter('%(asctime)s|:%(message)s')) logger.addHandler(handler) - -def start_process(): - try: - exif_data = get_meta_data(images=files) - sort_pictures(images=exif_data, dst=dst, logger=logger) - except Exception as err: - print(err) - logger.error(err) - raise err - - -files = recursive_scan_folder(src) -if len(files) > 0: - start_process() -else: - print("No images found") +start_process(logger=logger) diff --git a/src/process.py b/src/process.py new file mode 100644 index 0000000..5165a82 --- /dev/null +++ b/src/process.py @@ -0,0 +1,22 @@ +import sys +sys.path.append("../") + +from src.meta_data_handler import get_meta_data +from src.file_handler import sort_pictures +from src.scan_folder import recursive_scan_folder +from src.config import get_config + + +def start_process(logger): + config = get_config() + try: + files = recursive_scan_folder(config.src) + if len(files) > 0: + exif_data = get_meta_data(images=files) + sort_pictures(images=exif_data, dst=config.dst, logger=logger) + else: + print("No images found") + except Exception as err: + print(err) + logger.error(err) + raise err diff --git a/tests/start_tests.sh b/tests/start_tests.sh index 029d838..459ec60 100755 --- a/tests/start_tests.sh +++ b/tests/start_tests.sh @@ -1,4 +1,4 @@ -python3.10 -m pytest \ +python3.12 -m pytest \ --no-header \ -rfp \ --cov \ diff --git a/tests/start_tests_gitlab.sh b/tests/start_tests_gitlab.sh index 265d5e4..7c6d6cf 100755 --- a/tests/start_tests_gitlab.sh +++ b/tests/start_tests_gitlab.sh @@ -1,9 +1,9 @@ apk add --update libmagic -pip3.10 install -r requirements.txt +pip3.12 install -r requirements.txt pwd sh tests/start_tests.sh cp tests/coverage/coverage.xml ./coverage.xml cp tests/coverage/report.xml ./report.xml -python3.10 tests/get_coverage_percent.py +python3.12 tests/get_coverage_percent.py diff --git a/tests/test_config.py b/tests/test_config.py new file mode 100644 index 0000000..dbd737a --- /dev/null +++ b/tests/test_config.py @@ -0,0 +1,6 @@ +import unittest + + +class TestConfig(unittest.TestCase): + def test_config(self): + pass diff --git a/tests/test_files/iphone_x_001.jpeg b/tests/test_files/iphone_x_001.jpeg new file mode 100644 index 0000000..ed869f2 Binary files /dev/null and b/tests/test_files/iphone_x_001.jpeg differ diff --git a/tests/test_files/iphone_x_002.jpeg b/tests/test_files/iphone_x_002.jpeg new file mode 100644 index 0000000..29d6f0c Binary files /dev/null and b/tests/test_files/iphone_x_002.jpeg differ diff --git a/tests/test_files/iphone_x_003.jpeg b/tests/test_files/iphone_x_003.jpeg new file mode 100644 index 0000000..918dd76 Binary files /dev/null and b/tests/test_files/iphone_x_003.jpeg differ diff --git a/tests/test_files/iphone_x_004.jpeg b/tests/test_files/iphone_x_004.jpeg new file mode 100644 index 0000000..5dd5d16 Binary files /dev/null and b/tests/test_files/iphone_x_004.jpeg differ diff --git a/tests/test_files/iphone_x_005.jpeg b/tests/test_files/iphone_x_005.jpeg new file mode 100644 index 0000000..cea7aa7 Binary files /dev/null and b/tests/test_files/iphone_x_005.jpeg differ diff --git a/tests/test_files/iphone_x_006.jpeg b/tests/test_files/iphone_x_006.jpeg new file mode 100644 index 0000000..5380551 Binary files /dev/null and b/tests/test_files/iphone_x_006.jpeg differ diff --git a/tests/test_process.py b/tests/test_process.py new file mode 100644 index 0000000..6cb6e7e --- /dev/null +++ b/tests/test_process.py @@ -0,0 +1,12 @@ +import unittest +from unittest.mock import Mock + +from src.process import start_process + + +@unittest.skip("") +class TestProcess(unittest.TestCase): + def test_process(self): + start_process(logger=Mock()) + +