From: Zac Medico Date: Sat, 15 Apr 2006 23:05:48 +0000 (-0000) Subject: Override LazyItemsDict.update() so that it works correctly with other instances of... X-Git-Tag: v2.1_pre9~9 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=5ab90a26a614293c83ff1f55571529c0cde587dd;p=portage.git Override LazyItemsDict.update() so that it works correctly with other instances of LazyItemsDict. svn path=/main/trunk/; revision=3159 --- 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]