Merge branch 'develop' into 'main'
Develop See merge request DasMoorhuhn/autopicture-v3!5
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
pytest:
|
pytest:
|
||||||
image: python:3.10-alpine
|
image: python:3.12-alpine
|
||||||
only:
|
only:
|
||||||
- main
|
- main
|
||||||
script:
|
script:
|
||||||
|
|||||||
11
README.md
11
README.md
@@ -1,7 +1,6 @@
|
|||||||
# AutoPicture V3
|
# AutoPicture V3
|
||||||
|
|
||||||
Dies ist die dritte Version von AutoPicture.
|
Bildersortierprogramm geschrieben in Python3.12.
|
||||||
|
|
||||||
|
|
||||||
Beispiel Struktur der Sortierung:
|
Beispiel Struktur der Sortierung:
|
||||||
```bash
|
```bash
|
||||||
@@ -44,6 +43,14 @@ app/Bilder/
|
|||||||
|
|
||||||
# Erste Schritte
|
# Erste Schritte
|
||||||
|
|
||||||
|
## Python
|
||||||
|
|
||||||
|
## Pip
|
||||||
|
|
||||||
|
## Config
|
||||||
|
|
||||||
|
## Starten
|
||||||
|
|
||||||
# Tests
|
# Tests
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
pillow
|
pillow==10.1.*
|
||||||
python-magic
|
pyyaml==6.0.*
|
||||||
progressbar
|
python-magic==0.4.*
|
||||||
virtualenv
|
progressbar==2.5
|
||||||
requests
|
virtualenv==20.25.*
|
||||||
|
requests==2.31.*
|
||||||
pytest==7.4.*
|
pytest==7.4.*
|
||||||
pytest-cov==4.1.*
|
pytest-cov==4.1.*
|
||||||
pytest-factoryboy==2.5.*
|
pytest-factoryboy==2.5.*
|
||||||
14
src/config.py
Normal file
14
src/config.py
Normal 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
2
src/config.yml
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
src: "../app/Temp"
|
||||||
|
dst: "../app/Bilder"
|
||||||
24
src/main.py
24
src/main.py
@@ -1,14 +1,9 @@
|
|||||||
import sys
|
import sys
|
||||||
import logging
|
import logging
|
||||||
|
from process import start_process
|
||||||
from meta_data_handler import get_meta_data
|
|
||||||
from file_handler import sort_pictures
|
|
||||||
from scan_folder import *
|
|
||||||
|
|
||||||
sys.path.append("../")
|
sys.path.append("../")
|
||||||
log_folder = "."
|
log_folder = "."
|
||||||
src = "../app/TempPic"
|
|
||||||
dst = "../app/Bilder"
|
|
||||||
|
|
||||||
logger = logging.getLogger('AutoPicture')
|
logger = logging.getLogger('AutoPicture')
|
||||||
logger.setLevel(logging.DEBUG)
|
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'))
|
handler.setFormatter(logging.Formatter('%(asctime)s|:%(message)s'))
|
||||||
logger.addHandler(handler)
|
logger.addHandler(handler)
|
||||||
|
|
||||||
|
start_process(logger=logger)
|
||||||
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")
|
|
||||||
|
|||||||
22
src/process.py
Normal file
22
src/process.py
Normal 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
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
python3.10 -m pytest \
|
python3.12 -m pytest \
|
||||||
--no-header \
|
--no-header \
|
||||||
-rfp \
|
-rfp \
|
||||||
--cov \
|
--cov \
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
apk add --update libmagic
|
apk add --update libmagic
|
||||||
pip3.10 install -r requirements.txt
|
pip3.12 install -r requirements.txt
|
||||||
pwd
|
pwd
|
||||||
sh tests/start_tests.sh
|
sh tests/start_tests.sh
|
||||||
|
|
||||||
cp tests/coverage/coverage.xml ./coverage.xml
|
cp tests/coverage/coverage.xml ./coverage.xml
|
||||||
cp tests/coverage/report.xml ./report.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
6
tests/test_config.py
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
import unittest
|
||||||
|
|
||||||
|
|
||||||
|
class TestConfig(unittest.TestCase):
|
||||||
|
def test_config(self):
|
||||||
|
pass
|
||||||
BIN
tests/test_files/iphone_x_001.jpeg
Normal file
BIN
tests/test_files/iphone_x_001.jpeg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.9 KiB |
BIN
tests/test_files/iphone_x_002.jpeg
Normal file
BIN
tests/test_files/iphone_x_002.jpeg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.9 KiB |
BIN
tests/test_files/iphone_x_003.jpeg
Normal file
BIN
tests/test_files/iphone_x_003.jpeg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.1 KiB |
BIN
tests/test_files/iphone_x_004.jpeg
Normal file
BIN
tests/test_files/iphone_x_004.jpeg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.0 KiB |
BIN
tests/test_files/iphone_x_005.jpeg
Normal file
BIN
tests/test_files/iphone_x_005.jpeg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.0 KiB |
BIN
tests/test_files/iphone_x_006.jpeg
Normal file
BIN
tests/test_files/iphone_x_006.jpeg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.9 KiB |
12
tests/test_process.py
Normal file
12
tests/test_process.py
Normal 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())
|
||||||
|
|
||||||
|
|
||||||
Reference in New Issue
Block a user