def oai_records(tree): """ Iterate over OAI-PMH records """ records = ns_path("OAI-PMH.ListRecords.record").find(tree.getroot()) for r in records: try: header = ns_path(".header").find(r)[0] meta = ns_path(".metadata."+ns_oai_dc('dc')).find(r)[0] yield merge(children_to_list(header, ns_oai()) + children_to_list(meta, ns_dc())) except Exception as e: print e
def oai_identifiers(tree): """ Iterate over OAI-PMH headers """ headers = path("OAI-PMH.ListIdentifiers.header").find(tree.getroot()) for h in headers: yield merge(children_to_list(h, ns_oai()))