Make fakedbapi support generic metadata instead of just slots.
authorZac Medico <zmedico@gentoo.org>
Tue, 14 Nov 2006 07:35:29 +0000 (07:35 -0000)
committerZac Medico <zmedico@gentoo.org>
Tue, 14 Nov 2006 07:35:29 +0000 (07:35 -0000)
svn path=/main/trunk/; revision=5042

bin/emerge
pym/portage.py

index 8f37ac58063d9ce1083759d755d1bbedf86d892f..7cd5b58eff19e9ae6b2f0398ab839b1338a991dc 100755 (executable)
@@ -745,7 +745,7 @@ class depgraph:
                if "empty" not in self.myparams or self.target_root != "/":
                        for pkg in vardb.cpv_all():
                                myslot = vardb.aux_get(pkg, ["SLOT"])[0]
-                               fakedb.cpv_inject(pkg, myslot=myslot)
+                               fakedb.cpv_inject(pkg, metadata={"SLOT":myslot})
                if self.target_root != "/":
                        self.mydbapi[self.target_root] = \
                                portage.fakedbapi(settings=settings)
@@ -754,7 +754,7 @@ class depgraph:
                        if "empty" not in self.myparams:
                                for pkg in vardb.cpv_all():
                                        myslot = vardb.aux_get(pkg, ["SLOT"])[0]
-                                       fakedb.cpv_inject(pkg, myslot=myslot)
+                                       fakedb.cpv_inject(pkg, metadata={"SLOT":myslot})
                if "--usepkg" in self.myopts:
                        trees["/"]["bintree"].populate(
                                "--getbinpkg" in self.myopts, "--getbinpkgonly" in self.myopts)
@@ -887,7 +887,7 @@ class depgraph:
 
                if addme:
                        myslot = mydbapi.aux_get(mykey, ["SLOT"])[0]
-                       self.mydbapi[myroot].cpv_inject(mykey, myslot=myslot)
+                       self.mydbapi[myroot].cpv_inject(mykey, metadata={"SLOT":myslot})
 
                """ This section determines whether we go deeper into dependencies or not.
                    We want to go deeper on a few occasions:
index 23f51c50dd47081348c7fd78be150682cdf509ff..44e99d7eb1ade3c6f85040f26172c96b4c72085e 100644 (file)
@@ -4236,10 +4236,13 @@ class fakedbapi(dbapi):
        def cpv_all(self):
                return self.cpvdict.keys()
 
-       def cpv_inject(self, mycpv, myslot=None):
+       def cpv_inject(self, mycpv, metadata=None):
                """Adds a cpv from the list of available packages."""
                mycp=cpv_getkey(mycpv)
-               self.cpvdict[mycpv] = myslot
+               self.cpvdict[mycpv] = metadata
+               myslot = None
+               if metadata:
+                       myslot = metadata.get("SLOT", None)
                if myslot and mycp in self.cpdict:
                        # If necessary, remove another package in the same SLOT.
                        for cpv in self.cpdict[mycp]:
@@ -4276,13 +4279,10 @@ class fakedbapi(dbapi):
        def aux_get(self, mycpv, wants):
                if not self.cpv_exists(mycpv):
                        raise KeyError(mycpv)
-               values = []
-               for x in wants:
-                       if x == "SLOT":
-                               values.append(self.cpvdict[mycpv])
-                       else:
-                               values.append("")
-               return values
+               metadata = self.cpvdict[mycpv]
+               if not metadata:
+                       return ["" for x in wants]
+               return [metadata.get(x, "") for x in wants]
 
 class bindbapi(fakedbapi):
        def __init__(self, mybintree=None, settings=None):