Skip to content

Commit adf8eb2

Browse files
authored
fix: add the wgs namespace binding back (#2294)
<#1686> inadvertently removed the `wgs` prefix. This change adds it back. - Closes <#2196>.
1 parent fe1a8f8 commit adf8eb2

File tree

2 files changed

+53
-1
lines changed

2 files changed

+53
-1
lines changed

rdflib/namespace/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ class NamespaceManager(object):
365365
* binds all the namespaces shipped with RDFLib as DefinedNamespace instances
366366
* all the core namespaces and all the following: brick, csvw, dc, dcat
367367
* dcmitype, dcterms, dcam, doap, foaf, geo, odrl, org, prof, prov, qb, sdo
368-
* sh, skos, sosa, ssn, time, vann, void
368+
* sh, skos, sosa, ssn, time, vann, void, wgs
369369
* see the NAMESPACE_PREFIXES_RDFLIB object for the up-to-date list
370370
* none:
371371
* binds no namespaces to prefixes
@@ -914,4 +914,5 @@ def get_longest_namespace(trie: Dict[str, Any], value: str) -> Optional[str]:
914914
"time": TIME,
915915
"vann": VANN,
916916
"void": VOID,
917+
"wgs": WGS,
917918
}

test/test_namespacemanager.py

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,57 @@ def test_nman_bind_namespaces(
172172
check_graph_ns(graph, expected_result)
173173

174174

175+
@pytest.mark.parametrize(
176+
["selector", "expected_bindings"],
177+
[
178+
(
179+
"rdflib",
180+
{
181+
"brick": "https://brickschema.org/schema/Brick#",
182+
"csvw": "http://www.w3.org/ns/csvw#",
183+
"dc": "http://purl.org/dc/elements/1.1/",
184+
"dcat": "http://www.w3.org/ns/dcat#",
185+
"dcmitype": "http://purl.org/dc/dcmitype/",
186+
"dcterms": "http://purl.org/dc/terms/",
187+
"dcam": "http://purl.org/dc/dcam/",
188+
"doap": "http://usefulinc.com/ns/doap#",
189+
"foaf": "http://xmlns.com/foaf/0.1/",
190+
"odrl": "http://www.w3.org/ns/odrl/2/",
191+
"geo": "http://www.opengis.net/ont/geosparql#",
192+
"org": "http://www.w3.org/ns/org#",
193+
"owl": "http://www.w3.org/2002/07/owl#",
194+
"prof": "http://www.w3.org/ns/dx/prof/",
195+
"prov": "http://www.w3.org/ns/prov#",
196+
"qb": "http://purl.org/linked-data/cube#",
197+
"rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
198+
"rdfs": "http://www.w3.org/2000/01/rdf-schema#",
199+
"sdo": "https://schema.org/",
200+
"sh": "http://www.w3.org/ns/shacl#",
201+
"skos": "http://www.w3.org/2004/02/skos/core#",
202+
"sosa": "http://www.w3.org/ns/sosa/",
203+
"ssn": "http://www.w3.org/ns/ssn/",
204+
"time": "http://www.w3.org/2006/time#",
205+
"vann": "http://purl.org/vocab/vann/",
206+
"void": "http://rdfs.org/ns/void#",
207+
"wgs": "https://www.w3.org/2003/01/geo/wgs84_pos#",
208+
"xsd": "http://www.w3.org/2001/XMLSchema#",
209+
"xml": "http://www.w3.org/XML/1998/namespace",
210+
},
211+
)
212+
],
213+
)
214+
def test_bound_namespaces_subset(
215+
selector: Any, expected_bindings: Dict[str, str]
216+
) -> None:
217+
graph = Graph(bind_namespaces=selector)
218+
bound_namespaces = dict(
219+
(key, str(value)) for key, value in graph.namespace_manager.namespaces()
220+
)
221+
assert (
222+
expected_bindings.items() <= bound_namespaces.items()
223+
), f"missing items {expected_bindings.items() - bound_namespaces.items()}"
224+
225+
175226
def test_compute_qname_no_generate() -> None:
176227
g = Graph() # 'core' bind_namespaces (default)
177228
with pytest.raises(KeyError):

0 commit comments

Comments
 (0)