Skip to content
This repository has been archived by the owner on Jun 2, 2022. It is now read-only.

Commit

Permalink
whoas error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
ehanson8 committed Sep 21, 2020
1 parent 800c32d commit 3751547
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions hoard/sources/whoas.py
Expand Up @@ -19,6 +19,12 @@
)


namespace = {
"oai": "http://www.openarchives.org/OAI/2.0/",
"dim": "http://www.dspace.org/xmlns/dspace/dim",
}


class WHOAS:
def __init__(self, client: OAIClient) -> None:
self.client = client
Expand All @@ -27,18 +33,19 @@ def __iter__(self) -> Iterator[Dataset]:
return self

def __next__(self) -> Dataset:
record = next(self.client)
dataset = create_from_whoas_dim_xml(record)
return dataset
while True:
record = next(self.client)
parsed_record = ET.fromstring(record)
if parsed_record.find(".//oai:error", namespace) is not None:
continue
else:
dataset = create_from_whoas_dim_xml(record)
return dataset


def create_from_whoas_dim_xml(data: str) -> Dataset:
kwargs: Dict[str, Any] = {}
record = ET.fromstring(data)
namespace = {
"oai": "http://www.openarchives.org/OAI/2.0/",
"dim": "http://www.dspace.org/xmlns/dspace/dim",
}
fields = record.findall(".//dim:field", namespace)
authors = []
contacts = [
Expand Down

0 comments on commit 3751547

Please sign in to comment.