Page Menu
Home
Software Heritage
Search
Configure Global Search
Log In
Files
F7163831
D1061.id3373.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Subscribers
None
D1061.id3373.diff
View Options
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
Details
Attached
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
Attached To
D1061: Add support for an alternate codemeta context URL.
Event Timeline
Log In to Comment