tahoe-lafs/src/allmydata/util/dictutil.py

16 lines
333 B
Python
Raw Normal View History

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]