Deprecate the first parameter of the portdbapi constructor since it is always
authorZac Medico <zmedico@gentoo.org>
Tue, 2 Mar 2010 18:26:26 +0000 (18:26 -0000)
committerZac Medico <zmedico@gentoo.org>
Tue, 2 Mar 2010 18:26:26 +0000 (18:26 -0000)
the same as mysettings['PORTDIR']. (trunk r15281)

svn path=/main/branches/2.1.7/; revision=15520

bin/egencache
pym/portage/dbapi/porttree.py

index 64429296daf0b31f03ee7a81cb187555c6fa6ad1..78d2f1f5b0f6ca027db0c7cf0a2441f461c91053 100755 (executable)
@@ -326,7 +326,7 @@ def egencache_main(args):
 
        settings.lock()
 
-       portdb = portage.portdbapi(settings["PORTDIR"], mysettings=settings)
+       portdb = portage.portdbapi(mysettings=settings)
        if options.repo is not None:
                repo_path = portdb.getRepositoryPath(options.repo)
                if repo_path is None:
index 7536f7972f8aca7e29da155fd32c0c7271bca8dc..1b5567a8e003b4954a83db86590b22f6c9f7124d 100644 (file)
@@ -141,7 +141,13 @@ class portdbapi(dbapi):
        def _categories(self):
                return self.settings.categories
 
-       def __init__(self, porttree_root, mysettings=None):
+       def __init__(self, _unused_param=None, mysettings=None):
+               """
+               @param _unused_param: deprecated
+               @type _unused_param: None
+               @param mysettings: an immutable config instance
+               @type mysettings: portage.config
+               """
                portdbapi.portdbapi_instances.append(self)
 
                from portage import config
@@ -151,6 +157,15 @@ class portdbapi(dbapi):
                        from portage import settings
                        self.mysettings = config(clone=settings)
 
+               if _unused_param is not None:
+                       warnings.warn("The first parameter of the " + \
+                               "portage.dbapi.porttree.portdbapi" + \
+                               " constructor is now unused. Use " + \
+                               "mysettings['PORTDIR'] instead.",
+                               DeprecationWarning)
+
+               porttree_root = self.mysettings['PORTDIR']
+
                # This is strictly for use in aux_get() doebuild calls when metadata
                # is generated by the depend phase.  It's safest to use a clone for
                # this purpose because doebuild makes many changes to the config
@@ -1182,8 +1197,7 @@ class portagetree(object):
                        self.settings = settings
                        self.portroot = settings["PORTDIR"]
                        self.virtual = virtual
-                       self.dbapi = portdbapi(
-                               settings["PORTDIR"], mysettings=settings)
+                       self.dbapi = portdbapi(mysettings=settings)
 
        def dep_bestmatch(self,mydep):
                "compatibility method"