summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoern Hees <dev@joernhees.de>2014-12-02 17:37:12 +0100
committerGunnar Aastrand Grimnes <gromgull@gmail.com>2017-01-30 17:43:04 +0100
commit0cd6546ffbd36b665f801e08c9d621f77d79e970 (patch)
tree39ec68a4d784d22f4c37ef8b9a8292d9ec5d8d2f
parent65fb67666254155589eca73d098bd5d2fabe60ee (diff)
downloadrdflib-0cd6546ffbd36b665f801e08c9d621f77d79e970.tar.gz
six: memory.py: headers, method sig tuple assignments
-rw-r--r--rdflib/plugins/memory.py15
1 files 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: