util.dictutil: move DictOfSets out to a separate utility module

This commit is contained in:
Brian Warner 2008-05-21 09:43:49 -07:00
parent 0df663b7ae
commit fe44b8fb4b
2 changed files with 16 additions and 16 deletions

View File

@ -1,5 +1,6 @@
from allmydata.util import idlib from allmydata.util import idlib
from allmydata.util.dictutil import DictOfSets
MODE_CHECK = "MODE_CHECK" # query all peers MODE_CHECK = "MODE_CHECK" # query all peers
MODE_ANYTHING = "MODE_ANYTHING" # one recoverable version 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: class ResponseCache:
"""I cache share data, to reduce the number of round trips used during """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 mutable file operations. All of the data in my cache is for a single

View File

@ -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]