Skip to content

Commit

Permalink
safeguards for breakign functions
Browse files Browse the repository at this point in the history
  • Loading branch information
dansand committed May 20, 2024
1 parent 19aa009 commit 1f5feb9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .github/scripts/crosswalks.py
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ def metadata_to_nci(ro_crate):
"Abstract*": list_to_string(ro_crate_nested.get_nested(f"{root}.abstract")),
"Topic category*": "geoscientificInformation",
"Field of research (FOR)*": list_to_string(ro_crate_nested.get_nested(f"{root}.about.@id")),
"License*": ro_crate_nested[license_id]['description'],
"License*": ro_crate_nested.get_nested(f"{root}.license.description"),
"Dataset lineage information*": list_to_string(ro_crate_nested.get_nested(f"{root}.description")),
"Dataset format*": "",
"Dataset status": list_to_string(ro_crate_nested.get_nested(f"{root}.creativeWorkStatus")),
Expand Down
18 changes: 9 additions & 9 deletions .github/scripts/nci_iso_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ def list_to_string(value):


def extract_creator_details(ro_crate_nested):
creators = [ro_crate_nested[key] for key in ro_crate_nested if key.startswith("http://orcid.org/")]
creators = ro_crate_nested.get('root', {}).get('creator', [])
creator_details = []
for creator in creators:
details = {
"Last name": creator.get("familyName", ""),
"First name": creator.get("givenName", ""),
"Organization": "Unknown", # Placeholder, as organization is not directly provided
"Email": "Unknown", # Placeholder, as email is not directly provided
"ORCID ID": creator["@id"]
"Last name": creator.get("familyName", "Unknown"), # Default to "Unknown" if not provided
"First name": creator.get("givenName", "Unknown"), # Default to "Unknown" if not provided
"Organization": creator.get("affiliation", {}).get("name", "Unknown") if "affiliation" in creator else "Unknown",
"Email": creator.get("email", "Unknown"), # Default to "Unknown" if not provided
"ORCID ID": creator.get("@id", "Unknown") # Default to "Unknown" if not provided
}
creator_details.append(details)
return creator_details
Expand All @@ -44,7 +44,7 @@ def extract_funder_details(ro_crate_nested):
for funder in root_funders:
# Use the funder record directly if it doesn't have an '@id'
if "@id" in funder:
funder_details = ro_crate_nested[funder["@id"]]
funder_details = ro_crate_nested.get(funder["@id"], {})
else:
funder_details = funder
funders.append({
Expand All @@ -57,11 +57,11 @@ def extract_funder_details(ro_crate_nested):
root_fundings = ro_crate_nested.get_nested('root.funding') or []
for funding in root_fundings:
if "@id" in funding:
funding_details = ro_crate_nested[funding["@id"]]
funding_details = ro_crate_nested.get(funding["@id"], {})
# Handle nested 'funder' information within 'funding'
if "funder" in funding_details:
if "@id" in funding_details["funder"]:
funder_info = ro_crate_nested[funding_details["funder"]["@id"]]
funder_info = ro_crate_nested.get(funding_details["funder"]["@id"], {})
else:
funder_info = funding_details["funder"]
funder_name = funder_info.get("name", "Unknown")
Expand Down

0 comments on commit 1f5feb9

Please sign in to comment.