diff options
author | Zac Medico <zmedico@gentoo.org> | 2006-04-14 06:30:52 +0000 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2006-04-14 06:30:52 +0000 |
commit | 86e08bdaf036b7b455514b3b6cde47523e9759f5 (patch) | |
tree | 050a51442fe0da782b7b856006e6fa0f3fda838e /pym/portage_util.py | |
parent | 0241a10d9fd597ff534446d82619fc42b2880a36 (diff) | |
download | portage-86e08bdaf036b7b455514b3b6cde47523e9759f5.tar.gz portage-86e08bdaf036b7b455514b3b6cde47523e9759f5.tar.bz2 portage-86e08bdaf036b7b455514b3b6cde47523e9759f5.zip |
Add an initial_items parameter to the LazyItemsDict constructor in order to facilitate integration with existing dict based code.
svn path=/main/trunk/; revision=3143
Diffstat (limited to 'pym/portage_util.py')
-rw-r--r-- | pym/portage_util.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/pym/portage_util.py b/pym/portage_util.py index 6fd76090c..cd69733ba 100644 --- a/pym/portage_util.py +++ b/pym/portage_util.py @@ -715,9 +715,13 @@ class LazyItemsDict(dict): """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.""" |