summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2010-02-22 01:41:25 +0000
committerZac Medico <zmedico@gentoo.org>2010-02-22 01:41:25 +0000
commita85d10088212250a74b2ff1c2b083897d4b3623c (patch)
treec61160160482d89facad2331d756b7a0327bb9f5
parentda4d877173458a35778c9db93e0a8762c5cb1a6e (diff)
downloadportage-a85d10088212250a74b2ff1c2b083897d4b3623c.tar.gz
portage-a85d10088212250a74b2ff1c2b083897d4b3623c.tar.bz2
portage-a85d10088212250a74b2ff1c2b083897d4b3623c.zip
Use lazy import for the portage.dbapi module.
svn path=/main/trunk/; revision=15419
-rw-r--r--pym/_emerge/FakeVartree.py3
-rw-r--r--pym/_emerge/PackageVirtualDbapi.py8
-rw-r--r--pym/_emerge/depgraph.py5
-rw-r--r--pym/portage/__init__.py13
4 files changed, 15 insertions, 14 deletions
diff --git a/pym/_emerge/FakeVartree.py b/pym/_emerge/FakeVartree.py
index 728d44a71..c408a2161 100644
--- a/pym/_emerge/FakeVartree.py
+++ b/pym/_emerge/FakeVartree.py
@@ -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
diff --git a/pym/_emerge/PackageVirtualDbapi.py b/pym/_emerge/PackageVirtualDbapi.py
index e557f0489..026b6cc72 100644
--- a/pym/_emerge/PackageVirtualDbapi.py
+++ b/pym/_emerge/PackageVirtualDbapi.py
@@ -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[:]
diff --git a/pym/_emerge/depgraph.py b/pym/_emerge/depgraph.py
index 70b59dda2..e6bffbc70 100644
--- a/pym/_emerge/depgraph.py
+++ b/pym/_emerge/depgraph.py
@@ -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 = {}
diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py
index 212951102..694062a62 100644
--- a/pym/portage/__init__.py
+++ b/pym/portage/__init__.py
@@ -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