Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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)
try:
pluginobject[KeyTag].values = KeyValue
except KeyError:
pluginobject[KeyTag] = pyexiv2.IptcTag(KeyTag, KeyValue)
except (ValueError, AttributeError):
pass
# Xmp KeyValue family?
elif "Xmp" in KeyTag:
try:
pluginobject[KeyTag].values = KeyValue
except KeyError:
pluginobject[KeyTag] = pyexiv2.XmpTag(KeyTag, KeyValue)
except (ValueError, AttributeError):
pass
def set_tag_multiple(self, tag, value):
if tag.startswith('Iptc'):
new_tag = pyexiv2.IptcTag(tag, value)
elif tag.startswith('Xmp'):
new_tag = pyexiv2.XmpTag(tag)
if new_tag.type == 'Lang Alt':
new_tag = pyexiv2.XmpTag(tag, {'x-default': value[0]})
elif new_tag.type == 'Date':
new_tag.raw_value = value[0]
else:
new_tag = pyexiv2.XmpTag(tag, value)
self._md[tag] = new_tag
def set_tag_multiple(self, tag, value):
if tag.startswith('Iptc'):
new_tag = pyexiv2.IptcTag(tag, value)
elif tag.startswith('Xmp'):
new_tag = pyexiv2.XmpTag(tag)
if new_tag.type == 'Lang Alt':
new_tag = pyexiv2.XmpTag(tag, {'x-default': value[0]})
elif new_tag.type == 'Date':
new_tag.raw_value = value[0]
else:
new_tag = pyexiv2.XmpTag(tag, value)
self._md[tag] = new_tag
def set_tag_multiple(self, tag, value):
if tag.startswith('Iptc'):
new_tag = pyexiv2.IptcTag(tag, value)
elif tag.startswith('Xmp'):
new_tag = pyexiv2.XmpTag(tag)
if new_tag.type == 'Lang Alt':
new_tag = pyexiv2.XmpTag(tag, {'x-default': value[0]})
elif new_tag.type == 'Date':
new_tag.raw_value = value[0]
else:
new_tag = pyexiv2.XmpTag(tag, value)
self._md[tag] = new_tag