-
Notifications
You must be signed in to change notification settings - Fork 577
Open
Labels
7.0Changes planned for version 7Changes planned for version 7breaking changeThis involves or proposes breaking RDFLib's public API.This involves or proposes breaking RDFLib's public API.cleanup
Description
I'm not sure why these methods exists:
rdflib/rdflib/plugins/stores/sparqlstore.py
Lines 379 to 442 in 0856ac8
# Namespace persistence interface implementation | |
def bind(self, prefix, namespace, override=True): | |
bound_prefix = self.prefix(namespace) | |
if override and bound_prefix: | |
del self.nsBindings[bound_prefix] | |
self.nsBindings[prefix] = namespace | |
def prefix(self, namespace): | |
""" """ | |
return dict([(v, k) for k, v in self.nsBindings.items()]).get(namespace) | |
def namespace(self, prefix): | |
return self.nsBindings.get(prefix) | |
def namespaces(self): | |
for prefix, ns in self.nsBindings.items(): | |
yield prefix, ns | |
def add_graph(self, graph): | |
raise TypeError("The SPARQL store is read only") | |
def remove_graph(self, graph): | |
raise TypeError("The SPARQL store is read only") | |
def _is_contextual(self, graph): | |
"""Returns `True` if the "GRAPH" keyword must appear | |
in the final SPARQL query sent to the endpoint. | |
""" | |
if (not self.context_aware) or (graph is None): | |
return False | |
if isinstance(graph, str): | |
return graph != "__UNION__" | |
else: | |
return graph.identifier != DATASET_DEFAULT_GRAPH_ID | |
def subjects(self, predicate=None, object=None): | |
"""A generator of subjects with the given predicate and object""" | |
for t, c in self.triples((None, predicate, object)): | |
yield t[0] | |
def predicates(self, subject=None, object=None): | |
"""A generator of predicates with the given subject and object""" | |
for t, c in self.triples((subject, None, object)): | |
yield t[1] | |
def objects(self, subject=None, predicate=None): | |
"""A generator of objects with the given subject and predicate""" | |
for t, c in self.triples((subject, predicate, None)): | |
yield t[2] | |
def subject_predicates(self, object=None): | |
"""A generator of (subject, predicate) tuples for the given object""" | |
for t, c in self.triples((None, None, object)): | |
yield t[0], t[1] | |
def subject_objects(self, predicate=None): | |
"""A generator of (subject, object) tuples for the given predicate""" | |
for t, c in self.triples((None, predicate, None)): | |
yield t[0], t[2] | |
def predicate_objects(self, subject=None): | |
"""A generator of (predicate, object) tuples for the given subject""" | |
for t, c in self.triples((subject, None, None)): | |
yield t[1], t[2] |
rdflib/rdflib/plugins/stores/sparqlstore.py
Lines 839 to 875 in 0856ac8
def remove_graph(self, graph): | |
if not self.graph_aware: | |
Store.remove_graph(self, graph) | |
elif graph.identifier == DATASET_DEFAULT_GRAPH_ID: | |
self.update("DROP DEFAULT") | |
else: | |
self.update("DROP GRAPH %s" % self.node_to_sparql(graph.identifier)) | |
def subjects(self, predicate=None, object=None): | |
"""A generator of subjects with the given predicate and object""" | |
for t, c in self.triples((None, predicate, object)): | |
yield t[0] | |
def predicates(self, subject=None, object=None): | |
"""A generator of predicates with the given subject and object""" | |
for t, c in self.triples((subject, None, object)): | |
yield t[1] | |
def objects(self, subject=None, predicate=None): | |
"""A generator of objects with the given subject and predicate""" | |
for t, c in self.triples((subject, predicate, None)): | |
yield t[2] | |
def subject_predicates(self, object=None): | |
"""A generator of (subject, predicate) tuples for the given object""" | |
for t, c in self.triples((None, None, object)): | |
yield t[0], t[1] | |
def subject_objects(self, predicate=None): | |
"""A generator of (subject, object) tuples for the given predicate""" | |
for t, c in self.triples((None, predicate, None)): | |
yield t[0], t[2] | |
def predicate_objects(self, subject=None): | |
"""A generator of (predicate, object) tuples for the given subject""" | |
for t, c in self.triples((subject, None, None)): | |
yield t[1], t[2] |
They seem to be duplicating functionality from rdflib.graph.Graph
and it seems like it would be best to keep this functionality in rdflib.graph.Graph
instead of duplicating it in Stores while not using it from rdflib.graph.Graph
, and if it is not part of the Store interface then it also is not clear how useful it can really be.
Metadata
Metadata
Assignees
Labels
7.0Changes planned for version 7Changes planned for version 7breaking changeThis involves or proposes breaking RDFLib's public API.This involves or proposes breaking RDFLib's public API.cleanup