Skip to content

Commit

Permalink
fix: change the https://schema.org/ prefix back to schema` and add…
Browse files Browse the repository at this point in the history
… the `wgs` binding back

<#1686> inadvertently changed the prefix
for `https://schema.org/` from `schema` to `sdo` and removed the `wgs` prefix.
This PR changes the `https://schema.org/` binding back to `schema` and adds the
`wgs` binding back.

- Closes <#2196>.
  • Loading branch information
aucampia committed Mar 19, 2023
1 parent 7a05c15 commit 0940997
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 3 deletions.
7 changes: 4 additions & 3 deletions rdflib/namespace/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -364,8 +364,8 @@ class NamespaceManager(object):
* rdflib:
* 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
* dcmitype, dcterms, dcam, doap, foaf, geo, odrl, org, prof, prov, qb, schema
* 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 @@ -906,12 +906,13 @@ def get_longest_namespace(trie: Dict[str, Any], value: str) -> Optional[str]:
"prof": PROF,
"prov": PROV,
"qb": QB,
"sdo": SDO,
"schema": SDO,
"sh": SH,
"skos": SKOS,
"sosa": SOSA,
"ssn": SSN,
"time": TIME,
"vann": VANN,
"void": VOID,
"wgs": WGS,
}
51 changes: 51 additions & 0 deletions test/test_namespacemanager.py
Original file line number Diff line number Diff line change
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#",
"schema": "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 0940997

Please sign in to comment.