def checkAllKeysPresent(p_file, p_metatype): #takes a filename and a metadata type (Title, Description, Tags, etc) #and returns true if all keys associated with that metadata type are present in the file #used for testing the metadata editing functions f_metadata = pyexiv2.ImageMetadata(p_file) f_metadata.read() f_keys = MetadataManagerL0.appropriateKeys(p_file, p_metatype) for key in f_keys: if key not in (f_metadata.exif_keys + f_metadata.xmp_keys + f_metadata.iptc_keys): return False return True
def checkAnyKeysPresent(p_file, p_metatype, p_verbose=False): #takes a filename and a metadata type (Title, Description, Tags, etc) #and returns true if any keys associated with that metadata type are present in the file #used for testing the metadata editing functions f_metadata = pyexiv2.ImageMetadata(p_file) f_metadata.read() f_keys = MetadataManagerL0.appropriateKeys(p_file, p_metatype) f_present = [] for key in f_keys: if key in (f_metadata.exif_keys + f_metadata.xmp_keys + f_metadata.iptc_keys): f_present.append(key) if p_verbose: print("In", p_file, "the following", p_metatype, "keys still exist:", f_present) if len(f_present) == 0: return False return True