diff options
author | Zac Medico <zmedico@gentoo.org> | 2009-03-06 20:50:53 +0000 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2009-03-06 20:50:53 +0000 |
commit | 0064e2bfa8c4f43441fead6aae077f9c7162794d (patch) | |
tree | ade7e802da8f0b82e5cd26e7fa240dcd82d82169 | |
parent | 7a741ae0d924d75b047bf9b8f55d98c6ff7e306b (diff) | |
download | portage-0064e2bfa8c4f43441fead6aae077f9c7162794d.tar.gz portage-0064e2bfa8c4f43441fead6aae077f9c7162794d.tar.bz2 portage-0064e2bfa8c4f43441fead6aae077f9c7162794d.zip |
Add keyword argument support to LazyItemsDict.update().
svn path=/main/trunk/; revision=12771
-rw-r--r-- | pym/portage/util.py | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/pym/portage/util.py b/pym/portage/util.py index 11fdd21fe..bc181ba37 100644 --- a/pym/portage/util.py +++ b/pym/portage/util.py @@ -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] |