pylint score cleanup...
svn: r17740
This commit is contained in:
parent
6d58e4db96
commit
dda9c5eaf6
@ -172,7 +172,7 @@ _DATAMAP = dict((key, val) for key, val in _DATAMAP.items())
|
|||||||
_DATAMAP.update( (val, key) for key, val in _DATAMAP.items())
|
_DATAMAP.update( (val, key) for key, val in _DATAMAP.items())
|
||||||
|
|
||||||
# define tooltips for all data entry fields...
|
# define tooltips for all data entry fields...
|
||||||
_DATATIPS = {
|
_TOOLTIPS = {
|
||||||
|
|
||||||
# Exif Label/ Title...
|
# Exif Label/ Title...
|
||||||
"ExifLabel" : _("This is equivalent to the Title field in the media object editor."),
|
"ExifLabel" : _("This is equivalent to the Title field in the media object editor."),
|
||||||
@ -207,9 +207,10 @@ _DATATIPS = {
|
|||||||
"Altitude" : _("This is the measurement of Above or Below Sea Level. It is measured in meters."
|
"Altitude" : _("This is the measurement of Above or Below Sea Level. It is measured in meters."
|
||||||
"Example: 200.558, -200.558"),
|
"Example: 200.558, -200.558"),
|
||||||
|
|
||||||
# Date/ Time (received from the GPS Satellites)...
|
# GPS Time (received from the GPS Satellites)...
|
||||||
"gpsTimeStamp" : _("The time that the GPS Latitude/ Longitude was received from the GPS Satellites.") }
|
"gpsTimeStamp" : _("The time that the GPS Latitude/ Longitude was received from the GPS Satellites.")}
|
||||||
_DATATIPS = dict( (key, tooltip) for key, tooltip in _DATATIPS.items() )
|
|
||||||
|
_TOOLTIPS = dict( (key, tooltip) for key, tooltip in _TOOLTIPS.items() )
|
||||||
|
|
||||||
# define tooltips for all buttons...
|
# define tooltips for all buttons...
|
||||||
# common buttons for all images...
|
# common buttons for all images...
|
||||||
@ -224,6 +225,7 @@ _BUTTONTIPS = {
|
|||||||
|
|
||||||
if (_MAGICK_FOUND or _JHEAD_FOUND):
|
if (_MAGICK_FOUND or _JHEAD_FOUND):
|
||||||
_BUTTONTIPS.update( {
|
_BUTTONTIPS.update( {
|
||||||
|
|
||||||
# Thumbnail Viewing Window button...
|
# Thumbnail Viewing Window button...
|
||||||
"Thumbnail" : _("Will produce a Popup window showing a Thumbnail Viewing Area"),
|
"Thumbnail" : _("Will produce a Popup window showing a Thumbnail Viewing Area"),
|
||||||
|
|
||||||
@ -235,7 +237,9 @@ if (_MAGICK_FOUND or _JHEAD_FOUND):
|
|||||||
"from this image! Are you sure that you want to do this?") } )
|
"from this image! Are you sure that you want to do this?") } )
|
||||||
|
|
||||||
# ------------------------------------------------------------------------
|
# ------------------------------------------------------------------------
|
||||||
# Gramplet class
|
#
|
||||||
|
# 'Edit Image Exif metadata' Class
|
||||||
|
#
|
||||||
# ------------------------------------------------------------------------
|
# ------------------------------------------------------------------------
|
||||||
class EditExifMetadata(Gramplet):
|
class EditExifMetadata(Gramplet):
|
||||||
def init(self):
|
def init(self):
|
||||||
@ -353,8 +357,8 @@ class EditExifMetadata(Gramplet):
|
|||||||
db = self.dbstate.db
|
db = self.dbstate.db
|
||||||
|
|
||||||
# clears all labels and display area...
|
# clears all labels and display area...
|
||||||
for widgetName in ["MediaLabel", "MimeType", "ImageSize", "MessageArea"]:
|
for widgetname_ in ["MediaLabel", "MimeType", "ImageSize", "MessageArea"]:
|
||||||
self.exif_widgets[widgetName].set_text("")
|
self.exif_widgets[widgetname_].set_text("")
|
||||||
self.model.clear()
|
self.model.clear()
|
||||||
|
|
||||||
# set Message Ares to Select...
|
# set Message Ares to Select...
|
||||||
@ -449,7 +453,7 @@ class EditExifMetadata(Gramplet):
|
|||||||
|
|
||||||
# if True, setup tooltips for all Data Entry Fields...
|
# if True, setup tooltips for all Data Entry Fields...
|
||||||
if fields:
|
if fields:
|
||||||
for widget, tooltip in _DATATIPS.items():
|
for widget, tooltip in _TOOLTIPS.items():
|
||||||
self.exif_widgets[widget].set_tooltip_text(tooltip)
|
self.exif_widgets[widget].set_tooltip_text(tooltip)
|
||||||
|
|
||||||
# if True, setup tooltips for all Buttons...
|
# if True, setup tooltips for all Buttons...
|
||||||
@ -480,6 +484,7 @@ class EditExifMetadata(Gramplet):
|
|||||||
except (IOError, OSError):
|
except (IOError, OSError):
|
||||||
self.set_has_data(False)
|
self.set_has_data(False)
|
||||||
return
|
return
|
||||||
|
|
||||||
return metadata
|
return metadata
|
||||||
|
|
||||||
def update_has_data(self):
|
def update_has_data(self):
|
||||||
@ -515,20 +520,23 @@ class EditExifMetadata(Gramplet):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
# update image Exif metadata...
|
# update image Exif metadata...
|
||||||
MediaDataTags = _get_exif_keypairs(self.plugin_image)
|
mediadatatags_ = _get_exif_keypairs(self.plugin_image)
|
||||||
if MediaDataTags:
|
if mediadatatags_:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def display_metadata(self, object):
|
def display_metadata(self, mediadatatags_ =None):
|
||||||
"""
|
"""
|
||||||
displays all of the image's Exif metadata in a grey-shaded tree view...
|
displays all of the image's Exif metadata in a grey-shaded tree view...
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
# clear display area...
|
||||||
|
self.model.clear()
|
||||||
|
|
||||||
# get All Exif metadata...
|
# get All Exif metadata...
|
||||||
metadatatags = _get_exif_keypairs(self.plugin_image)
|
metadatatags_ = _get_exif_keypairs(self.plugin_image)
|
||||||
if not metadatatags:
|
if not metadatatags_:
|
||||||
self.exif_widgets["MessageArea"].set_text(_("No Exif metadata to display..."))
|
self.exif_widgets["MessageArea"].set_text(_("No Exif metadata to display..."))
|
||||||
return
|
return
|
||||||
|
|
||||||
@ -546,30 +554,31 @@ class EditExifMetadata(Gramplet):
|
|||||||
if (_MAGICK_FOUND or _JHEAD_FOUND):
|
if (_MAGICK_FOUND or _JHEAD_FOUND):
|
||||||
self.activate_buttons(["Delete"])
|
self.activate_buttons(["Delete"])
|
||||||
|
|
||||||
for KeyTag in metadatatags:
|
for keytag_ in metadatatags_:
|
||||||
if LesserVersion: # prior to pyexiv2-0.2.0
|
if LesserVersion: # prior to pyexiv2-0.2.0
|
||||||
label = metadata.tagDetails(KeyTag)[0]
|
label = metadata.tagDetails(keytag_)[0]
|
||||||
|
|
||||||
# if KeyTag is one of the dates, display as the user wants it in preferences
|
# if keytag_ is one of the dates, display as the user wants it in preferences
|
||||||
if KeyTag in [_DATAMAP["Modified"], _DATAMAP["Original"], _DATAMAP["Digitized"] ]:
|
if keytag_ in [_DATAMAP["Modified"], _DATAMAP["Original"], _DATAMAP["Digitized"] ]:
|
||||||
human_value = _format_datetime(self.plugin_image[KeyTag])
|
human_value = _format_datetime(self.plugin_image[keytag_])
|
||||||
else:
|
else:
|
||||||
human_value = self.plugin_image.interpretedExifValue(KeyTag)
|
human_value = self.plugin_image.interpretedExifValue(keytag_)
|
||||||
|
|
||||||
else: # pyexiv2-0.2.0 and above
|
else: # pyexiv2-0.2.0 and above
|
||||||
tag = self.plugin_image[KeyTag]
|
tag = self.plugin_image[keytag_]
|
||||||
|
|
||||||
# if KeyTag is one of the dates, display as the user wants it in preferences
|
# if keytag_ is one of the dates, display as the user wants it in preferences
|
||||||
if KeyTag in [_DATAMAP["Modified"], _DATAMAP["Original"], _DATAMAP["Digitized"] ]:
|
if keytag_ in [_DATAMAP["Modified"], _DATAMAP["Original"], _DATAMAP["Digitized"] ]:
|
||||||
_value = self._get_value(KeyTag)
|
_value = self._get_value(keytag_)
|
||||||
if _value:
|
if _value:
|
||||||
label = tag.label
|
label = tag.label
|
||||||
human_value = _format_datetime(_value)
|
human_value = _format_datetime(_value)
|
||||||
else:
|
else:
|
||||||
human_value = False
|
human_value = False
|
||||||
elif ("Xmp" in KeyTag or "Iptc" in KeyTag):
|
|
||||||
label = self.plugin_image[KeyTag]
|
elif ("Xmp" in keytag_ or "Iptc" in keytag_):
|
||||||
human_value = self._get_value(KeyTag)
|
label = self.plugin_image[keytag_]
|
||||||
|
human_value = self._get_value(keytag_)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
label = tag.label
|
label = tag.label
|
||||||
@ -797,8 +806,8 @@ class EditExifMetadata(Gramplet):
|
|||||||
self.exif_widgets[widget].set_sensitive(False)
|
self.exif_widgets[widget].set_sensitive(False)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
for widgetName in ButtonList:
|
for widgetname_ in ButtonList:
|
||||||
self.exif_widgets[widgetName].set_sensitive(False)
|
self.exif_widgets[widgetname_].set_sensitive(False)
|
||||||
|
|
||||||
def active_buttons(self, obj):
|
def active_buttons(self, obj):
|
||||||
"""
|
"""
|
||||||
@ -840,6 +849,10 @@ class EditExifMetadata(Gramplet):
|
|||||||
self.edtarea.set_border_width(10)
|
self.edtarea.set_border_width(10)
|
||||||
self.edtarea.connect("destroy", lambda w: self.edtarea.destroy() )
|
self.edtarea.connect("destroy", lambda w: self.edtarea.destroy() )
|
||||||
|
|
||||||
|
if not any(exiv2type == self.extension for exiv2type in _vtypes):
|
||||||
|
self.close_window(self.edtarea)
|
||||||
|
return
|
||||||
|
|
||||||
# create a new scrolled window.
|
# create a new scrolled window.
|
||||||
scrollwindow = gtk.ScrolledWindow()
|
scrollwindow = gtk.ScrolledWindow()
|
||||||
scrollwindow.set_border_width(10)
|
scrollwindow.set_border_width(10)
|
||||||
@ -856,7 +869,7 @@ class EditExifMetadata(Gramplet):
|
|||||||
|
|
||||||
# display all fields and button tooltips...
|
# display all fields and button tooltips...
|
||||||
# need to add Save and Close over here...
|
# need to add Save and Close over here...
|
||||||
_BUTTONTIPS.update((key, tip) for key, tip in {
|
_BUTTONTIPS.update( (key, tip) for key, tip in {
|
||||||
|
|
||||||
# Add the Save button...
|
# Add the Save button...
|
||||||
"Save" : _("Saves a copy of the data fields into the image's Exif metadata."),
|
"Save" : _("Saves a copy of the data fields into the image's Exif metadata."),
|
||||||
@ -870,14 +883,16 @@ class EditExifMetadata(Gramplet):
|
|||||||
"Clear" : _("This button will clear all of the data fields shown here."),
|
"Clear" : _("This button will clear all of the data fields shown here."),
|
||||||
|
|
||||||
# Re- display the data fields button...
|
# Re- display the data fields button...
|
||||||
"Display" : _("Re -display the data fields that were cleared from the Edit Area."),
|
"Copy" : _("Re -display the data fields that were cleared from the Edit Area."),
|
||||||
|
|
||||||
# Convert 2 Decimal button...
|
# Convert 2 Decimal button...
|
||||||
"Decimal" : _("Convert GPS Latitude/ Longitude Coordinates to Decimal representation."),
|
"Decimal" : _("Convert GPS Latitude/ Longitude Coordinates to Decimal representation."),
|
||||||
|
|
||||||
# Convert 2 Degrees, Minutes, Seconds button...
|
# Convert 2 Degrees, Minutes, Seconds button...
|
||||||
"DMS" : _("Convert GPS Latitude/ Longitude Coordinates to (Degrees, Minutes, Seconds) Representation.")
|
"DMS" : _("Convert GPS Latitude/ Longitude Coordinates to "
|
||||||
}.items() )
|
"(Degrees, Minutes, Seconds) Representation.") }.items() )
|
||||||
|
|
||||||
|
# True, True -- all data fields and button tooltips will be displayed...
|
||||||
self._setup_widget_tips([True, True])
|
self._setup_widget_tips([True, True])
|
||||||
|
|
||||||
# display all data fields and their values...
|
# display all data fields and their values...
|
||||||
@ -1070,37 +1085,30 @@ class EditExifMetadata(Gramplet):
|
|||||||
button.show()
|
button.show()
|
||||||
|
|
||||||
# Help, Save, Clear, and Close horizontal box
|
# Help, Save, Clear, and Close horizontal box
|
||||||
hscdc_box = gtk.HButtonBox()
|
hsccc_box = gtk.HButtonBox()
|
||||||
hscdc_box.set_layout(gtk.BUTTONBOX_START)
|
hsccc_box.set_layout(gtk.BUTTONBOX_START)
|
||||||
main_vbox.pack_start(hscdc_box, expand =False, fill =False, padding =10)
|
main_vbox.pack_start(hsccc_box, expand =False, fill =False, padding =10)
|
||||||
hscdc_box.show()
|
hsccc_box.show()
|
||||||
|
|
||||||
# Help button...
|
# Help button...
|
||||||
hscdc_box.add(self.__create_button(
|
hsccc_box.add(self.__create_button(
|
||||||
"Help", False, [self.__help_page], gtk.STOCK_HELP, True) )
|
"Help", False, [self.__help_page], gtk.STOCK_HELP, True) )
|
||||||
|
|
||||||
# Save button...
|
# Save button...
|
||||||
hscdc_box.add(self.__create_button("Save", False, [self.save_metadata, self.update,
|
hsccc_box.add(self.__create_button("Save", False, [self.save_metadata, self.update,
|
||||||
self.display_metadata], gtk.STOCK_SAVE, True) )
|
self.display_metadata], gtk.STOCK_SAVE, True) )
|
||||||
|
|
||||||
# Clear button...
|
# Clear button...
|
||||||
hscdc_box.add(self.__create_button(
|
hsccc_box.add(self.__create_button(
|
||||||
"Clear", False, [self.clear_metadata], gtk.STOCK_CLEAR, True) )
|
"Clear", False, [self.clear_metadata], gtk.STOCK_CLEAR, True) )
|
||||||
|
|
||||||
# Re -display the edit area button...
|
# Re -display the edit area button...
|
||||||
hscdc_box.add(self.__create_button(
|
hsccc_box.add(self.__create_button(
|
||||||
"Display", _("Display"), [self.EditArea], False, True) )
|
"Copy", False, [self.EditArea], gtk.STOCK_COPY, True) )
|
||||||
|
|
||||||
# Close button...
|
# Close button...
|
||||||
hscdc_box.add(self.__create_button(
|
hsccc_box.add(self.__create_button(
|
||||||
"Close", False, [lambda w: self.edtarea.destroy()], gtk.STOCK_CLOSE, True) )
|
"Close", False, [lambda w: self.edtarea.destroy() ], gtk.STOCK_CLOSE, True) )
|
||||||
|
|
||||||
# disable all data fields if not one of the available exiv2 image types?
|
|
||||||
if not any(exiv2type == self.extension for exiv2type in _vtypes):
|
|
||||||
for widget in _DATATIPS.keys():
|
|
||||||
self.exif_widgets[widget].set_editable(False)
|
|
||||||
self.edtarea.destroy()
|
|
||||||
return
|
|
||||||
|
|
||||||
main_vbox.show_all()
|
main_vbox.show_all()
|
||||||
return main_vbox
|
return main_vbox
|
||||||
@ -1144,32 +1152,32 @@ class EditExifMetadata(Gramplet):
|
|||||||
"delete the Exif metadata from this image?"), _("Delete"),
|
"delete the Exif metadata from this image?"), _("Delete"),
|
||||||
self.strip_metadata)
|
self.strip_metadata)
|
||||||
|
|
||||||
def _get_value(self, KeyTag):
|
def _get_value(self, keytag_):
|
||||||
"""
|
"""
|
||||||
gets the value from the Exif Key, and returns it...
|
gets the value from the Exif Key, and returns it...
|
||||||
|
|
||||||
@param: KeyTag -- image metadata key
|
@param: keytag_ -- image metadata key
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if LesserVersion:
|
if LesserVersion:
|
||||||
KeyValue = self.plugin_image[KeyTag]
|
keyvalue_ = self.plugin_image[keytag_]
|
||||||
|
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
valu_ = self.plugin_image.__getitem__(KeyTag)
|
valu_ = self.plugin_image.__getitem__(keytag_)
|
||||||
KeyValue = valu_.value
|
keyvalue_ = valu_.value
|
||||||
|
|
||||||
except (KeyError, ValueError, AttributeError):
|
except (KeyError, ValueError, AttributeError):
|
||||||
KeyValue = False
|
keyvalue_ = False
|
||||||
|
|
||||||
return KeyValue
|
return keyvalue_
|
||||||
|
|
||||||
def clear_metadata(self, object):
|
def clear_metadata(self, object):
|
||||||
"""
|
"""
|
||||||
clears all data fields to nothing
|
clears all data fields to nothing
|
||||||
"""
|
"""
|
||||||
|
|
||||||
for widget in _DATATIPS.keys():
|
for widget in _TOOLTIPS.keys():
|
||||||
self.exif_widgets[widget].set_text("")
|
self.exif_widgets[widget].set_text("")
|
||||||
|
|
||||||
def EditArea(self, object):
|
def EditArea(self, object):
|
||||||
@ -1177,27 +1185,27 @@ class EditExifMetadata(Gramplet):
|
|||||||
displays the image Exif metadata in the Edit Area...
|
displays the image Exif metadata in the Edit Area...
|
||||||
"""
|
"""
|
||||||
|
|
||||||
MediaDataTags = _get_exif_keypairs(self.plugin_image)
|
mediadatatags_ = _get_exif_keypairs(self.plugin_image)
|
||||||
if MediaDataTags:
|
if mediadatatags_:
|
||||||
MediaDataTags = [KeyTag for KeyTag in MediaDataTags if KeyTag in _DATAMAP]
|
mediadatatags_ = [keytag_ for keytag_ in mediadatatags_ if keytag_ in _DATAMAP]
|
||||||
|
|
||||||
for KeyTag in MediaDataTags:
|
for keytag_ in mediadatatags_:
|
||||||
widgetName = _DATAMAP[KeyTag]
|
widgetname_ = _DATAMAP[keytag_]
|
||||||
|
|
||||||
tagValue = self._get_value(KeyTag)
|
tagValue = self._get_value(keytag_)
|
||||||
if tagValue:
|
if tagValue:
|
||||||
|
|
||||||
if widgetName in ["ExifLabel", "Description", "Artist", "Copyright"]:
|
if widgetname_ in ["ExifLabel", "Description", "Artist", "Copyright"]:
|
||||||
self.exif_widgets[widgetName].set_text(tagValue)
|
self.exif_widgets[widgetname_].set_text(tagValue)
|
||||||
|
|
||||||
# Last Changed/ Modified...
|
# Last Changed/ Modified...
|
||||||
elif widgetName in ["Modified", "Original"]:
|
elif widgetname_ in ["Modified", "Original"]:
|
||||||
use_date = _format_datetime(tagValue)
|
use_date = _format_datetime(tagValue)
|
||||||
if use_date:
|
if use_date:
|
||||||
self.exif_widgets[widgetName].set_text(use_date)
|
self.exif_widgets[widgetname_].set_text(use_date)
|
||||||
|
|
||||||
# LatitudeRef, Latitude, LongitudeRef, Longitude...
|
# LatitudeRef, Latitude, LongitudeRef, Longitude...
|
||||||
elif widgetName == "Latitude":
|
elif widgetname_ == "Latitude":
|
||||||
|
|
||||||
latitude, longitude = tagValue, self._get_value(_DATAMAP["Longitude"])
|
latitude, longitude = tagValue, self._get_value(_DATAMAP["Longitude"])
|
||||||
|
|
||||||
@ -1235,7 +1243,7 @@ class EditExifMetadata(Gramplet):
|
|||||||
self.exif_widgets["Latitude"].validate()
|
self.exif_widgets["Latitude"].validate()
|
||||||
self.exif_widgets["Longitude"].validate()
|
self.exif_widgets["Longitude"].validate()
|
||||||
|
|
||||||
elif widgetName == "Altitude":
|
elif widgetname_ == "Altitude":
|
||||||
altitude = tagValue
|
altitude = tagValue
|
||||||
AltitudeRef = self._get_value(_DATAMAP["AltitudeRef"])
|
AltitudeRef = self._get_value(_DATAMAP["AltitudeRef"])
|
||||||
|
|
||||||
@ -1244,44 +1252,44 @@ class EditExifMetadata(Gramplet):
|
|||||||
if altitude:
|
if altitude:
|
||||||
if AltitudeRef == "1":
|
if AltitudeRef == "1":
|
||||||
altitude = "-" + altitude
|
altitude = "-" + altitude
|
||||||
self.exif_widgets[widgetName].set_text(altitude)
|
self.exif_widgets[widgetname_].set_text(altitude)
|
||||||
|
|
||||||
elif widgetName == "gpsTimeStamp":
|
elif widgetname_ == "gpsTimeStamp":
|
||||||
hour, minutes, seconds = rational_to_dms(tagValue)
|
hour, minutes, seconds = rational_to_dms(tagValue)
|
||||||
hour, minutes, seconds = int(hour), int(minutes), int(seconds)
|
hour, minutes, seconds = int(hour), int(minutes), int(seconds)
|
||||||
self.exif_widgets[widgetName].set_text("%02d:%02d:%02d" % (
|
self.exif_widgets[widgetname_].set_text("%02d:%02d:%02d" % (
|
||||||
hour, minutes, seconds) )
|
hour, minutes, seconds) )
|
||||||
|
|
||||||
else:
|
else:
|
||||||
# set Edit Message Area to None...
|
# set Edit Message Area to None...
|
||||||
self.exif_widgets["Edit:Message"].set_text(_("There is NO Exif metadata for this image."))
|
self.exif_widgets["Edit:Message"].set_text(_("There is NO Exif metadata for this image."))
|
||||||
|
|
||||||
for widget in _DATATIPS.keys():
|
for widget in _TOOLTIPS.keys():
|
||||||
|
|
||||||
# once the user types in that field,
|
# once the user types in that field,
|
||||||
# the Edit, Clear, and Delete buttons will become active...
|
# the Edit, Clear, and Delete buttons will become active...
|
||||||
self.exif_widgets[widget].connect("changed", self.active_buttons)
|
self.exif_widgets[widget].connect("changed", self.active_buttons)
|
||||||
|
|
||||||
def _set_value(self, KeyTag, KeyValue):
|
def _set_value(self, keytag_, keyvalue_):
|
||||||
"""
|
"""
|
||||||
sets the value for the metadata KeyTags
|
sets the value for the metadata keytag_s
|
||||||
"""
|
"""
|
||||||
|
|
||||||
tagClass = KeyTag[0:4]
|
tagClass = keytag_[0:4]
|
||||||
|
|
||||||
if LesserVersion:
|
if LesserVersion:
|
||||||
self.plugin_image[KeyTag] = KeyValue
|
self.plugin_image[keytag_] = keyvalue_
|
||||||
|
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
self.plugin_image.__setitem__(KeyTag, KeyValue)
|
self.plugin_image.__setitem__(keytag_, keyvalue_)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
if tagClass == "Exif":
|
if tagClass == "Exif":
|
||||||
self.plugin_image[KeyTag] = pyexiv2.ExifTag(KeyTag, KeyValue)
|
self.plugin_image[keytag_] = pyexiv2.ExifTag(keytag_, keyvalue_)
|
||||||
elif tagClass == "Xmp.":
|
elif tagClass == "Xmp.":
|
||||||
self.plugin_image[KeyTag] = pyexiv2.XmpTag(KeyTag, KeyValue)
|
self.plugin_image[keytag_] = pyexiv2.XmpTag(keytag_, keyvalue_)
|
||||||
elif tagClass == "Iptc":
|
elif tagClass == "Iptc":
|
||||||
self.plugin_image[KeyTag] = IptcTag(KeyTag, KeyValue)
|
self.plugin_image[keytag_] = IptcTag(keytag_, keyvalue_)
|
||||||
except (ValueError, AttributeError):
|
except (ValueError, AttributeError):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@ -1305,9 +1313,6 @@ class EditExifMetadata(Gramplet):
|
|||||||
|
|
||||||
lambda w: widgetWindow.destroy()
|
lambda w: widgetWindow.destroy()
|
||||||
|
|
||||||
# -------------------------------------------------------------------
|
|
||||||
# GPS Coordinates functions
|
|
||||||
# -------------------------------------------------------------------
|
|
||||||
def convert_format(self, format):
|
def convert_format(self, format):
|
||||||
"""
|
"""
|
||||||
Convert GPS Coordinates into a specified format.
|
Convert GPS Coordinates into a specified format.
|
||||||
@ -1336,35 +1341,35 @@ class EditExifMetadata(Gramplet):
|
|||||||
"""
|
"""
|
||||||
self.convert_format("DEG")
|
self.convert_format("DEG")
|
||||||
|
|
||||||
def save_metadata(self, object):
|
def save_metadata(self, exif_widgets =None):
|
||||||
"""
|
"""
|
||||||
gets the information from the plugin data fields
|
gets the information from the plugin data fields
|
||||||
and sets the KeyTag = keyvalue image metadata
|
and sets the keytag_ = keyvalue image metadata
|
||||||
"""
|
"""
|
||||||
|
|
||||||
for widgetName in _DATATIPS.keys():
|
for widgetname_ in _TOOLTIPS.keys():
|
||||||
|
|
||||||
widgetValue = self.exif_widgets[widgetName].get_text()
|
|
||||||
|
|
||||||
# Exif Label, Description, Artist, Copyright...
|
# Exif Label, Description, Artist, Copyright...
|
||||||
if widgetName in ["ExifLabel", "Description", "Artist", "Copyright"]:
|
if widgetname_ in ["ExifLabel", "Description", "Artist", "Copyright"]:
|
||||||
self._set_value(_DATAMAP[widgetName], widgetValue)
|
widgetvalue_ = exif_widgets[widgetname_].get_text()
|
||||||
|
self._set_value(_DATAMAP[widgetname_], widgetvalue_)
|
||||||
|
|
||||||
# Modify Date/ Time...
|
# Modify Date/ Time...
|
||||||
elif widgetName == "Modified":
|
elif widgetname_ == "Modified":
|
||||||
|
date1 = self.dates["Modified"]
|
||||||
modified = datetime.now()
|
modified = datetime.now()
|
||||||
self._set_value(_DATAMAP[widgetName], modified)
|
use_date = date1 if date1 is not None else modified
|
||||||
self.exif_widgets[widgetName].set_text(_format_datetime(modified) )
|
self._set_value(_DATAMAP[widgetname_], use_date)
|
||||||
|
|
||||||
# Original Date/ Time...
|
# Original Date/ Time...
|
||||||
elif widgetName == "Original":
|
elif widgetname_ == "Original":
|
||||||
original = self.dates["Original"]
|
original = self.dates["Original"]
|
||||||
if original is not None:
|
if original is not None:
|
||||||
self._set_value(_DATAMAP[widgetName], original)
|
self._set_value(_DATAMAP[widgetname_], original)
|
||||||
|
|
||||||
# Latitude/ Longitude...
|
# Latitude/ Longitude...
|
||||||
elif widgetName == "Latitude":
|
elif widgetname_ == "Latitude":
|
||||||
latitude = self.exif_widgets["Latitude"].get_text()
|
latitude = self.exif_widgets["Latitude"].get_text()
|
||||||
longitude = self.exif_widgets["Longitude"].get_text()
|
longitude = self.exif_widgets["Longitude"].get_text()
|
||||||
|
|
||||||
latitude, longitude = conv_lat_lon(unicode(latitude),
|
latitude, longitude = conv_lat_lon(unicode(latitude),
|
||||||
@ -1372,60 +1377,61 @@ class EditExifMetadata(Gramplet):
|
|||||||
"DEG-:")
|
"DEG-:")
|
||||||
if latitude is not None:
|
if latitude is not None:
|
||||||
if "-" in latitude:
|
if "-" in latitude:
|
||||||
LatitudeRef = "S"
|
latituderef = "S"
|
||||||
else:
|
else:
|
||||||
LatitudeRef = "N"
|
latituderef = "N"
|
||||||
latitude = latitude.replace("-", "")
|
latitude = latitude.replace("-", "")
|
||||||
|
|
||||||
if "-" in longitude:
|
if "-" in longitude:
|
||||||
LongitudeRef = "W"
|
longituderef = "W"
|
||||||
else:
|
else:
|
||||||
LongitudeRef = "E"
|
longituderef = "E"
|
||||||
longitude = longitude.replace("-", "")
|
longitude = longitude.replace("-", "")
|
||||||
|
|
||||||
# convert (degrees, minutes, seconds) to Rational for saving
|
# convert (degrees, minutes, seconds) to Rational for saving
|
||||||
self._set_value(_DATAMAP["LatitudeRef"], LatitudeRef)
|
self._set_value(_DATAMAP["LatitudeRef"], latituderef)
|
||||||
self._set_value(_DATAMAP["Latitude"],
|
self._set_value(_DATAMAP["Latitude"],
|
||||||
coords_to_rational(latitude))
|
coords_to_rational(latitude))
|
||||||
|
|
||||||
# convert (degrees, minutes, seconds) to Rational for saving
|
# convert (degrees, minutes, seconds) to Rational for saving
|
||||||
self._set_value(_DATAMAP["LongitudeRef"], LongitudeRef)
|
self._set_value(_DATAMAP["LongitudeRef"], longituderef)
|
||||||
self._set_value(_DATAMAP["Longitude"],
|
self._set_value(_DATAMAP["Longitude"],
|
||||||
coords_to_rational(longitude))
|
coords_to_rational(longitude))
|
||||||
|
|
||||||
# Altitude, and Altitude Reference...
|
# Altitude, and Altitude Reference...
|
||||||
elif widgetName == "Altitude":
|
elif widgetname_ == "Altitude":
|
||||||
altitude = widgetValue
|
altitude = exif_widgets[widgetname_].get_text()
|
||||||
|
|
||||||
AltitudeRef = "0"
|
|
||||||
if altitude:
|
if altitude:
|
||||||
if altitude[0] == "-":
|
if "-" in altitude:
|
||||||
altitude = altitude.replace("-", "")
|
altitude = altitude.replace("-", "")
|
||||||
AltitudeRef = "1"
|
altituderef = "1"
|
||||||
|
else:
|
||||||
|
altituderef = "0"
|
||||||
|
|
||||||
self._set_value(_DATAMAP["AltitudeRef"], AltitudeRef)
|
# convert altitude to Rational for saving...
|
||||||
self._set_value(_DATAMAP["Altitude"], coords_to_rational(altitude) )
|
self._set_value(_DATAMAP["AltitudeRef"], altituderef)
|
||||||
|
self._set_value(_DATAMAP["Altitude"], coords_to_rational(altitude))
|
||||||
|
|
||||||
# gpsTimeStamp...
|
# gpsTimeStamp...
|
||||||
elif widgetName == "gpsTimeStamp":
|
elif widgetname_ == "gpsTimeStamp":
|
||||||
if widgetValue:
|
widgetvalue_ = exif_widgets[widgetname_].get_text()
|
||||||
widgetValue = coords_to_rational(widgetValue)
|
if widgetvalue_:
|
||||||
self._set_value(_DATAMAP[widgetName], widgetValue)
|
self._set_value(_DATAMAP[widgetname_], coords_to_rational(widgetvalue_))
|
||||||
|
|
||||||
# set Message Area to Saved...
|
# set Message Area to Saved...
|
||||||
self.exif_widgets["Edit:Message"].set_text(_("Saving Exif metadata to image..."))
|
exif_widgets["Edit:Message"].set_text(_("Saving Exif metadata to this image..."))
|
||||||
|
|
||||||
# writes all Exif Metadata to image even if the fields are all empty...
|
# writes all Exif Metadata to image even if the fields are all empty so as to remove the value...
|
||||||
self.write_metadata(self.plugin_image)
|
self.write_metadata(self.plugin_image)
|
||||||
|
|
||||||
def strip_metadata(self):
|
def strip_metadata(self, mediadatatags =None):
|
||||||
"""
|
"""
|
||||||
Will completely and irrevocably erase all Exif metadata from this image.
|
Will completely and irrevocably erase all Exif metadata from this image.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# update the image Exif metadata...
|
# update the image Exif metadata...
|
||||||
MediaDataTags = _get_exif_keypairs(self.plugin_image)
|
mediadatatags_ = _get_exif_keypairs(self.plugin_image)
|
||||||
if not MediaDataTags:
|
if not mediadatatags_:
|
||||||
return
|
return
|
||||||
|
|
||||||
if _MAGICK_FOUND:
|
if _MAGICK_FOUND:
|
||||||
@ -1436,9 +1442,9 @@ class EditExifMetadata(Gramplet):
|
|||||||
erase = subprocess.check_call( ["jhead", "-purejpeg", self.image_path] )
|
erase = subprocess.check_call( ["jhead", "-purejpeg", self.image_path] )
|
||||||
|
|
||||||
else:
|
else:
|
||||||
if MediaDataTags:
|
if mediadatatags_:
|
||||||
for KeyTag in MediaDataTags:
|
for keytag_ in mediadatatags_:
|
||||||
del self.plugin_image[KeyTag]
|
del self.plugin_image[keytag_]
|
||||||
erase_results = True
|
erase_results = True
|
||||||
|
|
||||||
# write wiped metadata to image...
|
# write wiped metadata to image...
|
||||||
@ -1488,11 +1494,11 @@ def _get_exif_keypairs(plugin_image):
|
|||||||
if not plugin_image:
|
if not plugin_image:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
MediaDataTags = [KeyTag for KeyTag in (plugin_image.exifKeys() if LesserVersion
|
mediadatatags_ = [keytag_ for keytag_ in (plugin_image.exifKeys() if LesserVersion
|
||||||
else chain( plugin_image.exif_keys,
|
else chain( plugin_image.exif_keys,
|
||||||
plugin_image.xmp_keys,
|
plugin_image.xmp_keys,
|
||||||
plugin_image.iptc_keys) ) ]
|
plugin_image.iptc_keys) ) ]
|
||||||
return MediaDataTags
|
return mediadatatags_
|
||||||
|
|
||||||
def string_to_rational(coordinate):
|
def string_to_rational(coordinate):
|
||||||
"""
|
"""
|
||||||
|
Loading…
Reference in New Issue
Block a user