From 9725815e43159078557534eed7e410a844a72e5d Mon Sep 17 00:00:00 2001 From: Christian Tacke <58549698+ChristianTackeGSI@users.noreply.github.com> Date: Thu, 3 Aug 2023 11:25:53 +0200 Subject: [PATCH] fix: Only handle "Person"s in contacts Codemeta also allows "Organizations" in some contact fields (author, contributor, creator, ...). And for example "maintainer" will also allow Organizations in Codemeta 4.0 [1]. The current conversion code (to zenodo) only needs to handle Persons. So make sure that only Persons are handled and everything else is ignored. [1]: https://github.com/codemeta/codemeta/pull/250#issuecomment-1660417541 --- eossr/metadata/codemeta2zenodo.py | 9 +++++++-- .../tests/samples/codemeta_contributors_sample.json | 5 +++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/eossr/metadata/codemeta2zenodo.py b/eossr/metadata/codemeta2zenodo.py index 4233e33..61fd2d8 100644 --- a/eossr/metadata/codemeta2zenodo.py +++ b/eossr/metadata/codemeta2zenodo.py @@ -38,6 +38,9 @@ def parse_person_schema_property(person_property, contributor_field): dictionary with the correct zenodo syntax for all {author, contributor, maintainer}. """ + if person_property["@type"] != "Person": + return None + zenodo_person = {} name = person_property['familyName'] @@ -93,10 +96,12 @@ def add_author_metadata(zenodo_file, codemt_person_entry, person_field): zenodo_person = parse_person_schema_property(person_property, person_field) # 'name' is the only key that MUST be contained in a # person_property at least - full_contacts[zenodo_person['name']] = zenodo_person + if zenodo_person is not None: + full_contacts[zenodo_person['name']] = zenodo_person else: zenodo_person = parse_person_schema_property(codemt_person_entry, person_field) - full_contacts[zenodo_person['name']] = zenodo_person + if zenodo_person is not None: + full_contacts[zenodo_person['name']] = zenodo_person # then save each person by field and avoid duplicates for person, value in full_contacts.items(): diff --git a/eossr/metadata/tests/samples/codemeta_contributors_sample.json b/eossr/metadata/tests/samples/codemeta_contributors_sample.json index 6a27134..f4b73a1 100644 --- a/eossr/metadata/tests/samples/codemeta_contributors_sample.json +++ b/eossr/metadata/tests/samples/codemeta_contributors_sample.json @@ -38,6 +38,11 @@ "@id": "https://orcid.org/0000-0000-0000-0000" }, "contributor": [ + { + "@type": "ResearchOrganization", + "@id": "https://ror.org/", + "name:": "Some Research Org" + }, { "@type": "Person", "givenName": "Contributor-name", -- GitLab