From 6379e5dd27b5fd76939ac7d3a0ba07520451cd90 Mon Sep 17 00:00:00 2001 From: Arfrever Frehtes Taifersar Arahesis Date: Fri, 25 Sep 2009 05:29:02 +0000 Subject: Use list comprehensions instead of filter() or map() in some places for compatibility with Python 3. svn path=/main/trunk/; revision=14421 --- bin/dispatch-conf | 2 +- bin/emaint | 6 +++--- bin/regenworld | 14 ++++++-------- 3 files changed, 10 insertions(+), 12 deletions(-) (limited to 'bin') diff --git a/bin/dispatch-conf b/bin/dispatch-conf index 5247cdb60..bf4cac611 100755 --- a/bin/dispatch-conf +++ b/bin/dispatch-conf @@ -205,7 +205,7 @@ class dispatch: else: return True - confs = filter (f, confs) + confs = [x for x in confs if f(x)] # # Interactively process remaining diff --git a/bin/emaint b/bin/emaint index 7aac5d49a..2626036e9 100755 --- a/bin/emaint +++ b/bin/emaint @@ -80,9 +80,9 @@ class WorldHandler(object): self._check_world(onProgress) errors = [] if self.found: - errors += map(lambda x: "'%s' is not a valid atom" % x, self.invalid) - errors += map(lambda x: "'%s' is not installed" % x, self.not_installed) - errors += map(lambda x: "'%s' has a category that is not listed in /etc/portage/categories" % x, self.invalid_category) + errors += ["'%s' is not a valid atom" % x for x in self.invalid] + errors += ["'%s' is not installed" % x for x in self.not_installed] + errors += ["'%s' has a category that is not listed in /etc/portage/categories" % x for x in self.invalid_category] else: errors.append(self.world_file + " could not be opened for reading") return errors diff --git a/bin/regenworld b/bin/regenworld index de082db41..f5b30bd49 100755 --- a/bin/regenworld +++ b/bin/regenworld @@ -58,18 +58,16 @@ if len(sys.argv) >= 2 and sys.argv[1] in ["-h", "--help"]: sys.exit(0) worldlist = portage.grabfile(os.path.join("/", portage.WORLD_FILE)) -syslist = portage.settings.packages -syslist = filter(issyspkg, syslist) +syslist = [x for x in portage.settings.packages if issyspkg(x)] logfile = portage.grabfile("/var/log/emerge.log") -biglist = filter(iscandidate, logfile) -biglist = map(getpkginfo, biglist) +biglist = [getpkginfo(x) for x in logfile if iscandidate(x)] tmplist = [] for l in biglist: tmplist += l.split() -biglist = filter(isunwanted, tmplist) +biglist = [x for x in tmplist if isunwanted(x)] #for p in biglist: -# print p +# print(p) #sys.exit(0) # resolving virtuals @@ -77,7 +75,7 @@ realsyslist = [] for mykey in syslist: # drop the asterix mykey = mykey[1:] - #print "candidate:",mykey + #print("candidate:",mykey) mylist=portage.db["/"]["vartree"].dbapi.match(mykey) if mylist: mykey=portage.cpv_getkey(mylist[0]) @@ -85,7 +83,7 @@ for mykey in syslist: realsyslist.append(mykey) for mykey in biglist: - #print "checking:",mykey + #print("checking:",mykey) try: mylist=portage.db["/"]["vartree"].dbapi.match(mykey) except (portage.exception.InvalidAtom, KeyError): -- cgit v1.2.3-1-g7c22