projects
/
tahoe-lafs
/
tahoe-lafs.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
c1e3c66
)
util: dictutil: add DictOfSets.union(key, values) and DictOfSets.update(otherdictofsets)
author
Zooko O'Whielacronx
<zooko@zooko.com>
Mon, 12 Jan 2009 17:55:39 +0000
(10:55 -0700)
committer
Zooko O'Whielacronx
<zooko@zooko.com>
Mon, 12 Jan 2009 17:55:39 +0000
(10:55 -0700)
src/allmydata/util/dictutil.py
patch
|
blob
|
history
diff --git
a/src/allmydata/util/dictutil.py
b/src/allmydata/util/dictutil.py
index 227d2479c3e10fb167ac5682cb7eab9e4188866c..11c0c7438ab4d2d7de755571f7bcf038f5bb99cf 100644
(file)
--- a/
src/allmydata/util/dictutil.py
+++ b/
src/allmydata/util/dictutil.py
@@
-40,6
+40,16
@@
class DictOfSets(dict):
else:
self[key] = set([value])
+ def union(self, key, values):
+ if key in self:
+ self[key].update(values)
+ else:
+ self[key] = set(values)
+
+ def update(self, otherdictofsets):
+ for key, value in otherdictofsets.iteritems():
+ self.union(key, value)
+
def discard(self, key, value):
if not key in self:
return