GEexiv2 vor Python 2.7.3 and Win (see 6464)

svn: r21559
This commit is contained in:
Helge Herz 2013-03-05 21:56:09 +00:00
parent b57e7b7508
commit dd3bb6122c

View File

@ -21,6 +21,13 @@
# #
# $Id$ # $Id$
# #
#-------------------------------------------------------------------------
#
# Python modules
#
#-------------------------------------------------------------------------
import sys
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
# GNOME modules # GNOME modules
@ -28,6 +35,7 @@
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
from gi.repository import Gtk from gi.repository import Gtk
from gi.repository import GExiv2 from gi.repository import GExiv2
from gramps.gen.constfunc import win
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
@ -172,30 +180,46 @@ class MetadataView(Gtk.TreeView):
""" """
self.sections = {} self.sections = {}
self.model.clear() self.model.clear()
if (sys.version_info[0] < 3) and win():
try: #May be it's also necessary for lin and sys.version_info[0] < 3
metadata = GExiv2.Metadata(full_path) #if so, remove 'and win()'
except: #currently it's tested for Win only
return False metadata = GExiv2.Metadata.new()
try:
if not metadata.open_path(full_path):
return False
except:
# may be wrong file name
return False
else:
try:
metadata = GExiv2.Metadata(full_path)
except:
return False
get_human = metadata.get_exif_tag_interpreted_string get_human = metadata.get_exif_tag_interpreted_string
for section, key, key2, func in TAGS: for section, key, key2, func in TAGS:
if not key in metadata.get_exif_tags(): if (sys.version_info[0] < 3) and win():
continue #May be it's also necessary for lin and sys.version_info[0] < 3
#if so, remove 'and win()'
if func is not None: #currently it's tested for Win only
if key2 is None:
human_value = func(metadata[key])
else:
if key2 in metadata.get_exif_tags():
human_value = func(metadata[key], metadata[key2])
else:
human_value = func(metadata[key], None)
else:
human_value = get_human(key) human_value = get_human(key)
if key2 in metadata.get_exif_tags(): else:
human_value += ' ' + get_human(key2) if not key in metadata.get_exif_tags():
continue
if func is not None:
if key2 is None:
human_value = func(metadata[key])
else:
if key2 in metadata.get_exif_tags():
human_value = func(metadata[key], metadata[key2])
else:
human_value = func(metadata[key], None)
else:
human_value = get_human(key)
if key2 in metadata.get_exif_tags():
human_value += ' ' + get_human(key2)
label = metadata.get_exif_tag_label(key) label = metadata.get_exif_tag_label(key)
node = self.__add_section(section) node = self.__add_section(section)