Use lazy import for the portage.dbapi module.
authorZac Medico <zmedico@gentoo.org>
Mon, 22 Feb 2010 01:41:25 +0000 (01:41 -0000)
committerZac Medico <zmedico@gentoo.org>
Mon, 22 Feb 2010 01:41:25 +0000 (01:41 -0000)
svn path=/main/trunk/; revision=15419

pym/_emerge/FakeVartree.py
pym/_emerge/PackageVirtualDbapi.py
pym/_emerge/depgraph.py
pym/portage/__init__.py

index 728d44a715bba752af540604af4d8c8c86c8401c..c408a21610b5711a77e82b7cec78117140971342 100644 (file)
@@ -8,11 +8,12 @@ import portage
 from portage import os
 from _emerge.Package import Package
 from _emerge.PackageVirtualDbapi import PackageVirtualDbapi
+from portage.dbapi.vartree import vartree
 
 if sys.hexversion >= 0x3000000:
        long = int
 
-class FakeVartree(portage.vartree):
+class FakeVartree(vartree):
        """This is implements an in-memory copy of a vartree instance that provides
        all the interfaces required for use by the depgraph.  The vardb is locked
        during the constructor call just long enough to read a copy of the
index e557f0489830e9e373ff4fdbc9e1b2542fc1aa1d..026b6cc7264dad9dd82a53a901c3fd1276318fcb 100644 (file)
@@ -3,9 +3,9 @@
 # $Id$
 
 import sys
-import portage
+from portage.dbapi import dbapi
 
-class PackageVirtualDbapi(portage.dbapi):
+class PackageVirtualDbapi(dbapi):
        """
        A dbapi-like interface class that represents the state of the installed
        package database as new packages are installed, replacing any packages
@@ -14,7 +14,7 @@ class PackageVirtualDbapi(portage.dbapi):
        internally (passed in via cpv_inject() and cpv_remove() calls).
        """
        def __init__(self, settings):
-               portage.dbapi.__init__(self)
+               dbapi.__init__(self)
                self.settings = settings
                self._match_cache = {}
                self._cp_map = {}
@@ -80,7 +80,7 @@ class PackageVirtualDbapi(portage.dbapi):
                result = self._match_cache.get(origdep)
                if result is not None:
                        return result[:]
-               result = portage.dbapi.match(self, origdep, use_cache=use_cache)
+               result = dbapi.match(self, origdep, use_cache=use_cache)
                self._match_cache[origdep] = result
                return result[:]
 
index 70b59dda2c81604245ab76fec73296d03d056c13..e6bffbc7049c1e160da1c42f664d200f87708f52 100644 (file)
@@ -14,6 +14,7 @@ from itertools import chain
 import portage
 from portage import os
 from portage import digraph
+from portage.dbapi import dbapi
 from portage.dep import Atom
 from portage.output import bold, blue, colorize, create_color_func, darkblue, \
        darkgreen, green, nc_len, red, teal, turquoise, yellow
@@ -5236,7 +5237,7 @@ class depgraph(object):
        def get_runtime_pkg_mask(self):
                return self._dynamic_config._runtime_pkg_mask.copy()
 
-class _dep_check_composite_db(portage.dbapi):
+class _dep_check_composite_db(dbapi):
        """
        A dbapi-like interface that is optimized for use in dep_check() calls.
        This is built on top of the existing depgraph package selection logic.
@@ -5245,7 +5246,7 @@ class _dep_check_composite_db(portage.dbapi):
        via dep_check().
        """
        def __init__(self, depgraph, root):
-               portage.dbapi.__init__(self)
+               dbapi.__init__(self)
                self._depgraph = depgraph
                self._root = root
                self._match_cache = {}
index 212951102ec5ae6102a4c6cf1b4338f102928b3a..694062a627f7922e7f6145a49ca24691c0484243 100644 (file)
@@ -83,6 +83,12 @@ try:
                'portage.data',
                'portage.data:lchown,ostype,portage_gid,portage_uid,secpass,' + \
                        'uid,userland,userpriv_groups,wheelgid',
+               'portage.dbapi:dbapi',
+               'portage.dbapi.bintree:bindbapi,binarytree',
+               'portage.dbapi.porttree:close_portdbapi_caches,FetchlistDict,' + \
+                       'portagetree,portdbapi',
+               'portage.dbapi.vartree:vardbapi,vartree,dblink',
+               'portage.dbapi.virtual:fakedbapi',
                'portage.dep',
                'portage.dep:best_match_to_list,dep_getcpv,dep_getkey,' + \
                        'flatten,get_operator,isjustname,isspecific,isvalidatom,' + \
@@ -8766,13 +8772,6 @@ auxdbkeys=[
        ]
 auxdbkeylen=len(auxdbkeys)
 
-from portage.dbapi import dbapi
-from portage.dbapi.virtual import fakedbapi
-from portage.dbapi.bintree import bindbapi, binarytree
-from portage.dbapi.vartree import vardbapi, vartree, dblink
-from portage.dbapi.porttree import FetchlistDict, \
-       close_portdbapi_caches, portagetree, portdbapi
-
 def pkgmerge(mytbz2, myroot, mysettings, mydbapi=None,
        vartree=None, prev_mtimes=None, blockers=None):
        """will merge a .tbz2 file, returning a list of runtime dependencies