Skip to content

Commit

Permalink
Updates based on further discussion in PR #56
Browse files Browse the repository at this point in the history
* Update datacite transform to fix errors and add validation to publicationYear
* Update dspace_dim transform for code consistency
  • Loading branch information
ehanson8 committed Mar 14, 2023
1 parent 30a81c6 commit 885bd58
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
16 changes: 10 additions & 6 deletions transmogrifier/sources/datacite.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,14 @@ def get_optional_fields(self, xml: Tag) -> Optional[dict]:

# dates
if publication_year := xml.metadata.find("publicationYear", string=True):
fields["dates"] = [
timdex.Date(
kind="Publication date", value=publication_year.string.strip()
)
]
publication_year = str(publication_year.string.strip())
if validate_date(
publication_year,
source_record_id,
):
fields["dates"] = [
timdex.Date(kind="Publication date", value=publication_year)
]
else:
logger.warning(
"Datacite record %s missing required Datacite field publicationYear",
Expand All @@ -120,7 +123,8 @@ def get_optional_fields(self, xml: Tag) -> Optional[dict]:

for date in xml.metadata.find_all("date"):
d = timdex.Date()
if date_value := str(date.string):
if date_value := date.string:
date_value = str(date_value)
if "/" in date_value:
split = date_value.index("/")
gte_date = date_value[:split].strip()
Expand Down
2 changes: 1 addition & 1 deletion transmogrifier/sources/dspace_dim.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def get_optional_fields(self, xml: Tag) -> Optional[dict]:
)

# dates
for date in [d for d in xml.find_all("dim:field", element="date") if d.string]:
for date in xml.find_all("dim:field", element="date", string=True):
date_value = str(date.string.strip())
if validate_date(date_value, source_record_id):
if date.get("qualifier") == "issued":
Expand Down

0 comments on commit 885bd58

Please sign in to comment.