From ee81e69eceaa5ec1356dd08b8050e20e0d7be222 Mon Sep 17 00:00:00 2001 From: Rhet Turnbull Date: Fri, 14 Jan 2022 15:02:33 -0800 Subject: [PATCH] Added dev tools --- README.md | 4 +-- docs/.buildinfo | 2 +- docs/_static/documentation_options.js | 2 +- docs/cli.html | 2 +- docs/genindex.html | 2 +- docs/index.html | 2 +- docs/modules.html | 2 +- docs/reference.html | 2 +- docs/search.html | 2 +- osxphotos/_constants.py | 2 +- osxphotos/_version.py | 2 +- osxphotos/cli.py | 42 +++++++++++++++++---------- 12 files changed, 39 insertions(+), 27 deletions(-) diff --git a/README.md b/README.md index 98cbd0f4..19b52b36 100644 --- a/README.md +++ b/README.md @@ -1720,7 +1720,7 @@ Substitution Description {lf} A line feed: '\n', alias for {newline} {cr} A carriage return: '\r' {crlf} a carriage return + line feed: '\r\n' -{osxphotos_version} The osxphotos version, e.g. '0.44.8' +{osxphotos_version} The osxphotos version, e.g. '0.44.9' {osxphotos_cmd_line} The full command line used to run osxphotos The following substitutions may result in multiple values. Thus if specified for @@ -3622,7 +3622,7 @@ The following template field substitutions are availabe for use the templating s |{lf}|A line feed: '\n', alias for {newline}| |{cr}|A carriage return: '\r'| |{crlf}|a carriage return + line feed: '\r\n'| -|{osxphotos_version}|The osxphotos version, e.g. '0.44.8'| +|{osxphotos_version}|The osxphotos version, e.g. '0.44.9'| |{osxphotos_cmd_line}|The full command line used to run osxphotos| |{album}|Album(s) photo is contained in| |{folder_album}|Folder path + album photo is contained in. e.g. 'Folder/Subfolder/Album' or just 'Album' if no enclosing folder| diff --git a/docs/.buildinfo b/docs/.buildinfo index a605847a..8e412f35 100644 --- a/docs/.buildinfo +++ b/docs/.buildinfo @@ -1,4 +1,4 @@ # Sphinx build info version 1 # This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done. -config: fff79f4920939baa44eddc90423972ec +config: 7f709983e4cb93aeb5bcc8c73a7d13f9 tags: 645f666f9bcd5a90fca523b33c5a78b7 diff --git a/docs/_static/documentation_options.js b/docs/_static/documentation_options.js index 38d01eca..d929174f 100644 --- a/docs/_static/documentation_options.js +++ b/docs/_static/documentation_options.js @@ -1,6 +1,6 @@ var DOCUMENTATION_OPTIONS = { URL_ROOT: document.getElementById("documentation_options").getAttribute('data-url_root'), - VERSION: '0.44.8', + VERSION: '0.44.9', LANGUAGE: 'None', COLLAPSE_INDEX: false, BUILDER: 'html', diff --git a/docs/cli.html b/docs/cli.html index 1601eb3a..1048582b 100644 --- a/docs/cli.html +++ b/docs/cli.html @@ -6,7 +6,7 @@ - osxphotos command line interface (CLI) — osxphotos 0.44.8 documentation + osxphotos command line interface (CLI) — osxphotos 0.44.9 documentation diff --git a/docs/genindex.html b/docs/genindex.html index 88561a8b..73305336 100644 --- a/docs/genindex.html +++ b/docs/genindex.html @@ -5,7 +5,7 @@ - Index — osxphotos 0.44.8 documentation + Index — osxphotos 0.44.9 documentation diff --git a/docs/index.html b/docs/index.html index 758a3132..30405a85 100644 --- a/docs/index.html +++ b/docs/index.html @@ -6,7 +6,7 @@ - Welcome to osxphotos’s documentation! — osxphotos 0.44.8 documentation + Welcome to osxphotos’s documentation! — osxphotos 0.44.9 documentation diff --git a/docs/modules.html b/docs/modules.html index 071b0774..ba3c3dd0 100644 --- a/docs/modules.html +++ b/docs/modules.html @@ -6,7 +6,7 @@ - osxphotos — osxphotos 0.44.8 documentation + osxphotos — osxphotos 0.44.9 documentation diff --git a/docs/reference.html b/docs/reference.html index 54ebff24..ced66c8b 100644 --- a/docs/reference.html +++ b/docs/reference.html @@ -6,7 +6,7 @@ - osxphotos package — osxphotos 0.44.8 documentation + osxphotos package — osxphotos 0.44.9 documentation diff --git a/docs/search.html b/docs/search.html index ed7702ad..4d8cde26 100644 --- a/docs/search.html +++ b/docs/search.html @@ -5,7 +5,7 @@ - Search — osxphotos 0.44.8 documentation + Search — osxphotos 0.44.9 documentation diff --git a/osxphotos/_constants.py b/osxphotos/_constants.py index bbecfac3..90f9b43f 100644 --- a/osxphotos/_constants.py +++ b/osxphotos/_constants.py @@ -42,7 +42,7 @@ _PHOTOS_5_VERSION = "5000" # I've seen both 5001 and 6000. 6000 is most common # Ranges for model version by Photos version _PHOTOS_5_MODEL_VERSION = [13000, 13999] _PHOTOS_6_MODEL_VERSION = [14000, 14999] -_PHOTOS_7_MODEL_VERSION = [15000, 15999] # Monterey developer preview is 15134 +_PHOTOS_7_MODEL_VERSION = [15000, 15999] # Monterey developer preview is 15134, 12.1 is 15331 # some table names differ between Photos 5 and Photos 6 _DB_TABLE_NAMES = { diff --git a/osxphotos/_version.py b/osxphotos/_version.py index bc5c810c..6f9b6215 100644 --- a/osxphotos/_version.py +++ b/osxphotos/_version.py @@ -1,3 +1,3 @@ """ version info """ -__version__ = "0.44.8" +__version__ = "0.44.9" diff --git a/osxphotos/cli.py b/osxphotos/cli.py index 344df470..009224cb 100644 --- a/osxphotos/cli.py +++ b/osxphotos/cli.py @@ -4361,12 +4361,12 @@ def debug_dump(ctx, cli_obj, db, photos_library, dump, uuid, verbose): print(f"Did not find attribute {attr} in PhotosDB") -@cli.command(name="snap", hidden=True) +@cli.command(name="snap") @click.pass_obj @click.pass_context @DB_OPTION def snap(ctx, cli_obj, db): - """Create a snapshot of a Photos library database for use with `osxphotos diff` + """Create snapshot of Photos database to use with diff command Snapshots only the database files, not the entire library. If OSXPHOTOS_SNAPSHOT environment variable is defined, will use that as snapshot directory, otherwise @@ -4403,7 +4403,7 @@ def snap(ctx, cli_obj, db): print(f"Copied {count} files from {db_path} to {destination_path}") -@cli.command(name="diff", hidden=True) +@cli.command(name="diff") @click.pass_obj @click.pass_context @DB_OPTION @@ -4414,10 +4414,20 @@ def snap(ctx, cli_obj, db): default=False, help="Print raw output (don't use syntax highlighting).", ) +@click.option( + "--style", + "-s", + metavar="STYLE", + nargs=1, + default="monokai", + help = "Specify style/theme for syntax highlighting. " + "Theme may be any valid pygments style (https://pygments.org/styles/). " + "Default is 'monokai'.", +) @click.argument("db2", nargs=-1, type=click.Path(exists=True)) @click.option("--verbose", "-V", "verbose", is_flag=True, help="Print verbose output.") -def diff(ctx, cli_obj, db, raw_output, db2, verbose): - """Compares two Photos libraries and prints out differences +def diff(ctx, cli_obj, db, raw_output, style, db2, verbose): + """Compare two Photos databases and print out differences To use the diff command, you'll need to install sqldiff via homebrew: @@ -4444,7 +4454,7 @@ def diff(ctx, cli_obj, db, raw_output, db2, verbose): Works only on Photos library versions since Catalina (10.15) or newer. """ - + global VERBOSE VERBOSE = bool(verbose) @@ -4481,12 +4491,14 @@ def diff(ctx, cli_obj, db, raw_output, db2, verbose): verbose_(f"Comparing databases {db_1} and {db_2}") - output = os.popen(f"{sqldiff} {db_2} {db_1}").read() - if raw_output: - print(output) - else: - syntax = Syntax( - output, "sql", theme="monokai", line_numbers=False, code_width=1000 - ) - console = Console() - console.print(syntax) + diff_proc = subprocess.Popen([sqldiff, db_2, db_1], stdout=subprocess.PIPE) + console = Console() + for line in iter(diff_proc.stdout.readline, b""): + line = line.decode("UTF-8").rstrip() + if raw_output: + print(line) + else: + syntax = Syntax( + line, "sql", theme=style, line_numbers=False, code_width=1000 + ) + console.print(syntax)