From: Zac Medico Date: Fri, 30 Jun 2006 10:10:06 +0000 (-0000) Subject: Pass a config instance into the bindbapi and fakedbapi constructors in order to avoid... X-Git-Tag: v2.1.1~327 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=b74bf9d6ad8ef6e743efa78a1d97699d91e3f68e;p=portage.git Pass a config instance into the bindbapi and fakedbapi constructors in order to avoid dependance on globals for dep_expand() calls. svn path=/main/trunk/; revision=3716 --- diff --git a/bin/emerge b/bin/emerge index fc11cfb97..6bde09bc1 100755 --- a/bin/emerge +++ b/bin/emerge @@ -618,12 +618,12 @@ class depgraph: self.orderedkeys=[] self.outdatedpackages=[] self.mydbapi={} - self.mydbapi["/"] = portage.fakedbapi() + self.mydbapi["/"] = portage.fakedbapi(settings=settings) if "empty" not in self.myparams or settings["ROOT"] != "/": for pkg in self.trees["/"]["vartree"].getallcpv(): self.mydbapi["/"].cpv_inject(pkg) if settings["ROOT"] != "/": - self.mydbapi[settings["ROOT"]] = portage.fakedbapi() + self.mydbapi[settings["ROOT"]] = portage.fakedbapi(settings=settings) if "empty" not in self.myparams: for pkg in self.trees[settings["ROOT"]]["vartree"].getallcpv(): self.mydbapi[settings["ROOT"]].cpv_inject(pkg) diff --git a/pym/portage.py b/pym/portage.py index e7bb750bb..f82045fcf 100644 --- a/pym/portage.py +++ b/pym/portage.py @@ -4143,7 +4143,7 @@ class dbapi: raise NotImplementedError def match(self,origdep,use_cache=1): - mydep=dep_expand(origdep,mydb=self) + mydep = dep_expand(origdep, mydb=self, settings=self.settings) mykey=dep_getkey(mydep) mycat=mykey.split("/")[0] return match_from_list(mydep,self.cp_list(mykey,use_cache=use_cache)) @@ -4170,9 +4170,12 @@ class dbapi: class fakedbapi(dbapi): "This is a dbapi to use for the emptytree function. It's empty, but things can be added to it." - def __init__(self): + def __init__(self, settings=None): self.cpvdict={} self.cpdict={} + if settings is None: + settings = globals()["settings"] + self.settings = settings def cpv_exists(self,mycpv): return self.cpvdict.has_key(mycpv) @@ -4221,10 +4224,13 @@ class fakedbapi(dbapi): del self.cpdict[mycp] class bindbapi(fakedbapi): - def __init__(self,mybintree=None): + def __init__(self, mybintree=None, settings=None): self.bintree = mybintree self.cpvdict={} self.cpdict={} + if settings is None: + settings = globals()["settings"] + self.settings = settings def match(self, *pargs, **kwargs): if self.bintree and not self.bintree.populated: @@ -5444,7 +5450,7 @@ class binarytree(packagetree): self.root=root #self.pkgdir=settings["PKGDIR"] self.pkgdir=pkgdir - self.dbapi=bindbapi(self) + self.dbapi = bindbapi(self, settings=settings) self.populated=0 self.tree={} self.remotepkgs={}