From 6bcc67634ca50e84494539b8a25eb7925dcede62 Mon Sep 17 00:00:00 2001 From: Rhet Turnbull Date: Sun, 29 Aug 2021 13:06:09 -0700 Subject: [PATCH] Bug fix for null title, #512 --- README.md | 4 ++-- osxphotos/_version.py | 2 +- osxphotos/photoinfo/photoinfo.py | 7 ++++++- osxphotos/phototemplate.py | 3 +++ 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 5e4a755a..cdf61d62 100644 --- a/README.md +++ b/README.md @@ -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.78' +{osxphotos_version} The osxphotos version, e.g. '0.42.79' {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.78'| +|{osxphotos_version}|The osxphotos version, e.g. '0.42.79'| |{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/osxphotos/_version.py b/osxphotos/_version.py index ecb85206..e2f3567a 100644 --- a/osxphotos/_version.py +++ b/osxphotos/_version.py @@ -1,3 +1,3 @@ """ version info """ -__version__ = "0.42.78" +__version__ = "0.42.79" diff --git a/osxphotos/photoinfo/photoinfo.py b/osxphotos/photoinfo/photoinfo.py index eb0cac08..a3678f72 100644 --- a/osxphotos/photoinfo/photoinfo.py +++ b/osxphotos/photoinfo/photoinfo.py @@ -564,7 +564,12 @@ class PhotoInfo: @property def title(self): """name / title of picture""" - return self._info["name"] + # if user sets then deletes title, Photos sets it to empty string in DB instead of NULL + # in this case, return None so result is the same as if title had never been set (which returns NULL) + # issue #512 + title = self._info["name"] + title = None if title == "" else title + return title @property def uuid(self): diff --git a/osxphotos/phototemplate.py b/osxphotos/phototemplate.py index 51fd56de..47e25b6c 100644 --- a/osxphotos/phototemplate.py +++ b/osxphotos/phototemplate.py @@ -1004,6 +1004,9 @@ class PhotoTemplate: elif self.dirname: value = sanitize_dirname(value) + # ensure no empty strings in value (see #512) + value = None if value == "" else value + return [value] def get_template_value_pathlib(self, field):