summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2008-07-28 05:34:07 +0000
committerZac Medico <zmedico@gentoo.org>2008-07-28 05:34:07 +0000
commitcde46b372b6fa08174714f3b3443767528d3cd9c (patch)
tree1450f96b8db23ef38654fd759b098e73b24742e8
parent1033d4f65b7a126576bb6edf1b4a2a4c0f4f9471 (diff)
downloadportage-cde46b372b6fa08174714f3b3443767528d3cd9c.tar.gz
portage-cde46b372b6fa08174714f3b3443767528d3cd9c.tar.bz2
portage-cde46b372b6fa08174714f3b3443767528d3cd9c.zip
Create a SlotDict constructor which can take an optional positional arg that
is passed to the update() method (similar to the dict constructor), and also pass keyword arguments into the update() method if any are given. This makes it possible to use the constructor similarly to the way that the _emerge.SlotObject constructor is used. svn path=/main/trunk/; revision=11230
-rw-r--r--pym/portage/cache/mappings.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/pym/portage/cache/mappings.py b/pym/portage/cache/mappings.py
index d0ca487f0..75f97d6ae 100644
--- a/pym/portage/cache/mappings.py
+++ b/pym/portage/cache/mappings.py
@@ -142,6 +142,19 @@ def slot_dict_class(keys, prefix="_val_"):
__slots__ = ("__weakref__",) + \
tuple(prefix + k for k in allowed_keys)
+ def __init__(self, *args, **kwargs):
+
+ if len(args) > 1:
+ raise TypeError(
+ "expected at most 1 positional argument, got " + \
+ repr(1 + len(args)))
+
+ if args:
+ self.update(args[0])
+
+ if kwargs:
+ self.update(kwargs)
+
def __iter__(self):
for k, v in self.iteritems():
yield k