mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2024-12-20 05:28:04 +00:00
util.dictutil: move DictOfSets out to a separate utility module
This commit is contained in:
parent
0df663b7ae
commit
fe44b8fb4b
@ -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
|
||||
|
15
src/allmydata/util/dictutil.py
Normal file
15
src/allmydata/util/dictutil.py
Normal 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]
|
||||
|
Loading…
Reference in New Issue
Block a user