From 0cd6546ffbd36b665f801e08c9d621f77d79e970 Mon Sep 17 00:00:00 2001 From: Joern Hees Date: Tue, 2 Dec 2014 17:37:12 +0100 Subject: six: memory.py: headers, method sig tuple assignments --- rdflib/plugins/memory.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/rdflib/plugins/memory.py b/rdflib/plugins/memory.py index dcfd7c84..ba489be0 100644 --- a/rdflib/plugins/memory.py +++ b/rdflib/plugins/memory.py @@ -1,3 +1,7 @@ +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function + from rdflib.term import BNode from rdflib.store import Store, NO_STORE, VALID_STORE @@ -32,13 +36,14 @@ class Memory(Store): self.__namespace = {} self.__prefix = {} - def add(self, (subject, predicate, object), context, quoted=False): + def add(self, triple, context, quoted=False): """\ Add a triple to the store of triples. """ # add dictionary entries for spo[s][p][p] = 1 and pos[p][o][s] # = 1, creating the nested dictionaries where they do not yet # exits. + subject, predicate, object = triple spo = self.__spo try: po = spo[subject] @@ -72,15 +77,15 @@ class Memory(Store): p = sp[subject] = {} p[predicate] = 1 - def remove(self, (subject, predicate, object), context=None): - for (subject, predicate, object), c in self.triples( - (subject, predicate, object)): + def remove(self, triple_pattern, context=None): + for (subject, predicate, object), c in self.triples(triple_pattern): del self.__spo[subject][predicate][object] del self.__pos[predicate][object][subject] del self.__osp[object][subject][predicate] - def triples(self, (subject, predicate, object), context=None): + def triples(self, triple_pattern, context=None): """A generator over all the triples matching """ + subject, predicate, object = triple_pattern if subject != ANY: # subject is given spo = self.__spo if subject in spo: -- cgit v1.2.1