diff options
author | Zac Medico <zmedico@gentoo.org> | 2007-06-12 21:14:34 +0000 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2007-06-12 21:14:34 +0000 |
commit | 975f0a7c86743553b9479b1f88d5135b2f138f61 (patch) | |
tree | 021d2dc39123beb91be888a0aef617843092e99a /pym | |
parent | f9e6439685818e289b6a16217cef1944252ab4b8 (diff) | |
download | portage-975f0a7c86743553b9479b1f88d5135b2f138f61.tar.gz portage-975f0a7c86743553b9479b1f88d5135b2f138f61.tar.bz2 portage-975f0a7c86743553b9479b1f88d5135b2f138f61.zip |
Always return a dict from dblink.getcontents() since callers never expect to get None. (trunk r6816)
svn path=/main/branches/2.1.2/; revision=6817
Diffstat (limited to 'pym')
-rw-r--r-- | pym/portage.py | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/pym/portage.py b/pym/portage.py index 3d202d07e..8d972c7a9 100644 --- a/pym/portage.py +++ b/pym/portage.py @@ -6942,12 +6942,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 + 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" @@ -6996,10 +7002,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, |