diff options
author | Zac Medico <zmedico@gentoo.org> | 2009-02-21 22:07:51 +0000 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2009-02-21 22:07:51 +0000 |
commit | 8ad7d9d8941a53b9cb5bdb4b835dded508c7c1ce (patch) | |
tree | 0d6c9fd612915bac8cba705d4e4aca0e13d3527e | |
parent | b612926a04a7ef31029e27229dea2a9d1dbddb2c (diff) | |
download | portage-8ad7d9d8941a53b9cb5bdb4b835dded508c7c1ce.tar.gz portage-8ad7d9d8941a53b9cb5bdb4b835dded508c7c1ce.tar.bz2 portage-8ad7d9d8941a53b9cb5bdb4b835dded508c7c1ce.zip |
Make the UserDict and LazyItemsDict constructors use an optional positional
argument instead of a keyword argument.
svn path=/main/trunk/; revision=12674
-rw-r--r-- | pym/portage/__init__.py | 2 | ||||
-rw-r--r-- | pym/portage/cache/mappings.py | 14 | ||||
-rw-r--r-- | pym/portage/util.py | 17 |
3 files changed, 25 insertions, 8 deletions
diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py index 992f257cb..c6d570497 100644 --- a/pym/portage/__init__.py +++ b/pym/portage/__init__.py @@ -7693,7 +7693,7 @@ def create_trees(config_root=None, target_root=None, trees=None): myroots.append((settings["ROOT"], settings)) for myroot, mysettings in myroots: - trees[myroot] = portage.util.LazyItemsDict(trees.get(myroot, None)) + trees[myroot] = portage.util.LazyItemsDict(trees.get(myroot, {})) trees[myroot].addLazySingleton("virtuals", mysettings.getvirtuals, myroot) trees[myroot].addLazySingleton( "vartree", vartree, myroot, categories=mysettings.categories, diff --git a/pym/portage/cache/mappings.py b/pym/portage/cache/mappings.py index a632ce61d..1117b855b 100644 --- a/pym/portage/cache/mappings.py +++ b/pym/portage/cache/mappings.py @@ -139,10 +139,16 @@ class UserDict(MutableMapping): http://bugs.python.org/issue2876 """ - def __init__(self, dict=None, **kwargs): - self.data = {} - if dict is not None: - self.update(dict) + def __init__(self, *args, **kwargs): + + if len(args) > 1: + raise TypeError( + "expected at most 1 positional argument, got " + \ + repr(len(args))) + + if args: + self.update(args[0]) + if kwargs: self.update(kwargs) diff --git a/pym/portage/util.py b/pym/portage/util.py index ce226a4f7..d18faff2a 100644 --- a/pym/portage/util.py +++ b/pym/portage/util.py @@ -1201,11 +1201,22 @@ class LazyItemsDict(dict): __slots__ = ('lazy_items',) - def __init__(self, initial_items=None): + def __init__(self, *args, **kwargs): + + if len(args) > 1: + raise TypeError( + "expected at most 1 positional argument, got " + \ + repr(len(args))) + dict.__init__(self) self.lazy_items = {} - if initial_items is not None: - self.update(initial_items) + + if args: + self.update(args[0]) + + if kwargs: + self.update(kwargs) + 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.""" |