Skip to content

Commit

Permalink
feat: check if orcid is valid before writing
Browse files Browse the repository at this point in the history
  • Loading branch information
rmfranken committed Nov 20, 2024
1 parent 5238b64 commit 5645f6d
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions gimie/parsers/cff.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,16 @@ def parse(self, data: bytes) -> Graph:
if not authors:
return extracted_cff_triples
for author in authors:
if author["orcid"]:
orcid = URIRef(author["orcid"])
if re.match(
r"https:\/\/orcid.org\/\d{4}-\d{4}-\d{4}-\d{4}", str(orcid)
):
extracted_cff_triples.add(
(self.subject, SDO.author, URIRef(author["orcid"]))
(self.subject, SDO.author, URIRef(orcid))
)
extracted_cff_triples.add(
(
URIRef(author["orcid"]),
URIRef(orcid),
SDO.name,
Literal(
author["given-names"]
Expand All @@ -68,21 +71,19 @@ def parse(self, data: bytes) -> Graph:
)
extracted_cff_triples.add(
(
URIRef(author["orcid"]),
orcid,
MD4I.orcidId,
Literal(author["orcid"]),
Literal(orcid),
)
)
extracted_cff_triples.add(
(
URIRef(author["orcid"]),
orcid,
SDO.affiliation,
Literal(author["affiliation"]),
)
)
extracted_cff_triples.add(
(URIRef(author["orcid"]), RDF.type, SDO.Person)
)
extracted_cff_triples.add((orcid, RDF.type, SDO.Person))
return extracted_cff_triples


Expand Down

0 comments on commit 5645f6d

Please sign in to comment.