Clean up vardbapi.aux_get().
authorZac Medico <zmedico@gentoo.org>
Sat, 9 Dec 2006 00:02:35 +0000 (00:02 -0000)
committerZac Medico <zmedico@gentoo.org>
Sat, 9 Dec 2006 00:02:35 +0000 (00:02 -0000)
svn path=/main/trunk/; revision=5229

pym/portage.py

index 2bbc9dd54b992fdff2cd9df4094a18e7b9dcd140..e6dcc48bc99951e0d787b6ce25f41b9819591c7d 100644 (file)
@@ -4791,24 +4791,24 @@ class vardbapi(dbapi):
                return self.root+VDB_PATH+"/"+str(mycpv)+"/"+mycpv.split("/")[1]+".ebuild"
 
        def aux_get(self, mycpv, wants):
-               global auxdbkeys
+               mydir = os.path.join(self.root, VDB_PATH, mycpv)
+               if not os.path.isdir(mydir):
+                       raise KeyError(mycpv)
                results = []
                for x in wants:
-                       myfn = self.root+VDB_PATH+"/"+str(mycpv)+"/"+str(x)
                        try:
-                               myf = open(myfn, "r")
-                               myd = myf.read()
-                               myf.close()
-                               myd = re.sub("[\n\r\t]+"," ",myd)
-                               myd = re.sub(" +"," ",myd)
-                               myd = string.strip(myd)
-                       except (IOError, OSError):
+                               myf = open(os.path.join(mydir, x), "r")
+                               try:
+                                       myd = myf.read()
+                               finally:
+                                       myf.close()
+                               myd = " ".join(myd.split())
+                       except IOError:
                                myd = ""
-                       results.append(myd)
-               if "EAPI" in wants:
-                       idx = wants.index("EAPI")
-                       if not results[idx]:
-                               results[idx] = "0"
+                       if x == "EAPI" and not myd:
+                               results.append("0")
+                       else:
+                               results.append(myd)
                return results
 
        def aux_update(self, cpv, values):