Add keyword argument support to LazyItemsDict.update(). (trunk r12771)
authorZac Medico <zmedico@gentoo.org>
Wed, 11 Mar 2009 06:45:33 +0000 (06:45 -0000)
committerZac Medico <zmedico@gentoo.org>
Wed, 11 Mar 2009 06:45:33 +0000 (06:45 -0000)
svn path=/main/branches/2.1.6/; revision=13015

pym/portage/util.py

index 11fdd21fee8009f0566af99c48b6dad9e2ef9a02..bc181ba3799de794255b6a9f631925fb7eaa7adb 100644 (file)
@@ -1084,8 +1084,19 @@ class LazyItemsDict(dict):
                self.addLazyItem(item_key,
                        self._SingletonWrapper(self, item_key, value_callable,
                                *pargs, **kwargs))
-       def update(self, map_obj):
-               if isinstance(map_obj, LazyItemsDict):
+
+       def update(self, *args, **kwargs):
+               if len(args) > 1:
+                       raise TypeError(
+                               "expected at most 1 positional argument, got " + \
+                               repr(len(args)))
+               if args:
+                       map_obj = args[0]
+               else:
+                       map_obj = None
+               if map_obj is None:
+                       pass
+               elif isinstance(map_obj, LazyItemsDict):
                        for k in map_obj:
                                if k in map_obj.lazy_items:
                                        dict.__setitem__(self, k, None)
@@ -1094,6 +1105,9 @@ class LazyItemsDict(dict):
                        self.lazy_items.update(map_obj.lazy_items)
                else:
                        dict.update(self, map_obj)
+               if kwargs:
+                       dict.update(self, kwargs)
+
        def __getitem__(self, item_key):
                if item_key in self.lazy_items:
                        value_callable, pargs, kwargs = self.lazy_items[item_key]