From 7d2528280beff38779afae1503ab5ad3cf6a5cbf Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Mon, 19 Jan 2015 13:08:45 +0100 Subject: [PATCH] Python unicode is awful --- scanner/PhotoAlbum.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/scanner/PhotoAlbum.py b/scanner/PhotoAlbum.py index fffe4ac..d6e14c4 100644 --- a/scanner/PhotoAlbum.py +++ b/scanner/PhotoAlbum.py @@ -145,9 +145,9 @@ class Photo(object): exif = {} for tag, value in info.items(): decoded = TAGS.get(tag, tag) - if isinstance(value, str): + if isinstance(value, str) or isinstance(value, unicode): value = value.strip().partition("\x00")[0] - if isinstance(decoded, str) and decoded.startswith("DateTime"): + if (isinstance(decoded, str) or isinstance(value, unicode)) and decoded.startswith("DateTime"): try: value = datetime.strptime(value, '%Y:%m:%d %H:%M:%S') except KeyboardInterrupt: @@ -315,8 +315,6 @@ class Photo(object): correct_date = self._attributes["dateTime"] else: correct_date = self._attributes["dateTimeFile"] - if isinstance(correct_date, unicode): - correct_date = datetime.strptime(correct_date, '%Y:%m:%d %H:%M:%S') return correct_date def __cmp__(self, other):