From 4cc40d24cfb11ef8668c5d3c3bab40371fdd0436 Mon Sep 17 00:00:00 2001 From: Rhet Turnbull Date: Sun, 27 Dec 2020 09:26:54 -0800 Subject: [PATCH] Bug fix for --description-template, issue #304 --- osxphotos/_version.py | 2 +- osxphotos/photoinfo/_photoinfo_export.py | 8 +++++--- tests/test_cli.py | 4 ++-- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/osxphotos/_version.py b/osxphotos/_version.py index 575ae7b1..516ca806 100644 --- a/osxphotos/_version.py +++ b/osxphotos/_version.py @@ -1,5 +1,5 @@ """ version info """ -__version__ = "0.38.13" +__version__ = "0.38.14" diff --git a/osxphotos/photoinfo/_photoinfo_export.py b/osxphotos/photoinfo/_photoinfo_export.py index b2fd1f63..e262438d 100644 --- a/osxphotos/photoinfo/_photoinfo_export.py +++ b/osxphotos/photoinfo/_photoinfo_export.py @@ -1328,9 +1328,10 @@ def _exiftool_dict( exif = {} if description_template is not None: - description = self.render_template( + rendered = self.render_template( description_template, expand_inplace=True, inplace_sep=", " )[0] + description = " ".join(rendered) if rendered else "" exif["EXIF:ImageDescription"] = description exif["XMP:Description"] = description elif self.description: @@ -1547,9 +1548,10 @@ def _xmp_sidecar( extension = extension.suffix[1:] if extension.suffix else None if description_template is not None: - description = self.render_template( + rendered = self.render_template( description_template, expand_inplace=True, inplace_sep=", " )[0] + description = " ".join(rendered) if rendered else "" 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 - 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 diff --git a/tests/test_cli.py b/tests/test_cli.py index 96e67a35..ebc859cd 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -2036,11 +2036,11 @@ def test_export_sidecar_templates(): with open(CLI_TEMPLATE_SIDECAR_FILENAME, "r") as jsonfile: exifdata = json.load(jsonfile) assert ( - exifdata[0]["XMP:Description"][0] + exifdata[0]["XMP:Description"] == "Girls with pumpkins Katie, Suzy Kids Pumpkin Farm, Test Album" ) assert ( - exifdata[0]["EXIF:ImageDescription"][0] + exifdata[0]["EXIF:ImageDescription"] == "Girls with pumpkins Katie, Suzy Kids Pumpkin Farm, Test Album" )