Skip to content
Snippets Groups Projects
Commit d3b661db authored by vlorentz's avatar vlorentz
Browse files

Avoid discarding whole nodes when their URI is invalid

parent d096d44f
No related branches found
No related tags found
1 merge request!533Avoid discarding whole nodes when their URI is invalid
Pipeline #12371 passed
......@@ -77,7 +77,12 @@ def codemeta_to_bibtex(
identifiers.append(doc["identifier"])
doc = expand(doc)
g = rdflib.Graph().parse(data=json.dumps(doc), format="json-ld")
g = rdflib.Graph().parse(
data=json.dumps(doc),
format="json-ld",
# replace invalid URIs with blank node ids, instead of discarding whole nodes:
generalized_rdf=True,
)
persons: Dict[str, List[Person]] = collections.defaultdict(list)
fields: Dict[str, Any] = {}
......
......@@ -276,6 +276,58 @@ def test_affiliation():
)
def test_author_id():
assert codemeta_to_bibtex(
{
"@context": "https://doi.org/10.5063/schema/codemeta-2.0",
"author": {
"name": "Jane Doe",
"id": "https://orcid.org/0000-0002-2771-9344",
},
"name": "Example Software",
"url": "http://example.org/",
"datePublished": "2023-10-10",
}
) == textwrap.dedent(
"""\
@software{REPLACEME,
author = "Doe, Jane",
date = "2023-10-10",
year = "2023",
month = oct,
title = "Example Software",
url = "http://example.org/"
}
"""
)
def test_author_invalid_id():
assert codemeta_to_bibtex(
{
"@context": "https://doi.org/10.5063/schema/codemeta-2.0",
"author": {
"name": "Jane Doe",
"id": "https://orcid.org/ 0000-0002-2771-9344",
},
"name": "Example Software",
"url": "http://example.org/",
"datePublished": "2023-10-10",
}
) == textwrap.dedent(
"""\
@software{REPLACEME,
author = "Doe, Jane",
date = "2023-10-10",
year = "2023",
month = oct,
title = "Example Software",
url = "http://example.org/"
}
"""
)
def test_invalid_date():
assert codemeta_to_bibtex(
{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment