Skip to content

Commit

Permalink
Importapalooza (#1560)
Browse files Browse the repository at this point in the history
* Working on import fixes

* Working on --check

* More work on import check

* Got import check working

* Initial refactor of --check-not

* Working on import code

* Tests passing for import

* Fixed reporting for import

* Fixes #1470, apply sidecar to _edited photos, adds --edited-suffix

* Implements #1373, --favorite-rating

* Updated docs

* Implemented --auto-live, #1399

* Normalizes unicode for album names, #1475

* Added height, width to PhotoInfoFromFile

* Updated test names

* Adds --signature to import, #1374

* Fix test for linux

* Implements PR #1486

* Allow import to accept files or directories as argument

* Fixed error with files_or_dirs

* Added export_directory table

* ExportDB updates to allow reading last export path

* Added --runs to exportdb, updated exportdb tests

* Added photoinfo_from_dict

* Added photoinfo_from_dict tests

* Added --exportdb to import

* Stage files that need modification, added tests

* Refactoring for maintainability

* Refactoring for maintainability

* Refactoring for maintainability

* Changed verbose level

* Fix for files with same stemp when --auto-live is not used

* Handled edited version w/o AAE

* removed print statemetns

* Updated check, check not

* Added tests for importing edited versions

* Refactored to move import_cli code first in file

* Working on _edited photos

* Import of edited files now working

* Updated content_tree to fallback to mdls if needed

* Fixed image_file_utils for non-Spotlight volumes

* Fixed image_file_utils for non-Spotlight volumes

* Removed unneeded imports

* Tests passing for renamed edited photos

* Initial tests for import CLI utils

* Initial tests for import CLI utils

* Fixed regex for finding original / edited images

* Typo (my bad!) on GoPro Pics filename standards. (#1551)

* Added test images for import tests

* Fix for edited live photos

* Fixed skip if not macOS

* Added test for edited live photo

* Added clarification for --resume, --skip-dups, #802

* Fix for certain edited live photos

* Reset counter

* Added --exportdir

* Fixed help formatting

---------

Co-authored-by: oPromessa <[email protected]>
  • Loading branch information
RhetTbull and oPromessa authored Jun 8, 2024
1 parent b8c5987 commit 38d9bdb
Show file tree
Hide file tree
Showing 76 changed files with 5,966 additions and 1,916 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ docsrc/_build/
venv/
.python-version
cov.xml
pyrightconfig.json
6 changes: 3 additions & 3 deletions examples/new_text.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ def new_text(photos: list[osxphotos.PhotoInfo], **kwargs):
"photo": photo.original_filename,
"path": photo.path,
"uuid": photo.uuid,
"date_added": photo.date_added.isoformat()
if photo.date_added
else None,
"date_added": (
photo.date_added.isoformat() if photo.date_added else None
),
"text": text,
}
results.append(data)
Expand Down
1 change: 1 addition & 0 deletions examples/simple_example.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
""" Simple usage of the package """

import os.path

import osxphotos
Expand Down
1 change: 0 additions & 1 deletion osxphotos/cli/cli_params.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""Common options & parameters for osxphotos CLI commands"""


from __future__ import annotations

import contextlib
Expand Down
49 changes: 44 additions & 5 deletions osxphotos/cli/exportdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@
export_db_check_signatures,
export_db_get_about,
export_db_get_errors,
export_db_get_last_export_dir,
export_db_get_last_library,
export_db_get_last_run,
export_db_get_runs,
export_db_get_version,
export_db_migrate_photos_library,
export_db_save_config_to_file,
Expand Down Expand Up @@ -69,10 +71,18 @@
is_flag=True,
help="Touch files on disk to match created date in Photos library and update export database signatures",
)
@click.option(
"--runs",
is_flag=True,
help="List osxphotos commands used with this database. See also --last-run.",
)
@click.option(
"--last-run",
is_flag=True,
help="Show last run osxphotos commands used with this database.",
help="Show last run osxphotos commands used with this database. See also --runs.",
)
@click.option(
"--last-export-dir", is_flag=True, help="Print path to last used export directory"
)
@click.option(
"--save-config",
Expand Down Expand Up @@ -192,7 +202,7 @@
is_flag=True,
help="Run in dry-run mode (don't actually update files); for example, use with --update-signatures or --migrate-photos-library.",
)
@click.argument("export_db", metavar="EXPORT_DATABASE", type=click.Path(exists=True))
@click.argument("export_db", metavar="EXPORT_DATABASE", type=click.Path())
def exportdb(
append,
check,
Expand All @@ -204,10 +214,12 @@ def exportdb(
info,
errors,
last_errors,
last_export_dir,
last_run,
migrate_photos_library,
repair,
report,
runs,
save_config,
sql,
theme,
Expand Down Expand Up @@ -255,9 +267,11 @@ def exportdb(
create,
info,
last_run,
last_export_dir,
upgrade,
repair,
report,
runs,
save_config,
sql,
touch_file,
Expand Down Expand Up @@ -303,7 +317,7 @@ def exportdb(
)
sys.exit(1)

if not "4.3" <= create <= OSXPHOTOS_EXPORTDB_VERSION:
if not float("4.3") <= float(create) <= float(OSXPHOTOS_EXPORTDB_VERSION):
rich_echo_error(
f"[error]Error: invalid version number {create}: must be between >= 4.3, <= {OSXPHOTOS_EXPORTDB_VERSION}[/]"
)
Expand Down Expand Up @@ -366,6 +380,17 @@ def exportdb(
)
sys.exit(0)

if runs:
try:
run_info = export_db_get_runs(export_db)
except Exception as e:
rich_echo_error(f"[error]Error: {e}[/error]")
sys.exit(1)
else:
for run in run_info:
rich_echo(f"[time]{run[0]}[/]: {run[1]} {run[2]}")
sys.exit(0)

if last_run:
try:
last_run_info = export_db_get_last_run(export_db)
Expand All @@ -374,9 +399,23 @@ def exportdb(
sys.exit(1)
else:
rich_echo(f"last run at [time]{last_run_info[0]}:")
rich_echo(f"osxphotos {last_run_info[1]}")
rich_echo(f"{last_run_info[1]}")
sys.exit(0)

if last_export_dir:
try:
last_path = export_db_get_last_export_dir(export_db)
except Exception as e:
rich_echo_error(f"[error]Error: {e}[/error]")
sys.exit(1)
else:
if last_path:
rich_echo(f"[filepath]{last_path}[/]")
sys.exit(0)
else:
rich_echo(f"No last export directory found")
sys.exit(1)

if save_config:
try:
export_db_save_config_to_file(export_db, save_config)
Expand Down Expand Up @@ -590,7 +629,7 @@ def exportdb(
rich_echo(
dedent(
f"""
[warning]:warning-emoji: This command will update your export database ([filepath]{export_db}[/])
[warning]:warning-emoji: This command will update your export database ([filepath]{export_db}[/])
to use [filepath]{migrate_photos_library}[/] as the new source library.
The last library used was [filepath]{last_library}[/].
This will allow you to use the export database with the new library but it will
Expand Down
Loading

0 comments on commit 38d9bdb

Please sign in to comment.