summaryrefslogtreecommitdiffstats
path: root/pym
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2007-07-30 03:50:38 +0000
committerZac Medico <zmedico@gentoo.org>2007-07-30 03:50:38 +0000
commita5fe06366f2cf4ef913602e328fcd955128d1d1e (patch)
treed86e91197ae7841d985e2ad3a2ac9b6dd7d1782a /pym
parentc1281812dd177c2847f51c6ec5a4614cf0dc7243 (diff)
downloadportage-a5fe06366f2cf4ef913602e328fcd955128d1d1e.tar.gz
portage-a5fe06366f2cf4ef913602e328fcd955128d1d1e.tar.bz2
portage-a5fe06366f2cf4ef913602e328fcd955128d1d1e.zip
Always return a dict from dblink.getcontents() since callers never expect to get None. (branches/2.1.2 r6817)
svn path=/main/branches/2.1.2.9/; revision=7461
Diffstat (limited to 'pym')
-rw-r--r--pym/portage.py26
1 files changed, 17 insertions, 9 deletions
diff --git a/pym/portage.py b/pym/portage.py
index ebe2c96a6..d75ebecc4 100644
--- a/pym/portage.py
+++ b/pym/portage.py
@@ -6909,12 +6909,18 @@ class dblink:
"""
Get the installed files of a given package (aka what that package installed)
"""
- if not os.path.exists(self.dbdir+"/CONTENTS"):
- return None
- if self.contentscache != []:
+ contents_file = os.path.join(self.dbdir, "CONTENTS")
+ if self.contentscache is not None:
return self.contentscache
- pkgfiles={}
- myc=open(self.dbdir+"/CONTENTS","r")
+ pkgfiles = {}
+ try:
+ myc = open(contents_file,"r")
+ except EnvironmentError, e:
+ if e.errno != errno.ENOENT:
+ raise
+ del e
+ self.contentscache = pkgfiles
+ return pkgfiles
mylines=myc.readlines()
myc.close()
null_byte = "\0"
@@ -6963,10 +6969,12 @@ class dblink:
#format: type
pkgfiles[" ".join(mydat[1:])]=[mydat[0]]
else:
- return None
- except (KeyError,IndexError):
- print "portage: CONTENTS line",pos,"corrupt!"
- self.contentscache=pkgfiles
+ writemsg("!!! Unrecognized CONTENTS entry on " + \
+ "line %d: '%s'\n" % (pos, line), noiselevel=-1)
+ except (KeyError, IndexError):
+ writemsg("!!! Unrecognized CONTENTS entry on " + \
+ "line %d: '%s'\n" % (pos, line), noiselevel=-1)
+ self.contentscache = pkgfiles
return pkgfiles
def unmerge(self, pkgfiles=None, trimworld=1, cleanup=1,