From: Zac Medico Date: Sat, 9 Dec 2006 00:02:35 +0000 (-0000) Subject: Clean up vardbapi.aux_get(). X-Git-Tag: v2.1.2~355 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=f66720b6a5898f1b57ffa2ef3a0d04d98a5e4bdd;p=portage.git Clean up vardbapi.aux_get(). svn path=/main/trunk/; revision=5229 --- diff --git a/pym/portage.py b/pym/portage.py index 2bbc9dd54..e6dcc48bc 100644 --- a/pym/portage.py +++ b/pym/portage.py @@ -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):