From be2e16769d5d2c75af6d7792f1311f5a65c3bc67 Mon Sep 17 00:00:00 2001 From: Rhet Turnbull Date: Sat, 28 Mar 2020 10:18:58 -0700 Subject: [PATCH] added {place.country_code} to template system --- README.md | 1 + osxphotos/_version.py | 2 +- osxphotos/template.py | 4 ++++ tests/test_template.py | 1 + 4 files changed, 7 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 2d8cc07e..4ac5c89e 100644 --- a/README.md +++ b/README.md @@ -1007,6 +1007,7 @@ e.g. `render_filepath_template("{created.year}/{foo}", photo)` would return `("2 |{modified.mon}|Month abbreviation in the user's locale of the file modification time| |{modified.doy}|3-digit day of year (e.g Julian day) of file modification time, starting from 1 (zero padded)| |{place.name}|Place name from the photo's reverse geolocation data, as displayed in Photos| +|{place.country_code}|The ISO country code from the photo's reverse geolocationo data| |{place.name.country}|Country name from the photo's reverse geolocation data| |{place.name.state_province}|State or province name from the photo's reverse geolocation data| |{place.name.city}|City or locality name from the photo's reverse geolocation data| diff --git a/osxphotos/_version.py b/osxphotos/_version.py index 178c00af..b0a5cb74 100644 --- a/osxphotos/_version.py +++ b/osxphotos/_version.py @@ -1,3 +1,3 @@ """ version info """ -__version__ = "0.24.1" +__version__ = "0.24.2" diff --git a/osxphotos/template.py b/osxphotos/template.py index 4f2987d7..ce3377a4 100644 --- a/osxphotos/template.py +++ b/osxphotos/template.py @@ -25,6 +25,7 @@ TEMPLATE_SUBSTITUTIONS = { "{modified.mon}": "Month abbreviation in the user's locale of the file modification time", "{modified.doy}": "3-digit day of year (e.g Julian day) of file modification time, starting from 1 (zero padded)", "{place.name}": "Place name from the photo's reverse geolocation data, as displayed in Photos", + "{place.country_code}": "The ISO country code from the photo's reverse geolocationo data", "{place.name.country}": "Country name from the photo's reverse geolocation data", "{place.name.state_province}": "State or province name from the photo's reverse geolocation data", "{place.name.city}": "City or locality name from the photo's reverse geolocation data", @@ -119,6 +120,9 @@ def get_template_value(lookup, photo): if lookup == "place.name": return photo.place.name if photo.place else None + if lookup == "place.country_code": + return photo.place.country_code if photo.place else None + if lookup == "place.name.country": return ( photo.place.names.country[0] diff --git a/tests/test_template.py b/tests/test_template.py index 218f4921..0e0bf087 100644 --- a/tests/test_template.py +++ b/tests/test_template.py @@ -26,6 +26,7 @@ TEMPLATE_VALUES = { "{modified.mon}": "Mar", "{modified.doy}": "081", "{place.name}": "Washington, District of Columbia, United States", + "{place.country_code}": "US", "{place.name.country}": "United States", "{place.name.state_province}": "District of Columbia", "{place.name.city}": "Washington",