Пример #1
0
def oai_dc_writer(element, metadata):
    e_dc = SubElement(element, nsoaidc('dc'),
                      nsmap={'oai_dc': NS_OAIDC, 'dc': NS_DC, 'xsi': NS_XSI})
    e_dc.set('{%s}schemaLocation' % NS_XSI,
             '%s http://www.openarchives.org/OAI/2.0/oai_dc.xsd' % NS_DC)
    map = metadata.getMap()
    for name in [
        'title', 'creator', 'subject', 'description', 'publisher',
        'contributor', 'date', 'type', 'format', 'identifier',
        'source', 'language', 'relation', 'coverage', 'rights']:
        for value in map.get(name, []):
            e = SubElement(e_dc, nsdc(name))
            e.text = value
Пример #2
0
def oai_dc_writer(element, metadata):
    e_dc = SubElement(element, nsoaidc('dc'),
                      nsmap={'oai_dc': NS_OAIDC, 'dc': NS_DC, 'xsi': NS_XSI})
    e_dc.set('{%s}schemaLocation' % NS_XSI,
             '%s http://www.openarchives.org/OAI/2.0/oai_dc.xsd' % NS_DC)
    map = metadata.getMap()
    for name in [
        'title', 'creator', 'subject', 'description', 'publisher',
        'contributor', 'date', 'type', 'format', 'identifier',
        'source', 'language', 'relation', 'coverage', 'rights']:
        for value in map.get(name, []):
            e = SubElement(e_dc, nsdc(name))
            e.text = value
Пример #3
0
def print_records(records, max_recs = 5):
    print '****** Printing data ******'
    # for large collections this breaks
    count = 1

    for record in records:
        header, metadata, about = record
        map = metadata.getMap()
        print '****** Current record: %s' % header.identifier()
        for key, value in map.items():
            print '  ', key, ':', value
            
        if count > max_recs: break
        count += 1
Пример #4
0
def lang_aware_oai_dc_writer(element, metadata):
    e_dc = SubElement(
        element,
        server.nsoaidc("dc"),
        nsmap={
            "oai_dc": server.NS_OAIDC,
            "dc": server.NS_DC,
            "xsi": server.NS_XSI
        },
    )
    e_dc.set(
        "{%s}schemaLocation" % server.NS_XSI,
        "%s http://www.openarchives.org/OAI/2.0/oai_dc.xsd" % server.NS_DC,
    )
    map = metadata.getMap()
    for name in [
            "title",
            "creator",
            "subject",
            "description",
            "publisher",
            "contributor",
            "date",
            "type",
            "format",
            "identifier",
            "source",
            "language",
            "relation",
            "coverage",
            "rights",
    ]:
        for value in map.get(name, []):
            e = SubElement(e_dc, server.nsdc(name))
            if isinstance(value, dict):
                e.text = value["text"]
                if "lang" in value:
                    e.set("{http://www.w3.org/XML/1998/namespace}lang",
                          value["lang"])
            else:
                e.text = value