From f126b81886867e836fdd0ab9381404e4e4ca8d07 Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Tue, 12 Jun 2007 21:08:30 +0000 Subject: Always return a dict from dblink.getcontents() since callers never expect to get None. svn path=/main/trunk/; revision=6816 --- pym/portage/dbapi/vartree.py | 17 ++++++++++++----- 1 file 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 -- cgit v1.2.3-1-g7c22