Merge branch 'develop' into 'main'

Develop

See merge request DasMoorhuhn/autopicture-v3!5
This commit is contained in:
2023-12-15 00:12:53 +00:00
17 changed files with 77 additions and 33 deletions

View File

@@ -1,5 +1,5 @@
pytest:
image: python:3.10-alpine
image: python:3.12-alpine
only:
- main
script:

View File

@@ -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

View File

@@ -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.*

14
src/config.py Normal file
View File

@@ -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']

2
src/config.yml Normal file
View File

@@ -0,0 +1,2 @@
src: "../app/Temp"
dst: "../app/Bilder"

View File

@@ -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)

22
src/process.py Normal file
View File

@@ -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

View File

@@ -1,4 +1,4 @@
python3.10 -m pytest \
python3.12 -m pytest \
--no-header \
-rfp \
--cov \

View File

@@ -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

6
tests/test_config.py Normal file
View File

@@ -0,0 +1,6 @@
import unittest
class TestConfig(unittest.TestCase):
def test_config(self):
pass

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

12
tests/test_process.py Normal file
View File

@@ -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())