trans = etree.parse('translations.xml') values = trans.xpath('//value') matches_by_tag = {value.attrib['tag']: set() for value in values} matches_by_file_by_tag = {value.attrib['tag']: {} for value in values} matches_by_exiftag = {value.attrib['tag']: {} for value in values} matches_by_file = {} tags_command.set_defaults(func=print_tag2tag, matches_by_tag=matches_by_tag) matches_command.set_defaults(func=print_tag2file2tag, matches_by_file_by_tag=matches_by_file_by_tag) validation_command.set_defaults(func=print_validation_file, matches_by_exiftag=matches_by_exiftag) numtags_command.set_defaults(func=print_numtags, matches_by_file=matches_by_file) numtagscsv_command.set_defaults(func=print_csv, matches_by_file=matches_by_file) args = parser.parse_args() exceptions = [] example_files = getExampleFiles(args.exampledir) for filename in example_files: exif = getExifXml(filename) matches_by_file[filename] = {} for value in values: all_matches = [] for num, source in enumerate(value.getiterator('source')): valid = source.attrib["valid"] if valid == "false": continue parent = source.getparent() if parent.tag == 'priorityGroup': if 'ordered' in parent.attrib: num = '%s.%s' % (parent.getparent().index(parent), parent.index(source)) else: num = str(parent.getparent().index(parent)) else: num = None
def getKeys(fname): content = getExifXml(fname) nodes = content.xpath('/rdf:RDF/rdf:Description/*', namespaces=ns) names = set([nameElements(node) for node in nodes]) return names