global db, root
self._use = autouse(db[root]["vartree"], *self._pargs, **self._kwargs)
return self._use
- if isinstance(self.configdict["auto"],
- portage_util.LazyItemsDict):
- lazy_values = self.configdict["auto"]
- else:
- lazy_values = portage_util.LazyItemsDict()
- lazy_values.update(self.configdict["auto"])
- lazy_values.addLazyItem("USE", LazyAutouse(use_cache=use_cache))
- self.configdict["auto"] = lazy_values
+ self.configdict["auto"] = portage_util.LazyItemsDict(self.configdict["auto"])
+ self.configdict["auto"].addLazyItem("USE", LazyAutouse(use_cache=use_cache))
else:
self.configdict["auto"]["USE"]=""
else:
"""A mapping object that behaves like a standard dict except that it allows
for lazy initialization of values via callable objects. Lazy items can be
overwritten and deleted just as normal items."""
- def __init__(self):
+ def __init__(self, initial_items=None):
dict.__init__(self)
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):
"""Add a lazy item for the given key. When the item is requested,
value_callable will be called with no arguments."""