diff --git a/swh/indexer/codemeta.py b/swh/indexer/codemeta.py index ea502b1..86da517 100644 --- a/swh/indexer/codemeta.py +++ b/swh/indexer/codemeta.py @@ -146,6 +146,13 @@ def compact(doc, forgefed: bool): This is typically used for extrinsic metadata documents, which frequently use properties from these namespaces. """ + if "@context" in doc and isinstance(doc["@context"], list): + # workaround pyld issue (https://github.com/digitalbazaar/pyld/issues/154) + doc["@context"] = [ + context + for context in doc["@context"] + if not context.endswith("/schema.org") + ] contexts: List[Any] = [CODEMETA_CONTEXT_URL] if forgefed: contexts.append( diff --git a/swh/indexer/tests/test_bibtex.py b/swh/indexer/tests/test_bibtex.py index a820861..925164c 100644 --- a/swh/indexer/tests/test_bibtex.py +++ b/swh/indexer/tests/test_bibtex.py @@ -299,6 +299,34 @@ def test_invalid_date(): ) +def test_context_contains_schema_org(): + assert codemeta_to_bibtex( + { + "@context": [ + "https://doi.org/10.5063/schema/codemeta-2.0", + "http://schema.org", + ], + "author": {"name": "Jane Doe"}, + "name": "Example Software", + "url": "http://example.org/", + "datePublished": "2023-10-10", + "license": "https://spdx.org/licenses/Apache-2.0", + } + ) == textwrap.dedent( + """\ + @software{REPLACEME, + author = "Doe, Jane", + license = "Apache-2.0", + date = "2023-10-10", + year = "2023", + month = oct, + title = "Example Software", + url = "http://example.org/" + } + """ + ) + + def test_cff_empty(): assert cff_to_bibtex("") == textwrap.dedent( """\