about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMunyoki Kilyungi2024-08-29 23:18:21 +0300
committerBonfaceKilz2024-09-05 16:39:14 +0300
commit6e69b99f36a72079ff0b483f8dce4af0a4c06457 (patch)
treebe94d501562157fbe0fbe28f2e1efc9572b94c1e
parentab4e918da28ec09bf39ad38d79200b68baf28f17 (diff)
downloadgenenetwork3-6e69b99f36a72079ff0b483f8dce4af0a4c06457.tar.gz
Create global wiki context usable by all functions in gn3.rdf.wiki
Signed-off-by: Munyoki Kilyungi <me@bonfacemunyoki.com>
-rw-r--r--gn3/db/rdf/wiki.py44
1 files changed, 23 insertions, 21 deletions
diff --git a/gn3/db/rdf/wiki.py b/gn3/db/rdf/wiki.py
index 1fc3130..f902455 100644
--- a/gn3/db/rdf/wiki.py
+++ b/gn3/db/rdf/wiki.py
@@ -6,6 +6,28 @@ from gn3.db.rdf import (BASE_CONTEXT, RDF_PREFIXES,
                         query_frame_and_compact)
 
 
+WIKI_CONTEXT = BASE_CONTEXT | {
+    "foaf": "http://xmlns.com/foaf/0.1/",
+    "dct": "http://purl.org/dc/terms/",
+    "categories": "gnt:belongsToCategory",
+    "web_url": "foaf:homepage",
+    "version": "gnt:hasVersion",
+    "symbol": "rdfs:label",
+    "reason": "gnt:reason",
+    "species": "gnt:species",
+    "pubmed_id": "dct:references",
+    "email": "foaf:mbox",
+    "initial": "gnt:initial",
+    "comment": "rdfs:comment",
+    "created": "dct:created",
+    "id": "dct:identifier",
+    # This points to the RDF Node which is the unique identifier
+    # for this triplet.  It's constructed using the comment-id and
+    # the comment-versionId
+    "wiki_identifier": "@id",
+}
+
+
 def get_wiki_entries_by_symbol(symbol: str, sparql_uri: str) -> dict:
     """Fetch all the Wiki entries using the symbol"""
     # This query uses a sub-query to fetch the latest comment by the
@@ -61,28 +83,8 @@ CONSTRUCT {
     BIND (str(?createTime) AS ?created) .
 }
 """).substitute(prefix=RDF_PREFIXES, symbol=symbol,)
-    context = BASE_CONTEXT | {
-        "foaf": "http://xmlns.com/foaf/0.1/",
-        "dct": "http://purl.org/dc/terms/",
-        "categories": "gnt:belongsToCategory",
-        "web_url": "foaf:homepage",
-        "version": "gnt:hasVersion",
-        "symbol": "rdfs:label",
-        "reason": "gnt:reason",
-        "species": "gnt:species",
-        "pubmed_id": "dct:references",
-        "email": "foaf:mbox",
-        "initial": "gnt:initial",
-        "comment": "rdfs:comment",
-        "created": "dct:created",
-        "id": "dct:identifier",
-        # This points to the RDF Node which is the unique identifier
-        # for this triplet.  It's constructed using the comment-id and
-        # the comment-versionId
-        "wiki_identifier": "@id",
-    }
     results = query_frame_and_compact(
-        query, context,
+        query, WIKI_CONTEXT,
         sparql_uri
     )
     data = results.get("data")