4850: Update set_has_data when non-image media are made active

svn: r17189
This commit is contained in:
Nick Hall 2011-04-21 16:34:03 +00:00
parent 3f77cd5fb9
commit b8d65d68bd

View File

@ -29,40 +29,15 @@ import datetime
import gtk import gtk
import Utils import Utils
import sys import sys
import pyexiv2
# pyexiv2 download page (C) Olivier Tilloy
_DOWNLOAD_LINK = "http://tilloy.net/dev/pyexiv2/download.html"
# make sure the pyexiv2 library is installed and at least a minimum version
pyexiv2_req_install = True
Min_VERSION = (0, 1, 3)
Min_VERSION_str = "pyexiv2-%d.%d.%d" % Min_VERSION
PrefVersion_str = "pyexiv2-%d.%d.%d" % (0, 3, 0)
# v0.1 has a different API to v0.2 and above # v0.1 has a different API to v0.2 and above
LesserVersion = False if hasattr(pyexiv2, 'version_info'):
LesserVersion = False
try: else:
import pyexiv2
if pyexiv2.version_info < Min_VERSION:
pyexiv2_req_install = False
except ImportError:
pyexiv2_req_install = False
except AttributeError:
# version_info attribute does not exist prior to v0.2.0 # version_info attribute does not exist prior to v0.2.0
LesserVersion = True LesserVersion = True
# the library is either not installed or does not meet
# minimum required version for this addon....
if not pyexiv2_req_install:
raise Exception((_("The minimum required version for pyexiv2 must be %s "
"or greater.\n Or you do not have the python library installed yet.\n"
"You may download it from here: %s\n\n I recommend getting, %s") % (
Min_VERSION_str, _DOWNLOAD_LINK, PrefVersion_str)
).encode(sys.getfilesystemencoding()) )
class MetadataViewer(Gramplet): class MetadataViewer(Gramplet):
""" """
Displays the exif tags of an image. Displays the exif tags of an image.
@ -138,6 +113,7 @@ class MetadataViewer(Gramplet):
try: try:
metadata = pyexiv2.Image(full_path) metadata = pyexiv2.Image(full_path)
except IOError: except IOError:
self.set_has_data(False)
return return
metadata.readMetadata() metadata.readMetadata()
for key in metadata.exifKeys(): for key in metadata.exifKeys():
@ -155,6 +131,7 @@ class MetadataViewer(Gramplet):
try: try:
metadata.read() metadata.read()
except IOError: except IOError:
self.set_has_data(False)
return return
for key in metadata.exif_keys: for key in metadata.exif_keys:
tag = metadata[key] tag = metadata[key]