diff options
Diffstat (limited to 'bsfs/triple_store/sparql')
-rw-r--r-- | bsfs/triple_store/sparql/parse_filter.py | 6 | ||||
-rw-r--r-- | bsfs/triple_store/sparql/sparql.py | 10 |
2 files changed, 4 insertions, 12 deletions
diff --git a/bsfs/triple_store/sparql/parse_filter.py b/bsfs/triple_store/sparql/parse_filter.py index 8959b2c..bf19a02 100644 --- a/bsfs/triple_store/sparql/parse_filter.py +++ b/bsfs/triple_store/sparql/parse_filter.py @@ -154,7 +154,7 @@ class Filter(): puri = f'<{puri}>' # type: ignore [assignment] # variable re-use confuses mypy # apply reverse flag if node.reverse: - puri = URI('^' + puri) + puri = '^' + puri dom, rng = rng, dom # type: ignore [assignment] # variable re-use confuses mypy # check path consistency if not node_type <= dom: @@ -267,9 +267,7 @@ class Filter(): """ if not isinstance(node_type, bsc.Node): raise errors.BackendError(f'expected Node, found {node_type}') - if not rdflib.term._is_valid_uri(node.value): # pylint: disable=protected-access - raise errors.BackendError(f'<{node.value}> is not a serializable uri') - return f'VALUES {head} {{ <{node.value}> }}' + return f'VALUES {head} {{ <{URI(node.value)}> }}' def _equals(self, node_type: bsc.Vertex, node: ast.filter.Equals, head: str) -> str: """ diff --git a/bsfs/triple_store/sparql/sparql.py b/bsfs/triple_store/sparql/sparql.py index bd98f46..68c0027 100644 --- a/bsfs/triple_store/sparql/sparql.py +++ b/bsfs/triple_store/sparql/sparql.py @@ -284,10 +284,7 @@ class SparqlStore(base.TripleStoreBase): raise errors.ConsistencyError(f'{node_type} is not defined in the schema') # check and create guids for guid in guids: - # check convert to rdflib.URIRef - if not rdflib.term._is_valid_uri(guid): # pylint: disable=protected-access - raise ValueError(guids) - subject = rdflib.URIRef(guid) + subject = rdflib.URIRef(URI(guid)) # check node existence if (subject, rdflib.RDF.type, None) in self._graph: # FIXME: node exists and may have a different type! ignore? raise? report? @@ -326,10 +323,7 @@ class SparqlStore(base.TripleStoreBase): raise errors.InstanceError(inconsistent) # check guids # FIXME: Fail or skip inexistent nodes? - guids = set(guids) - invalid = {guid for guid in guids if not rdflib.term._is_valid_uri(guid)} # pylint: disable=protected-access - if len(invalid) > 0: - raise ValueError(invalid) + guids = {URI(guid) for guid in guids} inconsistent = {guid for guid in guids if not self._has_type(guid, node_type)} if len(inconsistent) > 0: raise errors.InstanceError(inconsistent) |