- """ find all dc:creator tags and add dc:creator_parsed with forenames first """
- for creator in doc.findall('//'+DCNS('creator')):
- p = Person.from_text(creator.text)
- creator_parsed = deepcopy(creator)
- creator_parsed.tag = DCNS('creator_parsed')
- creator_parsed.text = ' '.join(p.first_names + (p.last_name,))
- creator.getparent().insert(0, creator_parsed)
+ """Generates readable versions of creator and translator tags.
+
+ Finds all dc:creator and dc.contributor.translator tags
+ and adds *_parsed versions with forenames first.
+ """
+ for person in doc.xpath("|".join('//dc:'+(tag) for tag in (
+ 'creator', 'contributor.translator',
+ 'contributor.editor', 'contributor.technical_editor')),
+ namespaces = {'dc': str(DCNS)})[::-1]:
+ if not person.text:
+ continue
+ p = Person.from_text(person.text)
+ person_parsed = deepcopy(person)
+ person_parsed.tag = person.tag + '_parsed'
+ person_parsed.set('sortkey', person.text)
+ person_parsed.text = p.readable()
+ person.getparent().insert(0, person_parsed)