7258: Metadata viewer: Exiv2 can't handle Windows's UTF16 pathnames

So open the file and pass the handle.
This commit is contained in:
John Ralls 2014-04-19 17:11:13 -07:00
parent 94518f2577
commit 74336a7ca8

View File

@ -178,13 +178,13 @@ class MetadataView(Gtk.TreeView):
self.sections = {}
self.model.clear()
if os.path.exists(full_path):
if not os.path.exists(full_path):
return False
retval = False
with open(full_path, 'rb') as fd:
try:
metadata = GExiv2.Metadata(full_path)
except:
return False
else:
return False
metadata = GExiv2.Metadata(self.fd)
get_human = metadata.get_tag_interpreted_string
@ -212,7 +212,11 @@ class MetadataView(Gtk.TreeView):
self.model.add((label, human_value), node=node)
self.model.tree.expand_all()
return self.model.count > 0
retval = self.model.count > 0
except:
pass
return retval
def __add_section(self, section):
"""
@ -229,15 +233,17 @@ class MetadataView(Gtk.TreeView):
"""
Return True if the gramplet has data, else return False.
"""
if os.path.exists(full_path):
if not os.path.exists(full_path):
return False
with open(full_path, 'rb') as fd:
retval = False
try:
metadata = GExiv2.Metadata(full_path)
except:
return False
else:
return False
metadata = GExiv2.Metadata(fd)
for tag in TAGS:
if tag in metadata.get_exif_tags():
return True
return False
retval = True
break
except:
pass
return retval