Skip to content

Commit

Permalink
fix: DOI from dict, not flat value
Browse files Browse the repository at this point in the history
  • Loading branch information
rmfranken committed Dec 16, 2024
1 parent 477ab88 commit 0eb1423
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions gimie/parsers/cff.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,15 @@ def get_cff_doi(data: bytes) -> Optional[str]:
except yaml.scanner.ScannerError:
logger.warning("cannot read CITATION.cff, skipped.")
return None

try:
doi_url = doi_to_url(cff["doi"])
identifiers = cff.get("identifiers", [])
doi_identifier = next(
(id for id in identifiers if id.get("type") == "doi"), None
)
if doi_identifier:
doi_url = doi_to_url(doi_identifier["value"])
else:
raise KeyError("No DOI found in identifiers")
# No doi in cff file
except (KeyError, TypeError):
logger.warning("CITATION.cff does not contain a 'doi' key.")
Expand Down

0 comments on commit 0eb1423

Please sign in to comment.