Make the UserDict and LazyItemsDict constructors use an optional positional
authorZac Medico <zmedico@gentoo.org>
Sat, 21 Feb 2009 22:07:51 +0000 (22:07 -0000)
committerZac Medico <zmedico@gentoo.org>
Sat, 21 Feb 2009 22:07:51 +0000 (22:07 -0000)
argument instead of a keyword argument.

svn path=/main/trunk/; revision=12674

pym/portage/__init__.py
pym/portage/cache/mappings.py
pym/portage/util.py

index 992f257cbf63602f81ea7282ae48fb625c77765d..c6d5704970928f8f7c96184ec4f9f5892de207e4 100644 (file)
@@ -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,
index a632ce61d134f99c5747684e2e79d694e08d915e..1117b855b288487ef7ac8c036f7489cd367051ad 100644 (file)
@@ -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)
 
index ce226a4f7470f7eae76d4d12c699a19e48b3fa75..d18faff2a8ae63a7c8a46f9cbf34dfdbd6b6ebb3 100644 (file)
@@ -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."""