Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _set_value(plugininstance, key, widget_value):
"""
sets the value for the metadata keys
"""
if not plugininstance:
return False
valid = 0
try:
if OLD_API:
plugininstance[key] = widget_value
valid = 1
else:
plugininstance[key].value = widget_value
valid = 2
except KeyError:
plugininstance[key] = pyexiv2.ExifTag(key, widget_value)
valid = 3
except (ValueError, AttributeError):
valid = 4
return valid
def _set_value(plugininstance, key, widget_value):
"""
sets the value for the metadata keys
"""
if not plugininstance:
return False
valid = 0
try:
if OLD_API:
plugininstance[key] = widget_value
valid = 1
else:
plugininstance[key].value = widget_value
valid = 2
except KeyError:
plugininstance[key] = pyexiv2.ExifTag(key, widget_value)
valid = 3
except (ValueError, AttributeError):
valid = 4
return valid
def __setitem__(self,key,value):
try:
pyexiv2.ImageMetadata.__setitem__(self,key,value)
except TypeError:
if key.startswith('Exif'):
value=pyexiv2.ExifTag(key,value)
elif key.startswith('Iptc'):
value=pyexiv2.IptcTag(key,value)
elif key.startswith('Xmp'):
value=pyexiv2.XmpTag(key,value)
pyexiv2.ImageMetadata.__setitem__(self,key,value)
def _set_exif_KeyTag(self, KeyTag, KeyValue):
"""
sets the value for the metadata KeyTags
"""
if LesserVersion:
self.plugin_image[KeyTag] = KeyValue
else:
try: # tag is being modified...
self.plugin_image[KeyTag] = KeyValue
except KeyError: # tag has not been set...
self.plugin_image[KeyTag] = pyexiv2.ExifTag(KeyTag, KeyValue)
except (ValueError, AttributeError): # there is an issue with either KeyTag or KeyValue
pass
def _set_value(plugininstance, key, widget_value):
"""
sets the value for the metadata keys
"""
if not plugininstance:
return False
valid = 0
try:
if OLD_API:
plugininstance[key] = widget_value
valid = 1
else:
plugininstance[key].value = widget_value
valid = 2
except KeyError:
plugininstance[key] = pyexiv2.ExifTag(key, widget_value)
valid = 3
except (ValueError, AttributeError):
valid = 4
return valid
@param: pluginobject -- plugin media instance
@param: KeyTag -- exif key
@param: KeyValue -- value to be saved
"""
# LesserVersion would only be True when pyexiv2-to 0.1.3 is installed
if LesserVersion:
pluginobject[KeyTag] = KeyValue
else:
# Exif KeyValue family?
if "Exif" in KeyTag:
try:
pluginobject[KeyTag].value = KeyValue
except KeyError:
pluginobject[KeyTag] = pyexiv2.ExifTag(KeyTag, KeyValue)
except (ValueError, AttributeError):
pass
# Iptc KeyValue family?
elif "Iptc" in KeyTag:
try:
pluginobject[KeyTag].values = KeyValue
except KeyError:
pluginobject[KeyTag] = pyexiv2.IptcTag(KeyTag, KeyValue)
except (ValueError, AttributeError):
pass
# Xmp KeyValue family?