summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2006-04-15 23:05:48 +0000
committerZac Medico <zmedico@gentoo.org>2006-04-15 23:05:48 +0000
commit5ab90a26a614293c83ff1f55571529c0cde587dd (patch)
tree2cf00e6e242326f62ddd1d0fb9739125054e96ad
parent70effbe19e6c95eee21db8d164c65e8bcd90cde2 (diff)
downloadportage-5ab90a26a614293c83ff1f55571529c0cde587dd.tar.gz
portage-5ab90a26a614293c83ff1f55571529c0cde587dd.tar.bz2
portage-5ab90a26a614293c83ff1f55571529c0cde587dd.zip
Override LazyItemsDict.update() so that it works correctly with other instances of LazyItemsDict.
svn path=/main/trunk/; revision=3159
-rw-r--r--pym/portage_util.py12
1 files changed, 10 insertions, 2 deletions
diff --git a/pym/portage_util.py b/pym/portage_util.py
index a1e2d0227..25f4a70ae 100644
--- a/pym/portage_util.py
+++ b/pym/portage_util.py
@@ -720,8 +720,6 @@ class LazyItemsDict(dict):
self.lazy_items = {}
if initial_items is not None:
self.update(initial_items)
- if isinstance(initial_items, LazyItemsDict):
- self.lazy_items.update(initial_items.lazy_items)
def addLazyItem(self, item_key, value_callable, *pargs, **kwargs):
"""Add a lazy item for the given key. When the item is requested,
value_callable will be called with *pargs and **kwargs arguments."""
@@ -743,6 +741,16 @@ class LazyItemsDict(dict):
self._value = self._callable(*self._pargs, **self._kwargs)
return self._value
self.addLazyItem(item_key, SingletonItem(value_callable, *pargs, **kwargs))
+ def update(self, map_obj):
+ if isinstance(map_obj, LazyItemsDict):
+ for k in map_obj:
+ if k in map_obj.lazy_items:
+ dict.__setitem__(self, k, None)
+ else:
+ dict.__setitem__(self, k, map_obj[k])
+ self.lazy_items.update(map_obj.lazy_items)
+ else:
+ dict.update(self, map_obj)
def __getitem__(self, item_key):
if item_key in self.lazy_items:
value_callable, pargs, kwargs = self.lazy_items[item_key]