Skip to content

Commit

Permalink
Patch CodeMeta authors with emails from CFF data
Browse files Browse the repository at this point in the history
  • Loading branch information
sdruskat committed Dec 12, 2023
1 parent cf523da commit dd0df3c
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/hermes/commands/harvest/cff.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,19 @@ def _load_cff_from_file(cff_data: str) -> t.Any:
return yaml.load(cff_data)


def _patch_author_emails(cff_data, codemeta_str):
cff_authors = _load_cff_from_file(cff_data)["authors"]
codemeta = json.loads(codemeta_str)
for i, author in enumerate(cff_authors):
if "email" in author:
codemeta["author"][i]["email"] = author["email"]
return json.dumps(codemeta)


def _convert_cff_to_codemeta(cff_data: str) -> t.Any:
codemeta_str = Citation(cff_data).as_codemeta()
codemeta_str = _patch_author_emails(cff_data, codemeta_str)

return json.loads(codemeta_str)


Expand Down

0 comments on commit dd0df3c

Please sign in to comment.