]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
util.dictutil: move DictOfSets out to a separate utility module
authorBrian Warner <warner@allmydata.com>
Wed, 21 May 2008 16:43:49 +0000 (09:43 -0700)
committerBrian Warner <warner@allmydata.com>
Wed, 21 May 2008 16:43:49 +0000 (09:43 -0700)
src/allmydata/mutable/common.py
src/allmydata/util/dictutil.py [new file with mode: 0644]

index 6aed45d110ab3d5d38d64f4538faaee4e81d697b..6504909b94c8327644b8e1c66c543acbc121bf7b 100644 (file)
@@ -1,5 +1,6 @@
 
 from allmydata.util import idlib
+from allmydata.util.dictutil import DictOfSets
 
 MODE_CHECK = "MODE_CHECK" # query all peers
 MODE_ANYTHING = "MODE_ANYTHING" # one recoverable version
@@ -48,22 +49,6 @@ class CorruptShareError(Exception):
 
 
 
-
-
-class DictOfSets(dict):
-    def add(self, key, value):
-        if key in self:
-            self[key].add(value)
-        else:
-            self[key] = set([value])
-
-    def discard(self, key, value):
-        if not key in self:
-            return
-        self[key].discard(value)
-        if not self[key]:
-            del self[key]
-
 class ResponseCache:
     """I cache share data, to reduce the number of round trips used during
     mutable file operations. All of the data in my cache is for a single
diff --git a/src/allmydata/util/dictutil.py b/src/allmydata/util/dictutil.py
new file mode 100644 (file)
index 0000000..45234ee
--- /dev/null
@@ -0,0 +1,15 @@
+
+class DictOfSets(dict):
+    def add(self, key, value):
+        if key in self:
+            self[key].add(value)
+        else:
+            self[key] = set([value])
+
+    def discard(self, key, value):
+        if not key in self:
+            return
+        self[key].discard(value)
+        if not self[key]:
+            del self[key]
+