Implemented PhotoInfo.exiftool

This commit is contained in:
Rhet Turnbull
2020-05-14 12:55:17 -07:00
parent e67fce2871
commit a80dee401c
5 changed files with 135 additions and 1 deletions

View File

@@ -1,3 +1,3 @@
""" version info """
__version__ = "0.28.17"
__version__ = "0.28.18"

View File

@@ -0,0 +1,33 @@
""" Implementation for PhotoInfo.exiftool property which returns ExifTool object for a photo """
import logging
import os
from ..exiftool import ExifTool, get_exiftool_path
@property
def exiftool(self):
""" Returns an ExifTool object for the photo
requires that exiftool (https://exiftool.org/) be installed
If exiftool not installed, logs warning and returns None
If photo path is missing, returns None
"""
try:
# return the memoized instance if it exists
return self._exiftool
except AttributeError:
try:
exiftool_path = get_exiftool_path()
if self.path is not None and os.path.isfile(self.path):
exiftool = ExifTool(self.path)
else:
exiftool = None
logging.debug(f"exiftool: missing path {self.uuid}")
except FileNotFoundError:
# get_exiftool_path raises FileNotFoundError if exiftool not found
exiftool = None
logging.warning(f"exiftool not in path; download and install from https://exiftool.org/")
self._exiftool = exiftool
return self._exiftool

View File

@@ -65,6 +65,7 @@ class PhotoInfo:
SearchInfo,
)
from ._photoinfo_exifinfo import exif_info, ExifInfo
from ._photoinfo_exiftool import exiftool
def __init__(self, db=None, uuid=None, info=None):
self._uuid = uuid