Added {edited_version} template field, closes #420
This commit is contained in:
10
README.md
10
README.md
@@ -1362,10 +1362,13 @@ Substitution Description
|
|||||||
{hdr} Photo is HDR?; True/False value, use in format
|
{hdr} Photo is HDR?; True/False value, use in format
|
||||||
'{hdr?VALUE_IF_TRUE,VALUE_IF_FALSE}'
|
'{hdr?VALUE_IF_TRUE,VALUE_IF_FALSE}'
|
||||||
|
|
||||||
{edited} Photo has been edited (has adjustments)?;
|
{edited} True if photo has been edited (has
|
||||||
True/False value, use in format
|
adjustments), otherwise False; use in format
|
||||||
'{edited?VALUE_IF_TRUE,VALUE_IF_FALSE}'
|
'{edited?VALUE_IF_TRUE,VALUE_IF_FALSE}'
|
||||||
|
|
||||||
|
{edited_version} True if template is being rendered for the
|
||||||
|
edited version of a photo, otherwise False.
|
||||||
|
|
||||||
{favorite} Photo has been marked as favorite?; True/False
|
{favorite} Photo has been marked as favorite?; True/False
|
||||||
value, use in format
|
value, use in format
|
||||||
'{favorite?VALUE_IF_TRUE,VALUE_IF_FALSE}'
|
'{favorite?VALUE_IF_TRUE,VALUE_IF_FALSE}'
|
||||||
@@ -3187,7 +3190,8 @@ The following template field substitutions are availabe for use the templating s
|
|||||||
|{media_type}|Special media type resolved in this precedence: selfie, time_lapse, panorama, slow_mo, screenshot, portrait, live_photo, burst, photo, video. Defaults to 'photo' or 'video' if no special type. Customize one or more media types using format: '{media_type,video=vidéo;time_lapse=vidéo_accélérée}'|
|
|{media_type}|Special media type resolved in this precedence: selfie, time_lapse, panorama, slow_mo, screenshot, portrait, live_photo, burst, photo, video. Defaults to 'photo' or 'video' if no special type. Customize one or more media types using format: '{media_type,video=vidéo;time_lapse=vidéo_accélérée}'|
|
||||||
|{photo_or_video}|'photo' or 'video' depending on what type the image is. To customize, use default value as in '{photo_or_video,photo=fotos;video=videos}'|
|
|{photo_or_video}|'photo' or 'video' depending on what type the image is. To customize, use default value as in '{photo_or_video,photo=fotos;video=videos}'|
|
||||||
|{hdr}|Photo is HDR?; True/False value, use in format '{hdr?VALUE_IF_TRUE,VALUE_IF_FALSE}'|
|
|{hdr}|Photo is HDR?; True/False value, use in format '{hdr?VALUE_IF_TRUE,VALUE_IF_FALSE}'|
|
||||||
|{edited}|Photo has been edited (has adjustments)?; True/False value, use in format '{edited?VALUE_IF_TRUE,VALUE_IF_FALSE}'|
|
|{edited}|True if photo has been edited (has adjustments), otherwise False; use in format '{edited?VALUE_IF_TRUE,VALUE_IF_FALSE}'|
|
||||||
|
|{edited_version}|True if template is being rendered for the edited version of a photo, otherwise False. |
|
||||||
|{favorite}|Photo has been marked as favorite?; True/False value, use in format '{favorite?VALUE_IF_TRUE,VALUE_IF_FALSE}'|
|
|{favorite}|Photo has been marked as favorite?; True/False value, use in format '{favorite?VALUE_IF_TRUE,VALUE_IF_FALSE}'|
|
||||||
|{created.date}|Photo's creation date in ISO format, e.g. '2020-03-22'|
|
|{created.date}|Photo's creation date in ISO format, e.g. '2020-03-22'|
|
||||||
|{created.year}|4-digit year of photo creation time|
|
|{created.year}|4-digit year of photo creation time|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# Sphinx build info version 1
|
# 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.
|
# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done.
|
||||||
config: 25d6e59b24e8595abba5754b717909d9
|
config: 6ac453642da35cd6bd3feb4b51f3691d
|
||||||
tags: 645f666f9bcd5a90fca523b33c5a78b7
|
tags: 645f666f9bcd5a90fca523b33c5a78b7
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8" />
|
<meta charset="utf-8" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
<title>Overview: module code — osxphotos 0.42.11 documentation</title>
|
<title>Overview: module code — osxphotos 0.42.12 documentation</title>
|
||||||
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
|
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
|
||||||
<link rel="stylesheet" href="../_static/alabaster.css" type="text/css" />
|
<link rel="stylesheet" href="../_static/alabaster.css" type="text/css" />
|
||||||
<script id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script>
|
<script id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script>
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8" />
|
<meta charset="utf-8" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
<title>osxphotos.photoinfo.photoinfo — osxphotos 0.42.11 documentation</title>
|
<title>osxphotos.photoinfo.photoinfo — osxphotos 0.42.12 documentation</title>
|
||||||
<link rel="stylesheet" href="../../../_static/pygments.css" type="text/css" />
|
<link rel="stylesheet" href="../../../_static/pygments.css" type="text/css" />
|
||||||
<link rel="stylesheet" href="../../../_static/alabaster.css" type="text/css" />
|
<link rel="stylesheet" href="../../../_static/alabaster.css" type="text/css" />
|
||||||
<script id="documentation_options" data-url_root="../../../" src="../../../_static/documentation_options.js"></script>
|
<script id="documentation_options" data-url_root="../../../" src="../../../_static/documentation_options.js"></script>
|
||||||
@@ -970,6 +970,7 @@
|
|||||||
<span class="n">filename</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span>
|
<span class="n">filename</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span>
|
||||||
<span class="n">dirname</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span>
|
<span class="n">dirname</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span>
|
||||||
<span class="n">strip</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span>
|
<span class="n">strip</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span>
|
||||||
|
<span class="n">edited</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span>
|
||||||
<span class="p">):</span>
|
<span class="p">):</span>
|
||||||
<span class="sd">"""Renders a template string for PhotoInfo instance using PhotoTemplate</span>
|
<span class="sd">"""Renders a template string for PhotoInfo instance using PhotoTemplate</span>
|
||||||
|
|
||||||
@@ -985,6 +986,7 @@
|
|||||||
<span class="sd"> filename: if True, template output will be sanitized to produce valid file name</span>
|
<span class="sd"> filename: if True, template output will be sanitized to produce valid file name</span>
|
||||||
<span class="sd"> dirname: if True, template output will be sanitized to produce valid directory name</span>
|
<span class="sd"> dirname: if True, template output will be sanitized to produce valid directory name</span>
|
||||||
<span class="sd"> strip: if True, strips leading/trailing white space from resulting template</span>
|
<span class="sd"> strip: if True, strips leading/trailing white space from resulting template</span>
|
||||||
|
<span class="sd"> edited: if True, sets {edited_version} field to True, otherwise it gets set to False; set if you want template evaluated for edited version</span>
|
||||||
|
|
||||||
<span class="sd"> Returns:</span>
|
<span class="sd"> Returns:</span>
|
||||||
<span class="sd"> ([rendered_strings], [unmatched]): tuple of list of rendered strings and list of unmatched template values</span>
|
<span class="sd"> ([rendered_strings], [unmatched]): tuple of list of rendered strings and list of unmatched template values</span>
|
||||||
@@ -999,6 +1001,7 @@
|
|||||||
<span class="n">filename</span><span class="o">=</span><span class="n">filename</span><span class="p">,</span>
|
<span class="n">filename</span><span class="o">=</span><span class="n">filename</span><span class="p">,</span>
|
||||||
<span class="n">dirname</span><span class="o">=</span><span class="n">dirname</span><span class="p">,</span>
|
<span class="n">dirname</span><span class="o">=</span><span class="n">dirname</span><span class="p">,</span>
|
||||||
<span class="n">strip</span><span class="o">=</span><span class="n">strip</span><span class="p">,</span>
|
<span class="n">strip</span><span class="o">=</span><span class="n">strip</span><span class="p">,</span>
|
||||||
|
<span class="n">edited_version</span><span class="o">=</span><span class="n">edited</span><span class="p">,</span>
|
||||||
<span class="p">)</span></div>
|
<span class="p">)</span></div>
|
||||||
|
|
||||||
<span class="nd">@property</span>
|
<span class="nd">@property</span>
|
||||||
|
|||||||
2
docs/_static/documentation_options.js
vendored
2
docs/_static/documentation_options.js
vendored
@@ -1,6 +1,6 @@
|
|||||||
var DOCUMENTATION_OPTIONS = {
|
var DOCUMENTATION_OPTIONS = {
|
||||||
URL_ROOT: document.getElementById("documentation_options").getAttribute('data-url_root'),
|
URL_ROOT: document.getElementById("documentation_options").getAttribute('data-url_root'),
|
||||||
VERSION: '0.42.11',
|
VERSION: '0.42.12',
|
||||||
LANGUAGE: 'None',
|
LANGUAGE: 'None',
|
||||||
COLLAPSE_INDEX: false,
|
COLLAPSE_INDEX: false,
|
||||||
BUILDER: 'html',
|
BUILDER: 'html',
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8" />
|
<meta charset="utf-8" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
<title>osxphotos command line interface (CLI) — osxphotos 0.42.11 documentation</title>
|
<title>osxphotos command line interface (CLI) — osxphotos 0.42.12 documentation</title>
|
||||||
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
|
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
|
||||||
<link rel="stylesheet" href="_static/alabaster.css" type="text/css" />
|
<link rel="stylesheet" href="_static/alabaster.css" type="text/css" />
|
||||||
<script id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script>
|
<script id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script>
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8" />
|
<meta charset="utf-8" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
<title>Index — osxphotos 0.42.11 documentation</title>
|
<title>Index — osxphotos 0.42.12 documentation</title>
|
||||||
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
|
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
|
||||||
<link rel="stylesheet" href="_static/alabaster.css" type="text/css" />
|
<link rel="stylesheet" href="_static/alabaster.css" type="text/css" />
|
||||||
<script id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script>
|
<script id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script>
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8" />
|
<meta charset="utf-8" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
<title>Welcome to osxphotos’s documentation! — osxphotos 0.42.11 documentation</title>
|
<title>Welcome to osxphotos’s documentation! — osxphotos 0.42.12 documentation</title>
|
||||||
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
|
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
|
||||||
<link rel="stylesheet" href="_static/alabaster.css" type="text/css" />
|
<link rel="stylesheet" href="_static/alabaster.css" type="text/css" />
|
||||||
<script id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script>
|
<script id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script>
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8" />
|
<meta charset="utf-8" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
<title>osxphotos — osxphotos 0.42.11 documentation</title>
|
<title>osxphotos — osxphotos 0.42.12 documentation</title>
|
||||||
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
|
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
|
||||||
<link rel="stylesheet" href="_static/alabaster.css" type="text/css" />
|
<link rel="stylesheet" href="_static/alabaster.css" type="text/css" />
|
||||||
<script id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script>
|
<script id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script>
|
||||||
|
|||||||
Binary file not shown.
@@ -5,7 +5,7 @@
|
|||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8" />
|
<meta charset="utf-8" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
<title>osxphotos package — osxphotos 0.42.11 documentation</title>
|
<title>osxphotos package — osxphotos 0.42.12 documentation</title>
|
||||||
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
|
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
|
||||||
<link rel="stylesheet" href="_static/alabaster.css" type="text/css" />
|
<link rel="stylesheet" href="_static/alabaster.css" type="text/css" />
|
||||||
<script id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script>
|
<script id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script>
|
||||||
@@ -1184,7 +1184,7 @@ otherwise returns False</p>
|
|||||||
|
|
||||||
<dl class="py method">
|
<dl class="py method">
|
||||||
<dt id="osxphotos.PhotoInfo.render_template">
|
<dt id="osxphotos.PhotoInfo.render_template">
|
||||||
<code class="sig-name descname"><span class="pre">render_template</span></code><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">template_str</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">none_str</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'_'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">path_sep</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">expand_inplace</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">inplace_sep</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">filename</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">dirname</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">strip</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/osxphotos/photoinfo/photoinfo.html#PhotoInfo.render_template"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#osxphotos.PhotoInfo.render_template" title="Permalink to this definition">¶</a></dt>
|
<code class="sig-name descname"><span class="pre">render_template</span></code><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">template_str</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">none_str</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'_'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">path_sep</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">expand_inplace</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">inplace_sep</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">filename</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">dirname</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">strip</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">edited</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/osxphotos/photoinfo/photoinfo.html#PhotoInfo.render_template"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#osxphotos.PhotoInfo.render_template" title="Permalink to this definition">¶</a></dt>
|
||||||
<dd><p>Renders a template string for PhotoInfo instance using PhotoTemplate</p>
|
<dd><p>Renders a template string for PhotoInfo instance using PhotoTemplate</p>
|
||||||
<dl class="field-list simple">
|
<dl class="field-list simple">
|
||||||
<dt class="field-odd">Parameters</dt>
|
<dt class="field-odd">Parameters</dt>
|
||||||
@@ -1200,6 +1200,7 @@ with expand_inplace; default is ‘,’</p></li>
|
|||||||
<li><p><strong>filename</strong> – if True, template output will be sanitized to produce valid file name</p></li>
|
<li><p><strong>filename</strong> – if True, template output will be sanitized to produce valid file name</p></li>
|
||||||
<li><p><strong>dirname</strong> – if True, template output will be sanitized to produce valid directory name</p></li>
|
<li><p><strong>dirname</strong> – if True, template output will be sanitized to produce valid directory name</p></li>
|
||||||
<li><p><strong>strip</strong> – if True, strips leading/trailing white space from resulting template</p></li>
|
<li><p><strong>strip</strong> – if True, strips leading/trailing white space from resulting template</p></li>
|
||||||
|
<li><p><strong>edited</strong> – if True, sets {edited_version} field to True, otherwise it gets set to False; set if you want template evaluated for edited version</p></li>
|
||||||
</ul>
|
</ul>
|
||||||
</dd>
|
</dd>
|
||||||
<dt class="field-even">Returns</dt>
|
<dt class="field-even">Returns</dt>
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8" />
|
<meta charset="utf-8" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
<title>Search — osxphotos 0.42.11 documentation</title>
|
<title>Search — osxphotos 0.42.12 documentation</title>
|
||||||
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
|
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
|
||||||
<link rel="stylesheet" href="_static/alabaster.css" type="text/css" />
|
<link rel="stylesheet" href="_static/alabaster.css" type="text/css" />
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -5,7 +5,7 @@
|
|||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8" />
|
<meta charset="utf-8" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
<title>Export your photos — osxphotos 0.42.11 documentation</title>
|
<title>Export your photos — osxphotos 0.42.12 documentation</title>
|
||||||
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
|
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
|
||||||
<link rel="stylesheet" href="_static/alabaster.css" type="text/css" />
|
<link rel="stylesheet" href="_static/alabaster.css" type="text/css" />
|
||||||
<script id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script>
|
<script id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script>
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
""" version info """
|
""" version info """
|
||||||
|
|
||||||
__version__ = "0.42.11"
|
__version__ = "0.42.12"
|
||||||
|
|||||||
@@ -2317,7 +2317,7 @@ def export_photo(
|
|||||||
if export_edited and photo.hasadjustments:
|
if export_edited and photo.hasadjustments:
|
||||||
# if export-edited, also export the edited version
|
# if export-edited, also export the edited version
|
||||||
edited_filenames = get_filenames_from_template(
|
edited_filenames = get_filenames_from_template(
|
||||||
photo, filename_template, original_name, strip=strip
|
photo, filename_template, original_name, strip=strip, edited=True
|
||||||
)
|
)
|
||||||
for edited_filename in edited_filenames:
|
for edited_filename in edited_filenames:
|
||||||
edited_filename = pathlib.Path(edited_filename)
|
edited_filename = pathlib.Path(edited_filename)
|
||||||
@@ -2461,7 +2461,7 @@ def export_photo_with_template(
|
|||||||
results = ExportResults()
|
results = ExportResults()
|
||||||
|
|
||||||
dest_paths = get_dirnames_from_template(
|
dest_paths = get_dirnames_from_template(
|
||||||
photo, directory, export_by_date, dest, dry_run, strip=strip
|
photo, directory, export_by_date, dest, dry_run, strip=strip, edited=edited
|
||||||
)
|
)
|
||||||
|
|
||||||
# export the photo to each path in dest_paths
|
# export the photo to each path in dest_paths
|
||||||
@@ -2602,13 +2602,17 @@ def export_photo_with_template(
|
|||||||
return results
|
return results
|
||||||
|
|
||||||
|
|
||||||
def get_filenames_from_template(photo, filename_template, original_name, strip=False):
|
def get_filenames_from_template(
|
||||||
|
photo, filename_template, original_name, strip=False, edited=False
|
||||||
|
):
|
||||||
"""get list of export filenames for a photo
|
"""get list of export filenames for a photo
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
photo: a PhotoInfo instance
|
photo: a PhotoInfo instance
|
||||||
filename_template: a PhotoTemplate template string, may be None
|
filename_template: a PhotoTemplate template string, may be None
|
||||||
original_name: boolean; if True, use photo's original filename instead of current filename
|
original_name: boolean; if True, use photo's original filename instead of current filename
|
||||||
|
strip: if True, strips leading/trailing white space from resulting template
|
||||||
|
edited: if True, sets {edited_version} field to True, otherwise it gets set to False; set if you want template evaluated for edited version
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
list of filenames
|
list of filenames
|
||||||
@@ -2620,7 +2624,11 @@ def get_filenames_from_template(photo, filename_template, original_name, strip=F
|
|||||||
photo_ext = pathlib.Path(photo.original_filename).suffix
|
photo_ext = pathlib.Path(photo.original_filename).suffix
|
||||||
try:
|
try:
|
||||||
filenames, unmatched = photo.render_template(
|
filenames, unmatched = photo.render_template(
|
||||||
filename_template, path_sep="_", filename=True, strip=strip
|
filename_template,
|
||||||
|
path_sep="_",
|
||||||
|
filename=True,
|
||||||
|
strip=strip,
|
||||||
|
edited=edited,
|
||||||
)
|
)
|
||||||
except ValueError as e:
|
except ValueError as e:
|
||||||
raise click.BadOptionUsage(
|
raise click.BadOptionUsage(
|
||||||
@@ -2644,7 +2652,7 @@ def get_filenames_from_template(photo, filename_template, original_name, strip=F
|
|||||||
|
|
||||||
|
|
||||||
def get_dirnames_from_template(
|
def get_dirnames_from_template(
|
||||||
photo, directory, export_by_date, dest, dry_run, strip=False
|
photo, directory, export_by_date, dest, dry_run, strip=False, edited=False
|
||||||
):
|
):
|
||||||
"""get list of directories to export a photo into, creates directories if they don't exist
|
"""get list of directories to export a photo into, creates directories if they don't exist
|
||||||
|
|
||||||
@@ -2654,6 +2662,8 @@ def get_dirnames_from_template(
|
|||||||
export_by_date: boolean; if True, creates output directories in form YYYY-MM-DD
|
export_by_date: boolean; if True, creates output directories in form YYYY-MM-DD
|
||||||
dest: top-level destination directory
|
dest: top-level destination directory
|
||||||
dry_run: boolean; if True, runs in dry-run mode and does not create output directories
|
dry_run: boolean; if True, runs in dry-run mode and does not create output directories
|
||||||
|
strip: if True, strips leading/trailing white space from resulting template
|
||||||
|
edited: if True, sets {edited_version} field to True, otherwise it gets set to False; set if you want template evaluated for edited version
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
list of export directories
|
list of export directories
|
||||||
@@ -2674,7 +2684,7 @@ def get_dirnames_from_template(
|
|||||||
# got a directory template, render it and check results are valid
|
# got a directory template, render it and check results are valid
|
||||||
try:
|
try:
|
||||||
dirnames, unmatched = photo.render_template(
|
dirnames, unmatched = photo.render_template(
|
||||||
directory, dirname=True, strip=strip
|
directory, dirname=True, strip=strip, edited=edited
|
||||||
)
|
)
|
||||||
except ValueError as e:
|
except ValueError as e:
|
||||||
raise click.BadOptionUsage(
|
raise click.BadOptionUsage(
|
||||||
|
|||||||
@@ -937,6 +937,7 @@ class PhotoInfo:
|
|||||||
filename=False,
|
filename=False,
|
||||||
dirname=False,
|
dirname=False,
|
||||||
strip=False,
|
strip=False,
|
||||||
|
edited=False,
|
||||||
):
|
):
|
||||||
"""Renders a template string for PhotoInfo instance using PhotoTemplate
|
"""Renders a template string for PhotoInfo instance using PhotoTemplate
|
||||||
|
|
||||||
@@ -952,6 +953,7 @@ class PhotoInfo:
|
|||||||
filename: if True, template output will be sanitized to produce valid file name
|
filename: if True, template output will be sanitized to produce valid file name
|
||||||
dirname: if True, template output will be sanitized to produce valid directory name
|
dirname: if True, template output will be sanitized to produce valid directory name
|
||||||
strip: if True, strips leading/trailing white space from resulting template
|
strip: if True, strips leading/trailing white space from resulting template
|
||||||
|
edited: if True, sets {edited_version} field to True, otherwise it gets set to False; set if you want template evaluated for edited version
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
([rendered_strings], [unmatched]): tuple of list of rendered strings and list of unmatched template values
|
([rendered_strings], [unmatched]): tuple of list of rendered strings and list of unmatched template values
|
||||||
@@ -966,6 +968,7 @@ class PhotoInfo:
|
|||||||
filename=filename,
|
filename=filename,
|
||||||
dirname=dirname,
|
dirname=dirname,
|
||||||
strip=strip,
|
strip=strip,
|
||||||
|
edited_version=edited,
|
||||||
)
|
)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
|||||||
@@ -48,7 +48,8 @@ TEMPLATE_SUBSTITUTIONS = {
|
|||||||
),
|
),
|
||||||
"{photo_or_video}": "'photo' or 'video' depending on what type the image is. To customize, use default value as in '{photo_or_video,photo=fotos;video=videos}'",
|
"{photo_or_video}": "'photo' or 'video' depending on what type the image is. To customize, use default value as in '{photo_or_video,photo=fotos;video=videos}'",
|
||||||
"{hdr}": "Photo is HDR?; True/False value, use in format '{hdr?VALUE_IF_TRUE,VALUE_IF_FALSE}'",
|
"{hdr}": "Photo is HDR?; True/False value, use in format '{hdr?VALUE_IF_TRUE,VALUE_IF_FALSE}'",
|
||||||
"{edited}": "Photo has been edited (has adjustments)?; True/False value, use in format '{edited?VALUE_IF_TRUE,VALUE_IF_FALSE}'",
|
"{edited}": "True if photo has been edited (has adjustments), otherwise False; use in format '{edited?VALUE_IF_TRUE,VALUE_IF_FALSE}'",
|
||||||
|
"{edited_version}": "True if template is being rendered for the edited version of a photo, otherwise False. ",
|
||||||
"{favorite}": "Photo has been marked as favorite?; True/False value, use in format '{favorite?VALUE_IF_TRUE,VALUE_IF_FALSE}'",
|
"{favorite}": "Photo has been marked as favorite?; True/False value, use in format '{favorite?VALUE_IF_TRUE,VALUE_IF_FALSE}'",
|
||||||
"{created.date}": "Photo's creation date in ISO format, e.g. '2020-03-22'",
|
"{created.date}": "Photo's creation date in ISO format, e.g. '2020-03-22'",
|
||||||
"{created.year}": "4-digit year of photo creation time",
|
"{created.year}": "4-digit year of photo creation time",
|
||||||
@@ -257,6 +258,9 @@ class PhotoTemplate:
|
|||||||
# get parser singleton
|
# get parser singleton
|
||||||
self.parser = PhotoTemplateParser()
|
self.parser = PhotoTemplateParser()
|
||||||
|
|
||||||
|
# should {edited_version} render True?
|
||||||
|
self.edited_version = False
|
||||||
|
|
||||||
def render(
|
def render(
|
||||||
self,
|
self,
|
||||||
template,
|
template,
|
||||||
@@ -267,6 +271,7 @@ class PhotoTemplate:
|
|||||||
filename=False,
|
filename=False,
|
||||||
dirname=False,
|
dirname=False,
|
||||||
strip=False,
|
strip=False,
|
||||||
|
edited_version=False,
|
||||||
):
|
):
|
||||||
""" Render a filename or directory template
|
""" Render a filename or directory template
|
||||||
|
|
||||||
@@ -281,6 +286,7 @@ class PhotoTemplate:
|
|||||||
filename: if True, template output will be sanitized to produce valid file name
|
filename: if True, template output will be sanitized to produce valid file name
|
||||||
dirname: if True, template output will be sanitized to produce valid directory name
|
dirname: if True, template output will be sanitized to produce valid directory name
|
||||||
strip: if True, strips leading/trailing whitespace from rendered templates
|
strip: if True, strips leading/trailing whitespace from rendered templates
|
||||||
|
edited_version: set to True if you want {edited_version} to resolve to True (e.g. exporting edited version of photo)
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
([rendered_strings], [unmatched]): tuple of list of rendered strings and list of unmatched template values
|
([rendered_strings], [unmatched]): tuple of list of rendered strings and list of unmatched template values
|
||||||
@@ -304,6 +310,8 @@ class PhotoTemplate:
|
|||||||
# empty string
|
# empty string
|
||||||
return [], []
|
return [], []
|
||||||
|
|
||||||
|
self.edited_version = edited_version
|
||||||
|
|
||||||
return self._render_statement(
|
return self._render_statement(
|
||||||
model,
|
model,
|
||||||
none_str=none_str,
|
none_str=none_str,
|
||||||
@@ -669,6 +677,8 @@ class PhotoTemplate:
|
|||||||
value = "hdr" if self.photo.hdr else None
|
value = "hdr" if self.photo.hdr else None
|
||||||
elif field == "edited":
|
elif field == "edited":
|
||||||
value = "edited" if self.photo.hasadjustments else None
|
value = "edited" if self.photo.hasadjustments else None
|
||||||
|
elif field == "edited_version":
|
||||||
|
value = "edited_version" if self.edited_version else None
|
||||||
elif field == "favorite":
|
elif field == "favorite":
|
||||||
value = "favorite" if self.photo.favorite else None
|
value = "favorite" if self.photo.favorite else None
|
||||||
elif field == "created.date":
|
elif field == "created.date":
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -87,11 +87,13 @@ TEMPLATE_VALUES_TITLE = {
|
|||||||
UUID_BOOL_VALUES = {
|
UUID_BOOL_VALUES = {
|
||||||
"hdr": "D11D25FF-5F31-47D2-ABA9-58418878DC15",
|
"hdr": "D11D25FF-5F31-47D2-ABA9-58418878DC15",
|
||||||
"edited": "51F2BEF7-431A-4D31-8AC1-3284A57826AE",
|
"edited": "51F2BEF7-431A-4D31-8AC1-3284A57826AE",
|
||||||
|
"edited_version": "51F2BEF7-431A-4D31-8AC1-3284A57826AE",
|
||||||
}
|
}
|
||||||
|
|
||||||
# Boolean type values that render to False
|
# Boolean type values that render to False
|
||||||
UUID_BOOL_VALUES_NOT = {
|
UUID_BOOL_VALUES_NOT = {
|
||||||
"hdr": "51F2BEF7-431A-4D31-8AC1-3284A57826AE",
|
"hdr": "51F2BEF7-431A-4D31-8AC1-3284A57826AE",
|
||||||
|
"edited_version": "51F2BEF7-431A-4D31-8AC1-3284A57826AE",
|
||||||
"edited": "CCBE0EB9-AE9F-4479-BFFD-107042C75227",
|
"edited": "CCBE0EB9-AE9F-4479-BFFD-107042C75227",
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -830,7 +832,10 @@ def test_bool_values(photosdb_cloud):
|
|||||||
for field, uuid in UUID_BOOL_VALUES.items():
|
for field, uuid in UUID_BOOL_VALUES.items():
|
||||||
if uuid is not None:
|
if uuid is not None:
|
||||||
photo = photosdb_cloud.get_photo(uuid)
|
photo = photosdb_cloud.get_photo(uuid)
|
||||||
rendered, _ = photo.render_template("{" + f"{field}" + "?True,False}")
|
edited = field == "edited_version"
|
||||||
|
rendered, _ = photo.render_template(
|
||||||
|
"{" + f"{field}" + "?True,False}", edited=edited
|
||||||
|
)
|
||||||
assert rendered[0] == "True"
|
assert rendered[0] == "True"
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user