Page MenuHomeSoftware Heritage

D1061.id3373.diff
No OneTemporary

D1061.id3373.diff

diff --git a/swh/indexer/codemeta.py b/swh/indexer/codemeta.py
--- a/swh/indexer/codemeta.py
+++ b/swh/indexer/codemeta.py
@@ -22,6 +22,10 @@
CODEMETA_CONTEXT = json.load(fd)
CODEMETA_CONTEXT_URL = 'https://doi.org/10.5063/schema/codemeta-2.0'
+CODEMETA_ALTERNATE_CONTEXT_URLS = {
+ ('https://raw.githubusercontent.com/codemeta/codemeta/'
+ 'master/codemeta.jsonld')
+}
CODEMETA_URI = 'https://codemeta.github.io/terms/'
SCHEMA_URI = 'http://schema.org/'
@@ -98,7 +102,7 @@
Reads the local codemeta.jsonld file instead of fetching it
from the Internet every single time."""
- if url == CODEMETA_CONTEXT_URL:
+ if url == CODEMETA_CONTEXT_URL or url in CODEMETA_ALTERNATE_CONTEXT_URLS:
return {
'contextUrl': None,
'documentUrl': url,
diff --git a/swh/indexer/tests/test_metadata.py b/swh/indexer/tests/test_metadata.py
--- a/swh/indexer/tests/test_metadata.py
+++ b/swh/indexer/tests/test_metadata.py
@@ -549,6 +549,21 @@
result = self.codemeta_mapping.translate(raw_content)
self.assertEqual(result, expected_result)
+ def test_compute_metadata_codemeta_alternate_context(self):
+ raw_content = (
+ b"""{
+ "@context": "https://raw.githubusercontent.com/codemeta/codemeta/master/codemeta.jsonld",
+ "@type": "SoftwareSourceCode",
+ "identifier": "CodeMeta"
+ }""") # noqa
+ expected_result = {
+ "@context": "https://doi.org/10.5063/schema/codemeta-2.0",
+ "type": "SoftwareSourceCode",
+ "identifier": "CodeMeta",
+ }
+ result = self.codemeta_mapping.translate(raw_content)
+ self.assertEqual(result, expected_result)
+
def test_compute_metadata_maven(self):
raw_content = b"""
<project>

File Metadata

Mime Type
text/plain
Expires
Thu, Jan 30, 4:29 PM (5 h, 39 m ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3219155

Event Timeline