From 86e08bdaf036b7b455514b3b6cde47523e9759f5 Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Fri, 14 Apr 2006 06:30:52 +0000 Subject: 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 --- pym/portage_util.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'pym/portage_util.py') 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.""" -- cgit v1.2.3-1-g7c22