summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2007-06-12 21:08:30 +0000
committerZac Medico <zmedico@gentoo.org>2007-06-12 21:08:30 +0000
commitf126b81886867e836fdd0ab9381404e4e4ca8d07 (patch)
tree4401a101eef41820c4a210d9323d10deac417985
parent844863c5da7884273bcc02ba05c475ae6f6103c1 (diff)
downloadportage-f126b81886867e836fdd0ab9381404e4e4ca8d07.tar.gz
portage-f126b81886867e836fdd0ab9381404e4e4ca8d07.tar.bz2
portage-f126b81886867e836fdd0ab9381404e4e4ca8d07.zip
Always return a dict from dblink.getcontents() since callers never expect to get None.
svn path=/main/trunk/; revision=6816
-rw-r--r--pym/portage/dbapi/vartree.py17
1 files changed, 12 insertions, 5 deletions
diff --git a/pym/portage/dbapi/vartree.py b/pym/portage/dbapi/vartree.py
index 288cd0dbb..2d2fc99bc 100644
--- a/pym/portage/dbapi/vartree.py
+++ b/pym/portage/dbapi/vartree.py
@@ -908,12 +908,17 @@ class dblink(object):
Get the installed files of a given package (aka what that package installed)
"""
contents_file = os.path.join(self.dbdir, "CONTENTS")
- if not os.path.exists(contents_file):
- return None
if self.contentscache is not None:
return self.contentscache
pkgfiles = {}
- myc = open(contents_file,"r")
+ 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"
@@ -961,9 +966,11 @@ class dblink(object):
#format: type
pkgfiles[" ".join(mydat[1:])] = [mydat[0]]
else:
- return None
+ writemsg("!!! Unrecognized CONTENTS entry on " + \
+ "line %d: '%s'\n" % (pos, line), noiselevel=-1)
except (KeyError, IndexError):
- print "portage: CONTENTS line", pos, "corrupt!"
+ writemsg("!!! Unrecognized CONTENTS entry on " + \
+ "line %d: '%s'\n" % (pos, line), noiselevel=-1)
self.contentscache = pkgfiles
return pkgfiles