Simplified build_captures_from_exif
This commit is contained in:
parent
c58827a0cf
commit
6c51da5394
1 changed files with 31 additions and 37 deletions
|
|
@ -60,9 +60,7 @@ def build_captures_from_exif(capture_path):
|
||||||
|
|
||||||
for f in files:
|
for f in files:
|
||||||
logging.debug("Reloading capture {}...".format(f))
|
logging.debug("Reloading capture {}...".format(f))
|
||||||
exif = pull_usercomment_dict(f)
|
capture = capture_from_path(f)
|
||||||
if exif:
|
|
||||||
capture = capture_from_exif(f, exif)
|
|
||||||
if capture:
|
if capture:
|
||||||
captures[capture.id] = capture
|
captures[capture.id] = capture
|
||||||
else:
|
else:
|
||||||
|
|
@ -73,17 +71,9 @@ def build_captures_from_exif(capture_path):
|
||||||
return captures
|
return captures
|
||||||
|
|
||||||
|
|
||||||
def capture_from_exif(path, exif_dict):
|
def capture_from_path(path):
|
||||||
"""
|
exif_dict = pull_usercomment_dict(path)
|
||||||
Creates an instance of CaptureObject from a dictionary of capture information.
|
if exif_dict:
|
||||||
This is used when reloading the API server, to restore captures created in the
|
|
||||||
previous session.
|
|
||||||
|
|
||||||
Args:
|
|
||||||
path (str): Path to image file
|
|
||||||
exif_dict (dict): Dictionary containing capture information
|
|
||||||
"""
|
|
||||||
|
|
||||||
# Create a placeholder capture
|
# Create a placeholder capture
|
||||||
capture = CaptureObject(filepath=path)
|
capture = CaptureObject(filepath=path)
|
||||||
|
|
||||||
|
|
@ -101,7 +91,9 @@ def capture_from_exif(path, exif_dict):
|
||||||
|
|
||||||
# Populate capture parameters
|
# Populate capture parameters
|
||||||
capture.id = image_metadata.get("id")
|
capture.id = image_metadata.get("id")
|
||||||
capture.datetime = dateutil.parser.isoparse(image_metadata.get("acquisitionDate"))
|
capture.datetime = dateutil.parser.isoparse(
|
||||||
|
image_metadata.get("acquisitionDate")
|
||||||
|
)
|
||||||
capture.format = image_metadata.get("format")
|
capture.format = image_metadata.get("format")
|
||||||
capture.tags = image_metadata.get("tags")
|
capture.tags = image_metadata.get("tags")
|
||||||
capture.annotations = image_metadata.get("annotations")
|
capture.annotations = image_metadata.get("annotations")
|
||||||
|
|
@ -110,6 +102,8 @@ def capture_from_exif(path, exif_dict):
|
||||||
capture.set_metadata(exif_dict)
|
capture.set_metadata(exif_dict)
|
||||||
|
|
||||||
return capture
|
return capture
|
||||||
|
else:
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
class CaptureObject(object):
|
class CaptureObject(object):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue