Fix for #515, updated tests
This commit is contained in:
@@ -1702,7 +1702,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.42.80'
|
||||
{osxphotos_version} The osxphotos version, e.g. '0.42.82'
|
||||
{osxphotos_cmd_line} The full command line used to run osxphotos
|
||||
|
||||
The following substitutions may result in multiple values. Thus if specified for
|
||||
@@ -3561,7 +3561,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.42.80'|
|
||||
|{osxphotos_version}|The osxphotos version, e.g. '0.42.82'|
|
||||
|{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|
|
||||
|
||||
@@ -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: dd9bfb6ffa88332ee840ad3af2dd7f37
|
||||
config: 7fc4fe26df020008d210765b32b7a1a9
|
||||
tags: 645f666f9bcd5a90fca523b33c5a78b7
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Overview: module code — osxphotos 0.42.80 documentation</title>
|
||||
<title>Overview: module code — osxphotos 0.42.82 documentation</title>
|
||||
<link rel="stylesheet" type="text/css" href="../_static/pygments.css" />
|
||||
<link rel="stylesheet" type="text/css" href="../_static/alabaster.css" />
|
||||
<script data-url_root="../" id="documentation_options" src="../_static/documentation_options.js"></script>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>osxphotos.photoinfo._photoinfo_export — osxphotos 0.42.80 documentation</title>
|
||||
<title>osxphotos.photoinfo._photoinfo_export — osxphotos 0.42.82 documentation</title>
|
||||
<link rel="stylesheet" type="text/css" href="../../../_static/pygments.css" />
|
||||
<link rel="stylesheet" type="text/css" href="../../../_static/alabaster.css" />
|
||||
<script data-url_root="../../../" id="documentation_options" src="../../../_static/documentation_options.js"></script>
|
||||
@@ -89,7 +89,7 @@
|
||||
<span class="p">)</span>
|
||||
<span class="kn">from</span> <span class="nn">..phototemplate</span> <span class="kn">import</span> <span class="n">RenderOptions</span>
|
||||
<span class="kn">from</span> <span class="nn">..uti</span> <span class="kn">import</span> <span class="n">get_preferred_uti_extension</span>
|
||||
<span class="kn">from</span> <span class="nn">..utils</span> <span class="kn">import</span> <span class="n">findfiles</span><span class="p">,</span> <span class="n">lineno</span><span class="p">,</span> <span class="n">noop</span>
|
||||
<span class="kn">from</span> <span class="nn">..utils</span> <span class="kn">import</span> <span class="n">findfiles</span><span class="p">,</span> <span class="n">lineno</span><span class="p">,</span> <span class="n">noop</span><span class="p">,</span> <span class="n">normalize_fs_path</span>
|
||||
|
||||
<span class="c1"># retry if use_photos_export fails the first time (which sometimes it does)</span>
|
||||
<span class="n">MAX_PHOTOSCRIPT_RETRIES</span> <span class="o">=</span> <span class="mi">3</span>
|
||||
@@ -719,9 +719,12 @@
|
||||
<span class="n">count</span> <span class="o">=</span> <span class="mi">0</span>
|
||||
<span class="k">if</span> <span class="ow">not</span> <span class="n">update</span> <span class="ow">and</span> <span class="n">increment</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">overwrite</span><span class="p">:</span>
|
||||
<span class="n">dest_files</span> <span class="o">=</span> <span class="n">findfiles</span><span class="p">(</span><span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">dest_original</span><span class="o">.</span><span class="n">stem</span><span class="si">}</span><span class="s2">*"</span><span class="p">,</span> <span class="nb">str</span><span class="p">(</span><span class="n">dest_original</span><span class="o">.</span><span class="n">parent</span><span class="p">))</span>
|
||||
<span class="n">dest_files</span> <span class="o">=</span> <span class="p">[</span><span class="n">pathlib</span><span class="o">.</span><span class="n">Path</span><span class="p">(</span><span class="n">f</span><span class="p">)</span><span class="o">.</span><span class="n">stem</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span> <span class="k">for</span> <span class="n">f</span> <span class="ow">in</span> <span class="n">dest_files</span><span class="p">]</span>
|
||||
<span class="c1"># paths need to be normalized for unicode as filesystem returns unicode in NFD form</span>
|
||||
<span class="n">dest_files</span> <span class="o">=</span> <span class="p">[</span>
|
||||
<span class="n">normalize_fs_path</span><span class="p">(</span><span class="n">pathlib</span><span class="o">.</span><span class="n">Path</span><span class="p">(</span><span class="n">f</span><span class="p">)</span><span class="o">.</span><span class="n">stem</span><span class="o">.</span><span class="n">lower</span><span class="p">())</span> <span class="k">for</span> <span class="n">f</span> <span class="ow">in</span> <span class="n">dest_files</span>
|
||||
<span class="p">]</span>
|
||||
<span class="n">dest_new</span> <span class="o">=</span> <span class="n">dest_original</span><span class="o">.</span><span class="n">stem</span>
|
||||
<span class="k">while</span> <span class="n">dest_new</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span> <span class="ow">in</span> <span class="n">dest_files</span><span class="p">:</span>
|
||||
<span class="k">while</span> <span class="n">normalize_fs_path</span><span class="p">(</span><span class="n">dest_new</span><span class="o">.</span><span class="n">lower</span><span class="p">())</span> <span class="ow">in</span> <span class="n">dest_files</span><span class="p">:</span>
|
||||
<span class="n">count</span> <span class="o">+=</span> <span class="mi">1</span>
|
||||
<span class="n">dest_new</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">dest_original</span><span class="o">.</span><span class="n">stem</span><span class="si">}</span><span class="s2"> (</span><span class="si">{</span><span class="n">count</span><span class="si">}</span><span class="s2">)"</span>
|
||||
<span class="n">dest_original</span> <span class="o">=</span> <span class="n">dest_original</span><span class="o">.</span><span class="n">parent</span> <span class="o">/</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">dest_new</span><span class="si">}{</span><span class="n">dest_original</span><span class="o">.</span><span class="n">suffix</span><span class="si">}</span><span class="s2">"</span>
|
||||
@@ -741,12 +744,15 @@
|
||||
<span class="k">if</span> <span class="n">export_edited</span><span class="p">:</span>
|
||||
<span class="k">if</span> <span class="ow">not</span> <span class="n">update</span> <span class="ow">and</span> <span class="n">increment</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">overwrite</span><span class="p">:</span>
|
||||
<span class="n">dest_files</span> <span class="o">=</span> <span class="n">findfiles</span><span class="p">(</span><span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">dest_edited</span><span class="o">.</span><span class="n">stem</span><span class="si">}</span><span class="s2">*"</span><span class="p">,</span> <span class="nb">str</span><span class="p">(</span><span class="n">dest_edited</span><span class="o">.</span><span class="n">parent</span><span class="p">))</span>
|
||||
<span class="n">dest_files</span> <span class="o">=</span> <span class="p">[</span><span class="n">pathlib</span><span class="o">.</span><span class="n">Path</span><span class="p">(</span><span class="n">f</span><span class="p">)</span><span class="o">.</span><span class="n">stem</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span> <span class="k">for</span> <span class="n">f</span> <span class="ow">in</span> <span class="n">dest_files</span><span class="p">]</span>
|
||||
<span class="c1"># paths need to be normalized for unicode as filesystem returns unicode in NFD form</span>
|
||||
<span class="n">dest_files</span> <span class="o">=</span> <span class="p">[</span>
|
||||
<span class="n">normalize_fs_path</span><span class="p">(</span><span class="n">pathlib</span><span class="o">.</span><span class="n">Path</span><span class="p">(</span><span class="n">f</span><span class="p">)</span><span class="o">.</span><span class="n">stem</span><span class="o">.</span><span class="n">lower</span><span class="p">())</span> <span class="k">for</span> <span class="n">f</span> <span class="ow">in</span> <span class="n">dest_files</span>
|
||||
<span class="p">]</span>
|
||||
<span class="n">dest_new</span> <span class="o">=</span> <span class="n">dest_edited</span><span class="o">.</span><span class="n">stem</span>
|
||||
<span class="k">if</span> <span class="n">count</span><span class="p">:</span>
|
||||
<span class="c1"># incremented above when checking original destination</span>
|
||||
<span class="n">dest_new</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">dest_new</span><span class="si">}</span><span class="s2"> (</span><span class="si">{</span><span class="n">count</span><span class="si">}</span><span class="s2">)"</span>
|
||||
<span class="k">while</span> <span class="n">dest_new</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span> <span class="ow">in</span> <span class="n">dest_files</span><span class="p">:</span>
|
||||
<span class="k">while</span> <span class="n">normalize_fs_path</span><span class="p">(</span><span class="n">dest_new</span><span class="o">.</span><span class="n">lower</span><span class="p">())</span> <span class="ow">in</span> <span class="n">dest_files</span><span class="p">:</span>
|
||||
<span class="n">count</span> <span class="o">+=</span> <span class="mi">1</span>
|
||||
<span class="n">dest_new</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">dest</span><span class="o">.</span><span class="n">stem</span><span class="si">}</span><span class="s2"> (</span><span class="si">{</span><span class="n">count</span><span class="si">}</span><span class="s2">)"</span>
|
||||
<span class="n">dest_edited</span> <span class="o">=</span> <span class="n">dest_edited</span><span class="o">.</span><span class="n">parent</span> <span class="o">/</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">dest_new</span><span class="si">}{</span><span class="n">dest_edited</span><span class="o">.</span><span class="n">suffix</span><span class="si">}</span><span class="s2">"</span>
|
||||
@@ -864,13 +870,18 @@
|
||||
<span class="n">count</span> <span class="o">=</span> <span class="mi">1</span>
|
||||
<span class="n">glob_str</span> <span class="o">=</span> <span class="nb">str</span><span class="p">(</span><span class="n">dest</span><span class="o">.</span><span class="n">parent</span> <span class="o">/</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">dest</span><span class="o">.</span><span class="n">stem</span><span class="si">}</span><span class="s2">*"</span><span class="p">)</span>
|
||||
<span class="n">dest_files</span> <span class="o">=</span> <span class="n">glob</span><span class="o">.</span><span class="n">glob</span><span class="p">(</span><span class="n">glob_str</span><span class="p">)</span>
|
||||
<span class="n">dest_files</span> <span class="o">=</span> <span class="p">[</span><span class="n">pathlib</span><span class="o">.</span><span class="n">Path</span><span class="p">(</span><span class="n">f</span><span class="p">)</span><span class="o">.</span><span class="n">stem</span> <span class="k">for</span> <span class="n">f</span> <span class="ow">in</span> <span class="n">dest_files</span><span class="p">]</span>
|
||||
<span class="n">dest_files</span> <span class="o">=</span> <span class="p">[</span><span class="n">normalize_fs_path</span><span class="p">(</span><span class="n">pathlib</span><span class="o">.</span><span class="n">Path</span><span class="p">(</span><span class="n">f</span><span class="p">)</span><span class="o">.</span><span class="n">stem</span><span class="p">)</span> <span class="k">for</span> <span class="n">f</span> <span class="ow">in</span> <span class="n">dest_files</span><span class="p">]</span>
|
||||
<span class="n">dest_new</span> <span class="o">=</span> <span class="n">dest</span><span class="o">.</span><span class="n">stem</span>
|
||||
<span class="k">while</span> <span class="n">dest_new</span> <span class="ow">in</span> <span class="n">dest_files</span><span class="p">:</span>
|
||||
<span class="k">while</span> <span class="n">normalize_fs_path</span><span class="p">(</span><span class="n">dest_new</span><span class="p">)</span> <span class="ow">in</span> <span class="n">dest_files</span><span class="p">:</span>
|
||||
<span class="n">dest_new</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">dest</span><span class="o">.</span><span class="n">stem</span><span class="si">}</span><span class="s2"> (</span><span class="si">{</span><span class="n">count</span><span class="si">}</span><span class="s2">)"</span>
|
||||
<span class="n">count</span> <span class="o">+=</span> <span class="mi">1</span>
|
||||
<span class="n">dest</span> <span class="o">=</span> <span class="n">dest</span><span class="o">.</span><span class="n">parent</span> <span class="o">/</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">dest_new</span><span class="si">}{</span><span class="n">dest</span><span class="o">.</span><span class="n">suffix</span><span class="si">}</span><span class="s2">"</span>
|
||||
|
||||
<span class="k">if</span> <span class="n">export_original</span><span class="p">:</span>
|
||||
<span class="n">dest_original</span> <span class="o">=</span> <span class="n">dest</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="n">dest_edited</span> <span class="o">=</span> <span class="n">dest</span>
|
||||
|
||||
<span class="c1"># export the dest file</span>
|
||||
<span class="n">results</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_export_photo</span><span class="p">(</span>
|
||||
<span class="n">src</span><span class="p">,</span>
|
||||
|
||||
2
docs/_static/documentation_options.js
vendored
2
docs/_static/documentation_options.js
vendored
@@ -1,6 +1,6 @@
|
||||
var DOCUMENTATION_OPTIONS = {
|
||||
URL_ROOT: document.getElementById("documentation_options").getAttribute('data-url_root'),
|
||||
VERSION: '0.42.80',
|
||||
VERSION: '0.42.82',
|
||||
LANGUAGE: 'None',
|
||||
COLLAPSE_INDEX: false,
|
||||
BUILDER: 'html',
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>osxphotos command line interface (CLI) — osxphotos 0.42.80 documentation</title>
|
||||
<title>osxphotos command line interface (CLI) — osxphotos 0.42.82 documentation</title>
|
||||
<link rel="stylesheet" type="text/css" href="_static/pygments.css" />
|
||||
<link rel="stylesheet" type="text/css" href="_static/alabaster.css" />
|
||||
<script data-url_root="./" id="documentation_options" src="_static/documentation_options.js"></script>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Index — osxphotos 0.42.80 documentation</title>
|
||||
<title>Index — osxphotos 0.42.82 documentation</title>
|
||||
<link rel="stylesheet" type="text/css" href="_static/pygments.css" />
|
||||
<link rel="stylesheet" type="text/css" href="_static/alabaster.css" />
|
||||
<script data-url_root="./" id="documentation_options" src="_static/documentation_options.js"></script>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Welcome to osxphotos’s documentation! — osxphotos 0.42.80 documentation</title>
|
||||
<title>Welcome to osxphotos’s documentation! — osxphotos 0.42.82 documentation</title>
|
||||
<link rel="stylesheet" type="text/css" href="_static/pygments.css" />
|
||||
<link rel="stylesheet" type="text/css" href="_static/alabaster.css" />
|
||||
<script data-url_root="./" id="documentation_options" src="_static/documentation_options.js"></script>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>osxphotos — osxphotos 0.42.80 documentation</title>
|
||||
<title>osxphotos — osxphotos 0.42.82 documentation</title>
|
||||
<link rel="stylesheet" type="text/css" href="_static/pygments.css" />
|
||||
<link rel="stylesheet" type="text/css" href="_static/alabaster.css" />
|
||||
<script data-url_root="./" id="documentation_options" src="_static/documentation_options.js"></script>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>osxphotos package — osxphotos 0.42.80 documentation</title>
|
||||
<title>osxphotos package — osxphotos 0.42.82 documentation</title>
|
||||
<link rel="stylesheet" type="text/css" href="_static/pygments.css" />
|
||||
<link rel="stylesheet" type="text/css" href="_static/alabaster.css" />
|
||||
<script data-url_root="./" id="documentation_options" src="_static/documentation_options.js"></script>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Search — osxphotos 0.42.80 documentation</title>
|
||||
<title>Search — osxphotos 0.42.82 documentation</title>
|
||||
<link rel="stylesheet" type="text/css" href="_static/pygments.css" />
|
||||
<link rel="stylesheet" type="text/css" href="_static/alabaster.css" />
|
||||
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
""" version info """
|
||||
|
||||
__version__ = "0.42.81"
|
||||
__version__ = "0.42.82"
|
||||
|
||||
@@ -837,13 +837,18 @@ def export2(
|
||||
count = 1
|
||||
glob_str = str(dest.parent / f"{dest.stem}*")
|
||||
dest_files = glob.glob(glob_str)
|
||||
dest_files = [pathlib.Path(f).stem for f in dest_files]
|
||||
dest_files = [normalize_fs_path(pathlib.Path(f).stem) for f in dest_files]
|
||||
dest_new = dest.stem
|
||||
while dest_new in dest_files:
|
||||
while normalize_fs_path(dest_new) in dest_files:
|
||||
dest_new = f"{dest.stem} ({count})"
|
||||
count += 1
|
||||
dest = dest.parent / f"{dest_new}{dest.suffix}"
|
||||
|
||||
if export_original:
|
||||
dest_original = dest
|
||||
else:
|
||||
dest_edited = dest
|
||||
|
||||
# export the dest file
|
||||
results = self._export_photo(
|
||||
src,
|
||||
|
||||
@@ -183,13 +183,6 @@ UTI_ORIGINAL_DICT = {
|
||||
"1EB2B765-0765-43BA-A90C-0D0580E6172C": "public.jpeg",
|
||||
}
|
||||
|
||||
UUID_UNICODE_TITLE = [
|
||||
"B13F4485-94E0-41CD-AF71-913095D62E31", # Frítest.jpg
|
||||
"1793FAAB-DE75-4E25-886C-2BD66C780D6A", # Frítest.jpg
|
||||
"A8266C97-9BAF-4AF4-99F3-0013832869B8", # Frítest.jpg
|
||||
"D1D4040D-D141-44E8-93EA-E403D9F63E07", # Frítest.jpg
|
||||
]
|
||||
|
||||
RawInfo = namedtuple(
|
||||
"RawInfo",
|
||||
[
|
||||
|
||||
@@ -93,6 +93,12 @@ CLI_EXPORT_FILENAMES = [
|
||||
"screenshot-really-a-png.jpeg",
|
||||
"winebottle.jpeg",
|
||||
"winebottle (1).jpeg",
|
||||
"Frítest.jpg",
|
||||
"Frítest (1).jpg",
|
||||
"Frítest (2).jpg",
|
||||
"Frítest (3).jpg",
|
||||
"Frítest_edited.jpeg",
|
||||
"Frítest_edited (1).jpeg",
|
||||
]
|
||||
|
||||
|
||||
@@ -120,6 +126,8 @@ CLI_EXPORT_FILENAMES_DRY_RUN = [
|
||||
"screenshot-really-a-png.jpeg",
|
||||
"winebottle.jpeg",
|
||||
"winebottle.jpeg",
|
||||
"Frítest.jpg",
|
||||
"Frítest_edited.jpeg",
|
||||
]
|
||||
|
||||
CLI_EXPORT_IGNORE_SIGNATURE_FILENAMES = ["Tulips.jpg", "wedding.jpg"]
|
||||
@@ -160,6 +168,12 @@ CLI_EXPORT_FILENAMES_EDITED_SUFFIX = [
|
||||
"screenshot-really-a-png.jpeg",
|
||||
"winebottle.jpeg",
|
||||
"winebottle (1).jpeg",
|
||||
"Frítest.jpg",
|
||||
"Frítest (1).jpg",
|
||||
"Frítest (2).jpg",
|
||||
"Frítest (3).jpg",
|
||||
"Frítest_bearbeiten.jpeg",
|
||||
"Frítest_bearbeiten (1).jpeg",
|
||||
]
|
||||
|
||||
CLI_EXPORT_FILENAMES_EDITED_SUFFIX_TEMPLATE = [
|
||||
@@ -186,6 +200,12 @@ CLI_EXPORT_FILENAMES_EDITED_SUFFIX_TEMPLATE = [
|
||||
"screenshot-really-a-png.jpeg",
|
||||
"winebottle.jpeg",
|
||||
"winebottle (1).jpeg",
|
||||
"Frítest.jpg",
|
||||
"Frítest (1).jpg",
|
||||
"Frítest (2).jpg",
|
||||
"Frítest (3).jpg",
|
||||
"Frítest_edited.jpeg",
|
||||
"Frítest_edited (1).jpeg",
|
||||
]
|
||||
|
||||
CLI_EXPORT_FILENAMES_ORIGINAL_SUFFIX = [
|
||||
@@ -212,6 +232,12 @@ CLI_EXPORT_FILENAMES_ORIGINAL_SUFFIX = [
|
||||
"screenshot-really-a-png_original.jpeg",
|
||||
"winebottle_original.jpeg",
|
||||
"winebottle_original (1).jpeg",
|
||||
"Frítest_original.jpg",
|
||||
"Frítest_original (1).jpg",
|
||||
"Frítest_original (2).jpg",
|
||||
"Frítest_original (3).jpg",
|
||||
"Frítest_edited.jpeg",
|
||||
"Frítest_edited (1).jpeg",
|
||||
]
|
||||
|
||||
CLI_EXPORT_FILENAMES_ORIGINAL_SUFFIX_TEMPLATE = [
|
||||
@@ -238,6 +264,12 @@ CLI_EXPORT_FILENAMES_ORIGINAL_SUFFIX_TEMPLATE = [
|
||||
"screenshot-really-a-png.jpeg",
|
||||
"winebottle.jpeg",
|
||||
"winebottle (1).jpeg",
|
||||
"Frítest.jpg",
|
||||
"Frítest (1).jpg",
|
||||
"Frítest_original.jpg",
|
||||
"Frítest_edited.jpeg",
|
||||
"Frítest_original (1).jpg",
|
||||
"Frítest_edited (1).jpeg",
|
||||
]
|
||||
|
||||
CLI_EXPORT_FILENAMES_CURRENT = [
|
||||
@@ -264,6 +296,12 @@ CLI_EXPORT_FILENAMES_CURRENT = [
|
||||
"D1359D09-1373-4F3B-B0E3-1A4DE573E4A3.mp4",
|
||||
"E2078879-A29C-4D6F-BACB-E3BBE6C3EB91.jpeg",
|
||||
"52083079-73D5-4921-AC1B-FE76F279133F.jpeg",
|
||||
"B13F4485-94E0-41CD-AF71-913095D62E31.jpeg", # Frítest.jpg
|
||||
"1793FAAB-DE75-4E25-886C-2BD66C780D6A.jpeg", # Frítest.jpg
|
||||
"1793FAAB-DE75-4E25-886C-2BD66C780D6A_edited.jpeg", # Frítest.jpg
|
||||
"A8266C97-9BAF-4AF4-99F3-0013832869B8.jpeg", # Frítest.jpg
|
||||
"D1D4040D-D141-44E8-93EA-E403D9F63E07.jpeg", # Frítest.jpg
|
||||
"D1D4040D-D141-44E8-93EA-E403D9F63E07_edited.jpeg", # Frítest.jpg
|
||||
]
|
||||
|
||||
CLI_EXPORT_FILENAMES_CONVERT_TO_JPEG = [
|
||||
@@ -290,6 +328,12 @@ CLI_EXPORT_FILENAMES_CONVERT_TO_JPEG = [
|
||||
"screenshot-really-a-png.jpeg",
|
||||
"winebottle.jpeg",
|
||||
"winebottle (1).jpeg",
|
||||
"Frítest.jpg",
|
||||
"Frítest (1).jpg",
|
||||
"Frítest (2).jpg",
|
||||
"Frítest (3).jpg",
|
||||
"Frítest_edited (1).jpeg",
|
||||
"Frítest_edited.jpeg",
|
||||
]
|
||||
|
||||
CLI_EXPORT_FILENAMES_CONVERT_TO_JPEG_SKIP_RAW = [
|
||||
@@ -314,6 +358,12 @@ CLI_EXPORT_FILENAMES_CONVERT_TO_JPEG_SKIP_RAW = [
|
||||
"screenshot-really-a-png.jpeg",
|
||||
"winebottle.jpeg",
|
||||
"winebottle (1).jpeg",
|
||||
"Frítest.jpg",
|
||||
"Frítest (1).jpg",
|
||||
"Frítest (2).jpg",
|
||||
"Frítest (3).jpg",
|
||||
"Frítest_edited.jpeg",
|
||||
"Frítest_edited (1).jpeg",
|
||||
]
|
||||
|
||||
CLI_EXPORT_CONVERT_TO_JPEG_LARGE_FILE = "DSC03584.jpeg"
|
||||
@@ -486,10 +536,10 @@ PHOTOS_NOT_IN_TRASH_LEN_14_6 = 12
|
||||
PHOTOS_IN_TRASH_LEN_14_6 = 1
|
||||
PHOTOS_MISSING_14_6 = 1
|
||||
|
||||
PHOTOS_NOT_IN_TRASH_LEN_15_7 = 19
|
||||
PHOTOS_NOT_IN_TRASH_LEN_15_7 = 23
|
||||
PHOTOS_IN_TRASH_LEN_15_7 = 2
|
||||
PHOTOS_MISSING_15_7 = 2
|
||||
PHOTOS_EDITED_15_7 = 4
|
||||
PHOTOS_EDITED_15_7 = 6
|
||||
|
||||
CLI_PLACES_JSON = """{"places": {"_UNKNOWN_": 1, "Maui, Wailea, Hawai'i, United States": 1, "Washington, District of Columbia, United States": 1}}"""
|
||||
|
||||
@@ -645,6 +695,15 @@ KEYWORDS_JSON = {
|
||||
"Val d'Isère": 2,
|
||||
"Drink": 2,
|
||||
"Wine Bottle": 2,
|
||||
"Food": 2,
|
||||
"Furniture": 2,
|
||||
"Pizza": 2,
|
||||
"Table": 2,
|
||||
"Cloudy": 2,
|
||||
"Cord": 2,
|
||||
"Outdoor": 2,
|
||||
"Sky": 2,
|
||||
"Sunset Sunrise": 2,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -762,6 +821,10 @@ UUID_NOT_IN_ALBUM = [
|
||||
"8846E3E6-8AC8-4857-8448-E3D025784410",
|
||||
"7F74DD34-5920-4DA3-B284-479887A34F66",
|
||||
"52083079-73D5-4921-AC1B-FE76F279133F",
|
||||
"B13F4485-94E0-41CD-AF71-913095D62E31", # Frítest.jpg
|
||||
"1793FAAB-DE75-4E25-886C-2BD66C780D6A", # Frítest.jpg
|
||||
"A8266C97-9BAF-4AF4-99F3-0013832869B8", # Frítest.jpg
|
||||
"D1D4040D-D141-44E8-93EA-E403D9F63E07", # Frítest.jpg
|
||||
]
|
||||
|
||||
UUID_DUPLICATES = [
|
||||
@@ -4297,7 +4360,7 @@ def test_export_update_basic():
|
||||
)
|
||||
assert result.exit_code == 0
|
||||
assert (
|
||||
"Processed: 19 photos, exported: 0, updated: 0, skipped: 23, updated EXIF data: 0, missing: 2, error: 0"
|
||||
f"Processed: {PHOTOS_NOT_IN_TRASH_LEN_15_7} photos, exported: 0, updated: 0, skipped: {PHOTOS_NOT_IN_TRASH_LEN_15_7+PHOTOS_EDITED_15_7}, updated EXIF data: 0, missing: 2, error: 0"
|
||||
in result.output
|
||||
)
|
||||
|
||||
@@ -4381,7 +4444,7 @@ def test_export_update_exiftool():
|
||||
)
|
||||
assert result.exit_code == 0
|
||||
assert (
|
||||
"Processed: 19 photos, exported: 0, updated: 23, skipped: 0, updated EXIF data: 23, missing: 2, error: 1"
|
||||
f"Processed: {PHOTOS_NOT_IN_TRASH_LEN_15_7} photos, exported: 0, updated: {PHOTOS_NOT_IN_TRASH_LEN_15_7+PHOTOS_EDITED_15_7}, skipped: 0, updated EXIF data: {PHOTOS_NOT_IN_TRASH_LEN_15_7+PHOTOS_EDITED_15_7}, missing: 2, error: 1"
|
||||
in result.output
|
||||
)
|
||||
|
||||
@@ -4391,7 +4454,7 @@ def test_export_update_exiftool():
|
||||
)
|
||||
assert result.exit_code == 0
|
||||
assert (
|
||||
"Processed: 19 photos, exported: 0, updated: 0, skipped: 23, updated EXIF data: 0, missing: 2, error: 0"
|
||||
f"Processed: {PHOTOS_NOT_IN_TRASH_LEN_15_7} photos, exported: 0, updated: 0, skipped: {PHOTOS_NOT_IN_TRASH_LEN_15_7+PHOTOS_EDITED_15_7}, updated EXIF data: 0, missing: 2, error: 0"
|
||||
in result.output
|
||||
)
|
||||
|
||||
@@ -4428,7 +4491,7 @@ def test_export_update_hardlink():
|
||||
)
|
||||
assert result.exit_code == 0
|
||||
assert (
|
||||
"Processed: 19 photos, exported: 0, updated: 23, skipped: 0, updated EXIF data: 0, missing: 2, error: 0"
|
||||
f"Processed: {PHOTOS_NOT_IN_TRASH_LEN_15_7} photos, exported: 0, updated: {PHOTOS_NOT_IN_TRASH_LEN_15_7+PHOTOS_EDITED_15_7}, skipped: 0, updated EXIF data: 0, missing: 2, error: 0"
|
||||
in result.output
|
||||
)
|
||||
assert not os.path.samefile(CLI_EXPORT_UUID_FILENAME, photo.path)
|
||||
@@ -4467,7 +4530,7 @@ def test_export_update_hardlink_exiftool():
|
||||
)
|
||||
assert result.exit_code == 0
|
||||
assert (
|
||||
"Processed: 19 photos, exported: 0, updated: 23, skipped: 0, updated EXIF data: 23, missing: 2, error: 1"
|
||||
f"Processed: {PHOTOS_NOT_IN_TRASH_LEN_15_7} photos, exported: 0, updated: {PHOTOS_NOT_IN_TRASH_LEN_15_7+PHOTOS_EDITED_15_7}, skipped: 0, updated EXIF data: {PHOTOS_NOT_IN_TRASH_LEN_15_7+PHOTOS_EDITED_15_7}, missing: 2, error: 1"
|
||||
in result.output
|
||||
)
|
||||
assert not os.path.samefile(CLI_EXPORT_UUID_FILENAME, photo.path)
|
||||
@@ -4553,7 +4616,7 @@ def test_export_update_only_new():
|
||||
],
|
||||
)
|
||||
assert result.exit_code == 0
|
||||
assert "exported: 1" in result.output
|
||||
assert "exported: 7" in result.output
|
||||
|
||||
# --update with --only-new
|
||||
result = runner.invoke(
|
||||
@@ -4561,7 +4624,7 @@ def test_export_update_only_new():
|
||||
[os.path.join(cwd, PHOTOS_DB_15_7), ".", "-V", "--update", "--only-new"],
|
||||
)
|
||||
assert result.exit_code == 0
|
||||
assert "exported: 1" in result.output
|
||||
assert "exported: 7" in result.output
|
||||
|
||||
# --update with --only-new, should export nothing
|
||||
result = runner.invoke(
|
||||
@@ -4603,7 +4666,7 @@ def test_export_update_no_db():
|
||||
# edited files will be re-exported because there won't be an edited signature
|
||||
# in the database
|
||||
assert (
|
||||
"Processed: 19 photos, exported: 0, updated: 4, skipped: 19, updated EXIF data: 0, missing: 2, error: 0"
|
||||
f"Processed: {PHOTOS_NOT_IN_TRASH_LEN_15_7} photos, exported: 0, updated: {PHOTOS_EDITED_15_7}, skipped: {PHOTOS_NOT_IN_TRASH_LEN_15_7}, updated EXIF data: 0, missing: 2, error: 0"
|
||||
in result.output
|
||||
)
|
||||
assert os.path.isfile(OSXPHOTOS_EXPORT_DB)
|
||||
@@ -4643,7 +4706,8 @@ def test_export_then_hardlink():
|
||||
)
|
||||
assert result.exit_code == 0
|
||||
assert (
|
||||
"Processed: 19 photos, exported: 23, missing: 2, error: 0" in result.output
|
||||
f"Processed: {PHOTOS_NOT_IN_TRASH_LEN_15_7} photos, exported: {PHOTOS_NOT_IN_TRASH_LEN_15_7+PHOTOS_EDITED_15_7}, missing: 2, error: 0"
|
||||
in result.output
|
||||
)
|
||||
assert os.path.samefile(CLI_EXPORT_UUID_FILENAME, photo.path)
|
||||
|
||||
@@ -4656,6 +4720,7 @@ def test_export_dry_run():
|
||||
|
||||
import osxphotos
|
||||
from osxphotos.cli import export
|
||||
from osxphotos.utils import normalize_fs_path
|
||||
|
||||
runner = CliRunner()
|
||||
cwd = os.getcwd()
|
||||
@@ -4666,11 +4731,12 @@ def test_export_dry_run():
|
||||
)
|
||||
assert result.exit_code == 0
|
||||
assert (
|
||||
"Processed: 19 photos, exported: 23, missing: 2, error: 0" in result.output
|
||||
f"Processed: {PHOTOS_NOT_IN_TRASH_LEN_15_7} photos, exported: {PHOTOS_NOT_IN_TRASH_LEN_15_7+PHOTOS_EDITED_15_7}, missing: 2, error: 0"
|
||||
in result.output
|
||||
)
|
||||
for filepath in CLI_EXPORT_FILENAMES_DRY_RUN:
|
||||
assert re.search(r"Exported.*" + f"{filepath}", result.output)
|
||||
assert not os.path.isfile(filepath)
|
||||
assert not os.path.isfile(normalize_fs_path(filepath))
|
||||
|
||||
|
||||
def test_export_update_edits_dry_run():
|
||||
@@ -4747,7 +4813,10 @@ def test_export_directory_template_1_dry_run():
|
||||
],
|
||||
)
|
||||
assert result.exit_code == 0
|
||||
assert "exported: 23" in result.output
|
||||
assert (
|
||||
f"exported: {PHOTOS_NOT_IN_TRASH_LEN_15_7+PHOTOS_EDITED_15_7}"
|
||||
in result.output
|
||||
)
|
||||
workdir = os.getcwd()
|
||||
for filepath in CLI_EXPORTED_DIRECTORY_TEMPLATE_FILENAMES1:
|
||||
assert re.search(r"Exported.*" + f"{filepath}", result.output)
|
||||
@@ -4783,8 +4852,14 @@ def test_export_touch_files():
|
||||
)
|
||||
assert result.exit_code == 0
|
||||
|
||||
assert "exported: 23" in result.output
|
||||
assert "touched date: 21" in result.output
|
||||
assert (
|
||||
f"exported: {PHOTOS_NOT_IN_TRASH_LEN_15_7+PHOTOS_EDITED_15_7}"
|
||||
in result.output
|
||||
)
|
||||
assert (
|
||||
f"touched date: {PHOTOS_NOT_IN_TRASH_LEN_15_7+PHOTOS_EDITED_15_7-2}"
|
||||
in result.output
|
||||
)
|
||||
|
||||
for fname, mtime in zip(CLI_EXPORT_BY_DATE, CLI_EXPORT_BY_DATE_TOUCH_TIMES):
|
||||
st = os.stat(fname)
|
||||
@@ -4816,7 +4891,10 @@ def test_export_touch_files_update():
|
||||
)
|
||||
assert result.exit_code == 0
|
||||
|
||||
assert "exported: 23" in result.output
|
||||
assert (
|
||||
f"exported: {PHOTOS_NOT_IN_TRASH_LEN_15_7+PHOTOS_EDITED_15_7}"
|
||||
in result.output
|
||||
)
|
||||
|
||||
assert not pathlib.Path(CLI_EXPORT_BY_DATE[0]).is_file()
|
||||
|
||||
@@ -4826,7 +4904,10 @@ def test_export_touch_files_update():
|
||||
)
|
||||
assert result.exit_code == 0
|
||||
|
||||
assert "exported: 23" in result.output
|
||||
assert (
|
||||
f"exported: {PHOTOS_NOT_IN_TRASH_LEN_15_7+PHOTOS_EDITED_15_7}"
|
||||
in result.output
|
||||
)
|
||||
|
||||
assert pathlib.Path(CLI_EXPORT_BY_DATE[0]).is_file()
|
||||
|
||||
@@ -4837,7 +4918,10 @@ def test_export_touch_files_update():
|
||||
)
|
||||
assert result.exit_code == 0
|
||||
|
||||
assert "skipped: 23" in result.output
|
||||
assert (
|
||||
f"skipped: {PHOTOS_NOT_IN_TRASH_LEN_15_7+PHOTOS_EDITED_15_7}"
|
||||
in result.output
|
||||
)
|
||||
|
||||
# --update --touch-file --dry-run
|
||||
result = runner.invoke(
|
||||
@@ -4852,8 +4936,14 @@ def test_export_touch_files_update():
|
||||
],
|
||||
)
|
||||
assert result.exit_code == 0
|
||||
assert "skipped: 23" in result.output
|
||||
assert "touched date: 21" in result.output
|
||||
assert (
|
||||
f"skipped: {PHOTOS_NOT_IN_TRASH_LEN_15_7+PHOTOS_EDITED_15_7}"
|
||||
in result.output
|
||||
)
|
||||
assert (
|
||||
f"touched date: {PHOTOS_NOT_IN_TRASH_LEN_15_7+PHOTOS_EDITED_15_7-2}"
|
||||
in result.output
|
||||
)
|
||||
|
||||
for fname, mtime in zip(
|
||||
CLI_EXPORT_BY_DATE_NEED_TOUCH, CLI_EXPORT_BY_DATE_NEED_TOUCH_TIMES
|
||||
@@ -4873,8 +4963,14 @@ def test_export_touch_files_update():
|
||||
],
|
||||
)
|
||||
assert result.exit_code == 0
|
||||
assert "skipped: 23" in result.output
|
||||
assert "touched date: 21" in result.output
|
||||
assert (
|
||||
f"skipped: {PHOTOS_NOT_IN_TRASH_LEN_15_7+PHOTOS_EDITED_15_7}"
|
||||
in result.output
|
||||
)
|
||||
assert (
|
||||
f"touched date: {PHOTOS_NOT_IN_TRASH_LEN_15_7+PHOTOS_EDITED_15_7-2}"
|
||||
in result.output
|
||||
)
|
||||
|
||||
for fname, mtime in zip(
|
||||
CLI_EXPORT_BY_DATE_NEED_TOUCH, CLI_EXPORT_BY_DATE_NEED_TOUCH_TIMES
|
||||
@@ -4897,7 +4993,7 @@ def test_export_touch_files_update():
|
||||
],
|
||||
)
|
||||
assert result.exit_code == 0
|
||||
assert "updated: 1, skipped: 22" in result.output
|
||||
assert f"updated: 1, skipped: {PHOTOS_NOT_IN_TRASH_LEN_15_7+PHOTOS_EDITED_15_7-1}" in result.output
|
||||
assert "touched date: 1" in result.output
|
||||
|
||||
for fname, mtime in zip(CLI_EXPORT_BY_DATE, CLI_EXPORT_BY_DATE_TOUCH_TIMES):
|
||||
@@ -4911,7 +5007,10 @@ def test_export_touch_files_update():
|
||||
)
|
||||
assert result.exit_code == 0
|
||||
|
||||
assert "skipped: 23" in result.output
|
||||
assert (
|
||||
f"skipped: {PHOTOS_NOT_IN_TRASH_LEN_15_7+PHOTOS_EDITED_15_7}"
|
||||
in result.output
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.skip("TODO: This fails on some machines but not all")
|
||||
@@ -6551,7 +6650,7 @@ def test_query_min_size_1():
|
||||
assert result.exit_code == 0
|
||||
json_got = json.loads(result.output)
|
||||
|
||||
assert len(json_got) == 2
|
||||
assert len(json_got) == 4
|
||||
|
||||
|
||||
def test_query_min_size_2():
|
||||
@@ -6578,7 +6677,7 @@ def test_query_min_size_2():
|
||||
assert result.exit_code == 0
|
||||
json_got = json.loads(result.output)
|
||||
|
||||
assert len(json_got) == 2
|
||||
assert len(json_got) == 4
|
||||
|
||||
|
||||
def test_query_max_size_1():
|
||||
@@ -6599,7 +6698,7 @@ def test_query_max_size_1():
|
||||
assert result.exit_code == 0
|
||||
json_got = json.loads(result.output)
|
||||
|
||||
assert len(json_got) == 1
|
||||
assert len(json_got) == 3
|
||||
|
||||
|
||||
def test_query_max_size_2():
|
||||
@@ -6620,7 +6719,7 @@ def test_query_max_size_2():
|
||||
assert result.exit_code == 0
|
||||
json_got = json.loads(result.output)
|
||||
|
||||
assert len(json_got) == 1
|
||||
assert len(json_got) == 3
|
||||
|
||||
|
||||
def test_query_min_max_size():
|
||||
|
||||
Reference in New Issue
Block a user