Allow the portagetree constructor to work without globals.
authorZac Medico <zmedico@gentoo.org>
Fri, 30 Jun 2006 08:18:51 +0000 (08:18 -0000)
committerZac Medico <zmedico@gentoo.org>
Fri, 30 Jun 2006 08:18:51 +0000 (08:18 -0000)
svn path=/main/trunk/; revision=3709

pym/portage.py

index 671612c9123bb08d8ae06cc856d19dea63606daa..a72d2a1f4cb4e1816c233b7df3de176c6507a6a4 100644 (file)
@@ -4054,18 +4054,23 @@ def match_from_list_original(mydep,mylist):
 
 
 class portagetree:
-       def __init__(self,root="/",virtual=None,clone=None):
-               global portdb, settings
-               self.settings = settings # for key_expand calls
+       def __init__(self, root="/", virtual=None, clone=None, settings=None,
+               portdb=None):
+
                if clone:
                        self.root=clone.root
                        self.portroot=clone.portroot
                        self.pkglines=clone.pkglines
                else:
                        self.root=root
+                       if settings is None:
+                               settings = globals()["settings"]
+                       self.settings = settings
                        self.portroot=settings["PORTDIR"]
                        self.virtual=virtual
-                       self.dbapi=portdb
+                       if portdb is None:
+                               portdb = globals()["portdb"]
+                       self.dbapi = portdb
 
        def dep_bestmatch(self,mydep):
                "compatibility method"