From 5bad26bc47201aea14b57b0e03aca7eb89447212 Mon Sep 17 00:00:00 2001 From: Elrond Date: Fri, 23 Mar 2012 20:16:42 +0100 Subject: [PATCH] Create MediaEntry.exif_display_iter() MediaEntry.media_data.exif_all will contain all the "clean" EXIF data. MediaEntry.exif_display_iter() is an iterator that fetches the most interesting entries for display from that data. --- mediagoblin/db/mixin.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/mediagoblin/db/mixin.py b/mediagoblin/db/mixin.py index 4f9e1b11..7d0e0e9a 100644 --- a/mediagoblin/db/mixin.py +++ b/mediagoblin/db/mixin.py @@ -32,6 +32,7 @@ from mediagoblin.auth import lib as auth_lib from mediagoblin.tools import common, licenses from mediagoblin.tools.text import cleaned_markdown_conversion from mediagoblin.tools.url import slugify +from mediagoblin.tools.exif import USEFUL_TAGS class UserMixin(object): @@ -123,6 +124,15 @@ class MediaEntryMixin(object): """Return license dict for requested license""" return licenses.SUPPORTED_LICENSES[self.license or ""] + def exif_display_iter(self): + if not self.media_data: + return + exif_all = self.media_data.get("exif_all") + + for key in USEFUL_TAGS: + if key in exif_all: + yield key, exif_all[key] + class MediaCommentMixin(object): @property -- 2.25.1