CLI refactor (#642)

* Initial refactoring of cli.py

* Renamed cli_help

* Refactored all cli commands

* Dropped support for 3.7

* Added test for export with --min-size

* Version bump

* Fixed python version
This commit is contained in:
Rhet Turnbull
2022-02-26 22:29:19 -08:00
committed by GitHub
parent 3704fc4a23
commit 25d6f148be
40 changed files with 2951 additions and 3808 deletions

View File

@@ -3,10 +3,9 @@ import os
import pathlib
import pytest
from applescript import AppleScript
from photoscript.utils import ditto
import osxphotos
from applescript import AppleScript
from osxphotos.exiftool import _ExifToolProc
@@ -124,3 +123,12 @@ def copy_photos_library_to_path(photos_library_path: str, dest_path: str) -> str
"""Copy a photos library to a folder"""
ditto(photos_library_path, dest_path)
return dest_path
@pytest.fixture(scope="session", autouse=True)
def delete_crash_logs():
"""Delete left over crash logs from tests that were supposed to crash"""
yield
path = pathlib.Path(os.getcwd()) / "osxphotos_crash.log"
if path.is_file():
path.unlink()

View File

@@ -1,25 +0,0 @@
import re
import sys
from os import walk
from collections import Counter
FILE_PATTERN = "^(?!_).*\.py$"
SOUCE_CODE_ROOT = "osxphotos"
def create_module_name(dirpath: str, filename: str) -> str:
prefix = dirpath[dirpath.rfind(SOUCE_CODE_ROOT):].replace('/', '.')
return f"{prefix}.{filename}".replace(".py", "")
def test_check_duplicate():
for dirpath, dirnames, filenames in walk(SOUCE_CODE_ROOT):
print("\n", sys.modules)
for filename in filenames:
if re.search(FILE_PATTERN, filename):
module = create_module_name(dirpath, filename)
if module in sys.modules:
all_list = sys.modules[module].__all__
all_set = set(all_list)
assert Counter(all_list) == Counter(all_set)

View File

@@ -1408,7 +1408,6 @@ def test_exiftool_newlines_in_description(photosdb):
@pytest.mark.skip(reason="Test not yet implemented")
def test_duplicates_1(photosdb):
# test photo has duplicates
photo = photosdb.get_photo(uuid=UUID_DICT["duplicates"])
assert len(photo.duplicates) == 1
assert photo.duplicates[0].uuid == UUID_DUPLICATE

File diff suppressed because it is too large Load Diff