Refactored template code out of PhotoInfo into PhotoTemplate

This commit is contained in:
Rhet Turnbull
2020-05-30 13:14:07 -07:00
parent 8d2d5a8a33
commit 16f802bf71
7 changed files with 463 additions and 431 deletions

View File

@@ -98,14 +98,15 @@ def test_lookup():
""" Test that a lookup is returned for every possible value """
import re
import osxphotos
from osxphotos.photoinfo.template import TEMPLATE_SUBSTITUTIONS
from osxphotos.phototemplate import TEMPLATE_SUBSTITUTIONS, PhotoTemplate
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB_PLACES)
photo = photosdb.photos(uuid=[UUID_DICT["place_dc"]])[0]
template = PhotoTemplate(photo)
for subst in TEMPLATE_SUBSTITUTIONS:
lookup_str = re.match(r"\{([^\\,}]+)\}", subst).group(1)
lookup = photo.get_template_value(lookup_str)
lookup = template.get_template_value(lookup_str)
assert lookup or lookup is None