britney.py: Use defaultdict instead of "{}.setdefault"

Signed-off-by: Niels Thykier <niels@thykier.net>
debian
Niels Thykier 11 years ago
parent 12691baa87
commit 4383fe93a5

@ -189,6 +189,7 @@ import urllib
import apt_pkg import apt_pkg
from collections import defaultdict
from functools import reduce, partial from functools import reduce, partial
from itertools import chain, ifilter, product from itertools import chain, ifilter, product
from operator import attrgetter from operator import attrgetter
@ -678,7 +679,7 @@ class Britney(object):
The method returns a dictionary where the key is the binary package The method returns a dictionary where the key is the binary package
name and the value is the list of open RC bugs for it. name and the value is the list of open RC bugs for it.
""" """
bugs = {} bugs = defaultdict(list)
filename = os.path.join(basedir, "BugsV") filename = os.path.join(basedir, "BugsV")
self.__log("Loading RC bugs data from %s" % filename) self.__log("Loading RC bugs data from %s" % filename)
for line in open(filename): for line in open(filename):
@ -687,7 +688,6 @@ class Britney(object):
self.__log("Malformed line found in line %s" % (line), type='W') self.__log("Malformed line found in line %s" % (line), type='W')
continue continue
pkg = l[0] pkg = l[0]
bugs.setdefault(pkg, [])
bugs[pkg] += l[1].split(",") bugs[pkg] += l[1].split(",")
return bugs return bugs
@ -2783,10 +2783,10 @@ class Britney(object):
def nuninst_arch_report(self, nuninst, arch): def nuninst_arch_report(self, nuninst, arch):
"""Print a report of uninstallable packages for one architecture.""" """Print a report of uninstallable packages for one architecture."""
all = {} all = defaultdict(set)
for p in nuninst[arch]: for p in nuninst[arch]:
pkg = self.binaries['testing'][arch][0][p] pkg = self.binaries['testing'][arch][0][p]
all.setdefault((pkg[SOURCE], pkg[SOURCEVER]), set()).add(p) all[pkg].add(p)
print '* %s' % (arch,) print '* %s' % (arch,)

Loading…
Cancel
Save