Improve photo organization controls and reference completion
This commit is contained in:
1 parent
ad2b15994f
commit
e3633b8e1a
6 files changed
+316
-41
No files matched your search
Regular → Executable
+17
-8
@@ -18,6 +18,7 @@ import sys
|
||||
from tools.console import (
|
||||
ProgressView,
|
||||
clear_screen,
|
||||
launch_terminal_if_needed,
|
||||
pause_if_interactive,
|
||||
prompt_yes_no as ask_yes_no,
|
||||
)
|
||||
@@ -34,24 +35,30 @@ from tools.filesystem import (
|
||||
cleanup_roots_from_args,
|
||||
collect_files,
|
||||
determine_working_dir,
|
||||
input_paths,
|
||||
remove_empty_dirs,
|
||||
)
|
||||
|
||||
|
||||
def run(argv: list[str]) -> int:
|
||||
if len(argv) < 2:
|
||||
print("Usage: python3 photo_metadata.py path/to/file/or/directory [...]")
|
||||
return 2
|
||||
try:
|
||||
args = input_paths(argv)
|
||||
except RuntimeError as exc:
|
||||
print(exc)
|
||||
return 1
|
||||
if not args:
|
||||
print("No inputs selected.")
|
||||
return 0
|
||||
|
||||
try:
|
||||
working_dir = determine_working_dir(argv[1:])
|
||||
working_dir = determine_working_dir(args)
|
||||
except RuntimeError as exc:
|
||||
print(exc)
|
||||
return 1
|
||||
|
||||
cleanup_roots = cleanup_roots_from_args(argv[1:])
|
||||
files = collect_files(argv[1:], allowed_exts=SUPPORTED_EXTS, print_missing=True)
|
||||
pto_files = collect_files(argv[1:], allowed_exts={".pto"})
|
||||
cleanup_roots = cleanup_roots_from_args(args)
|
||||
files = collect_files(args, allowed_exts=SUPPORTED_EXTS, print_missing=True)
|
||||
pto_files = collect_files(args, allowed_exts={".pto"})
|
||||
if not files:
|
||||
print("No supported media files found.")
|
||||
return 1
|
||||
@@ -112,7 +119,7 @@ def run(argv: list[str]) -> int:
|
||||
|
||||
failures = apply_changes(exiftool, records, choices)
|
||||
failures.extend(apply_pto_changes(pto_plans))
|
||||
removed_dirs = remove_empty_dirs(cleanup_roots, keep_dirs={working_dir.resolve()})
|
||||
removed_dirs = remove_empty_dirs(cleanup_roots, keep_dirs={choices.working_dir.resolve()})
|
||||
print_removed_dirs(removed_dirs)
|
||||
|
||||
if failures:
|
||||
@@ -126,6 +133,8 @@ def run(argv: list[str]) -> int:
|
||||
|
||||
|
||||
def main(argv: list[str]) -> int:
|
||||
if launch_terminal_if_needed(argv):
|
||||
return 0
|
||||
try:
|
||||
return run(argv)
|
||||
finally:
|
||||
|
||||
Reference in new issue
Block a user