def metadata_synch(self, component_id, changes): # get xmp # the filename is needed because the extension is unknown, the following line of code is # tmp code because c.ID will include extension file (not only basename) # in the new MediaDART release try: myxmpfilename = str(self._fc.abspath(component_id)) except Exception, err: log.error("Found some problems getting filename: %s" % err)
try: prefix = xmp.get_prefix_for_namespace(str(ns)) except XMPError, err: log.debug("Error in get_prefix_for namespace: %s" % str(ns)) if prefix == None: # prefix does not exist so it must be created try: log.debug("%s %s" % (str(ns), str(changes[ns]["prefix"]))) res = xmp.register_namespace(str(ns), str(changes[ns]["prefix"])) # CHANGE ME except XMPError, err: log.error("Error in register_namespace: %s" % err) for i in changes[ns]["fields"].keys(): try: property_exists = xmp.does_property_exist(str(ns), str(i)) except XMPError, err: log.error("Error in does_property_exist: %s" % err) if changes[ns]["fields"][i]["is_array"] == "not_array": if changes[ns]["fields"][i]["xpath"] != []: # so it is a structure if property_exists == False: # if it is a structure and the property does not exist, # it must be created, otherwise, it will not be set. try: res = xmp.set_property( str(ns), str(i), "", prop_value_is_struct=XMP_PROP_VALUE_IS_STRUCT ) except XMPError, err: log.error("XMPError in set_property in case of structure: %s " % err) except Exception, err: log.error("Error in set_property in case of structure: %s " % err) for index, elem in enumerate(changes[ns]["fields"][i]["value"]): cleaned_xpath = re.sub(r"\[.\]", "", str(changes[ns]["fields"][i]["xpath"][index]))
def log_err(failure): log.error('Error in sending update notifications: %s' % str(failure))