Bug fix for --description-template, issue #304
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
""" version info """
|
""" version info """
|
||||||
|
|
||||||
__version__ = "0.38.13"
|
__version__ = "0.38.14"
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1328,9 +1328,10 @@ def _exiftool_dict(
|
|||||||
|
|
||||||
exif = {}
|
exif = {}
|
||||||
if description_template is not None:
|
if description_template is not None:
|
||||||
description = self.render_template(
|
rendered = self.render_template(
|
||||||
description_template, expand_inplace=True, inplace_sep=", "
|
description_template, expand_inplace=True, inplace_sep=", "
|
||||||
)[0]
|
)[0]
|
||||||
|
description = " ".join(rendered) if rendered else ""
|
||||||
exif["EXIF:ImageDescription"] = description
|
exif["EXIF:ImageDescription"] = description
|
||||||
exif["XMP:Description"] = description
|
exif["XMP:Description"] = description
|
||||||
elif self.description:
|
elif self.description:
|
||||||
@@ -1547,9 +1548,10 @@ def _xmp_sidecar(
|
|||||||
extension = extension.suffix[1:] if extension.suffix else None
|
extension = extension.suffix[1:] if extension.suffix else None
|
||||||
|
|
||||||
if description_template is not None:
|
if description_template is not None:
|
||||||
description = self.render_template(
|
rendered = self.render_template(
|
||||||
description_template, expand_inplace=True, inplace_sep=", "
|
description_template, expand_inplace=True, inplace_sep=", "
|
||||||
)[0]
|
)[0]
|
||||||
|
description = " ".join(rendered) if rendered else ""
|
||||||
else:
|
else:
|
||||||
description = self.description if self.description is not None else ""
|
description = self.description if self.description is not None else ""
|
||||||
|
|
||||||
@@ -1622,7 +1624,7 @@ def _xmp_sidecar(
|
|||||||
)
|
)
|
||||||
|
|
||||||
# remove extra lines that mako inserts from template
|
# remove extra lines that mako inserts from template
|
||||||
xmp_str = "\n".join([line for line in xmp_str.split("\n") if line.strip() != ""])
|
xmp_str = "\n".join(line for line in xmp_str.split("\n") if line.strip() != "")
|
||||||
return xmp_str
|
return xmp_str
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -2036,11 +2036,11 @@ def test_export_sidecar_templates():
|
|||||||
with open(CLI_TEMPLATE_SIDECAR_FILENAME, "r") as jsonfile:
|
with open(CLI_TEMPLATE_SIDECAR_FILENAME, "r") as jsonfile:
|
||||||
exifdata = json.load(jsonfile)
|
exifdata = json.load(jsonfile)
|
||||||
assert (
|
assert (
|
||||||
exifdata[0]["XMP:Description"][0]
|
exifdata[0]["XMP:Description"]
|
||||||
== "Girls with pumpkins Katie, Suzy Kids Pumpkin Farm, Test Album"
|
== "Girls with pumpkins Katie, Suzy Kids Pumpkin Farm, Test Album"
|
||||||
)
|
)
|
||||||
assert (
|
assert (
|
||||||
exifdata[0]["EXIF:ImageDescription"][0]
|
exifdata[0]["EXIF:ImageDescription"]
|
||||||
== "Girls with pumpkins Katie, Suzy Kids Pumpkin Farm, Test Album"
|
== "Girls with pumpkins Katie, Suzy Kids Pumpkin Farm, Test Album"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user