Added {favorite} template, partial fix for #289
This commit is contained in:
@@ -962,6 +962,10 @@ Substitution Description
|
|||||||
True/False value, use in format
|
True/False value, use in format
|
||||||
'{edited?VALUE_IF_TRUE,VALUE_IF_FALSE}'
|
'{edited?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.
|
{created.date} Photo's creation date in ISO format, e.g.
|
||||||
'2020-03-22'
|
'2020-03-22'
|
||||||
|
|
||||||
@@ -2705,6 +2709,7 @@ The following template field substitutions are availabe for use with `PhotoInfo.
|
|||||||
|{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}|Photo has been edited (has adjustments)?; True/False value, use in format '{edited?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|
|
||||||
|{created.yy}|2-digit year of photo creation time|
|
|{created.yy}|2-digit year of photo creation time|
|
||||||
|
|||||||
Binary file not shown.
@@ -48,6 +48,7 @@ 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}": "Photo has been edited (has adjustments)?; True/False value, use in format '{edited?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",
|
||||||
"{created.yy}": "2-digit year of photo creation time",
|
"{created.yy}": "2-digit year of photo creation time",
|
||||||
@@ -539,6 +540,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 == "favorite":
|
||||||
|
value = "favorite" if self.photo.favorite else None
|
||||||
elif field == "created.date":
|
elif field == "created.date":
|
||||||
value = DateTimeFormatter(self.photo.date).date
|
value = DateTimeFormatter(self.photo.date).date
|
||||||
elif field == "created.year":
|
elif field == "created.year":
|
||||||
|
|||||||
@@ -23,6 +23,14 @@ class PhotoInfoMock(PhotoInfo):
|
|||||||
else self._photo.hdr
|
else self._photo.hdr
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def favorite(self):
|
||||||
|
return (
|
||||||
|
self._mock_favorite
|
||||||
|
if getattr(self, "_mock_favorite", None) is not None
|
||||||
|
else self._photo.favorite
|
||||||
|
)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def hasadjustments(self):
|
def hasadjustments(self):
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ UUID_DICT = {
|
|||||||
"mojave_album_1": "15uNd7%8RguTEgNPKHfTWw",
|
"mojave_album_1": "15uNd7%8RguTEgNPKHfTWw",
|
||||||
"date_modified": "A9B73E13-A6F2-4915-8D67-7213B39BAE9F",
|
"date_modified": "A9B73E13-A6F2-4915-8D67-7213B39BAE9F",
|
||||||
"date_not_modified": "128FB4C6-0B16-4E7D-9108-FB2E90DA1546",
|
"date_not_modified": "128FB4C6-0B16-4E7D-9108-FB2E90DA1546",
|
||||||
|
"favorite": "E9BC5C36-7CD1-40A1-A72B-8B8FAC227D51",
|
||||||
}
|
}
|
||||||
|
|
||||||
UUID_MEDIA_TYPE = {
|
UUID_MEDIA_TYPE = {
|
||||||
@@ -176,6 +177,8 @@ TEMPLATE_VALUES = {
|
|||||||
"{exif.lens_model}": "iPhone 6s back camera 4.15mm f/2.2",
|
"{exif.lens_model}": "iPhone 6s back camera 4.15mm f/2.2",
|
||||||
"{album?{folder_album},{created.year}/{created.mm}}": "2020/02",
|
"{album?{folder_album},{created.year}/{created.mm}}": "2020/02",
|
||||||
"{title?Title is '{title} - {descr}',No Title}": "Title is 'Glen Ord - Jack Rose Dining Saloon'",
|
"{title?Title is '{title} - {descr}',No Title}": "Title is 'Glen Ord - Jack Rose Dining Saloon'",
|
||||||
|
"{favorite}": "_",
|
||||||
|
"{favorite?FAV,NOTFAV}": "NOTFAV",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -831,6 +834,14 @@ def test_edited(photosdb):
|
|||||||
assert rendered == ["edited"]
|
assert rendered == ["edited"]
|
||||||
|
|
||||||
|
|
||||||
|
def test_favorite(photosdb):
|
||||||
|
""" Test favorite"""
|
||||||
|
photo = photosdb.get_photo(UUID_MULTI_KEYWORDS)
|
||||||
|
photomock = PhotoInfoMock(photo, favorite=True)
|
||||||
|
rendered, _ = photomock.render_template("{favorite}")
|
||||||
|
assert rendered == ["favorite"]
|
||||||
|
|
||||||
|
|
||||||
def test_nested_template_bool(photosdb):
|
def test_nested_template_bool(photosdb):
|
||||||
photo = photosdb.get_photo(UUID_MULTI_KEYWORDS)
|
photo = photosdb.get_photo(UUID_MULTI_KEYWORDS)
|
||||||
template = "{hdr?{edited?HDR_EDITED,HDR_NOT_EDITED},{edited?NOT_HDR_EDITED,NOT_HDR_NOT_EDITED}}"
|
template = "{hdr?{edited?HDR_EDITED,HDR_NOT_EDITED},{edited?NOT_HDR_EDITED,NOT_HDR_NOT_EDITED}}"
|
||||||
|
|||||||
Reference in New Issue
Block a user