Beispiel #1
0
def parse_creator(doc):
    """ find all dc:creator and dc.contributor tags and add *_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)
Beispiel #2
0
def parse_creator(doc):
    """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')),
                            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)
Beispiel #3
0
def parse_creator(doc):
    """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")), 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)
Beispiel #4
0
 def person_name(context, text):
     """ Converts "Name, Forename" to "Forename Name" """
     if isinstance(text, list):
         text = ''.join(text)
     return Person.from_text(text).readable()
Beispiel #5
0
 def person_name(context, text):
     """ Converts "Name, Forename" to "Forename Name" """
     if isinstance(text, list):
         text = ''.join(text)
     return Person.from_text(text).readable()