Skip to content

Commit

Permalink
fix: add the wgs namespace binding back (#2294)
Browse files Browse the repository at this point in the history
<#1686> inadvertently removed the `wgs` prefix.
This change adds it back.

- Closes <#2196>.
  • Loading branch information
aucampia committed Mar 21, 2023
1 parent fe1a8f8 commit adf8eb2
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 1 deletion.
3 changes: 2 additions & 1 deletion rdflib/namespace/__init__.py
Expand Up @@ -365,7 +365,7 @@ class NamespaceManager(object):
* binds all the namespaces shipped with RDFLib as DefinedNamespace instances
* all the core namespaces and all the following: brick, csvw, dc, dcat
* dcmitype, dcterms, dcam, doap, foaf, geo, odrl, org, prof, prov, qb, sdo
* sh, skos, sosa, ssn, time, vann, void
* sh, skos, sosa, ssn, time, vann, void, wgs
* see the NAMESPACE_PREFIXES_RDFLIB object for the up-to-date list
* none:
* binds no namespaces to prefixes
Expand Down Expand Up @@ -914,4 +914,5 @@ def get_longest_namespace(trie: Dict[str, Any], value: str) -> Optional[str]:
"time": TIME,
"vann": VANN,
"void": VOID,
"wgs": WGS,
}
51 changes: 51 additions & 0 deletions test/test_namespacemanager.py
Expand Up @@ -172,6 +172,57 @@ def test_nman_bind_namespaces(
check_graph_ns(graph, expected_result)


@pytest.mark.parametrize(
["selector", "expected_bindings"],
[
(
"rdflib",
{
"brick": "https://brickschema.org/schema/Brick#",
"csvw": "http://www.w3.org/ns/csvw#",
"dc": "http://purl.org/dc/elements/1.1/",
"dcat": "http://www.w3.org/ns/dcat#",
"dcmitype": "http://purl.org/dc/dcmitype/",
"dcterms": "http://purl.org/dc/terms/",
"dcam": "http://purl.org/dc/dcam/",
"doap": "http://usefulinc.com/ns/doap#",
"foaf": "http://xmlns.com/foaf/0.1/",
"odrl": "http://www.w3.org/ns/odrl/2/",
"geo": "http://www.opengis.net/ont/geosparql#",
"org": "http://www.w3.org/ns/org#",
"owl": "http://www.w3.org/2002/07/owl#",
"prof": "http://www.w3.org/ns/dx/prof/",
"prov": "http://www.w3.org/ns/prov#",
"qb": "http://purl.org/linked-data/cube#",
"rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
"rdfs": "http://www.w3.org/2000/01/rdf-schema#",
"sdo": "https://schema.org/",
"sh": "http://www.w3.org/ns/shacl#",
"skos": "http://www.w3.org/2004/02/skos/core#",
"sosa": "http://www.w3.org/ns/sosa/",
"ssn": "http://www.w3.org/ns/ssn/",
"time": "http://www.w3.org/2006/time#",
"vann": "http://purl.org/vocab/vann/",
"void": "http://rdfs.org/ns/void#",
"wgs": "https://www.w3.org/2003/01/geo/wgs84_pos#",
"xsd": "http://www.w3.org/2001/XMLSchema#",
"xml": "http://www.w3.org/XML/1998/namespace",
},
)
],
)
def test_bound_namespaces_subset(
selector: Any, expected_bindings: Dict[str, str]
) -> None:
graph = Graph(bind_namespaces=selector)
bound_namespaces = dict(
(key, str(value)) for key, value in graph.namespace_manager.namespaces()
)
assert (
expected_bindings.items() <= bound_namespaces.items()
), f"missing items {expected_bindings.items() - bound_namespaces.items()}"


def test_compute_qname_no_generate() -> None:
g = Graph() # 'core' bind_namespaces (default)
with pytest.raises(KeyError):
Expand Down

0 comments on commit adf8eb2

Please sign in to comment.