From: Arfrever Frehtes Taifersar Arahesis Date: Mon, 21 Sep 2009 11:49:13 +0000 (-0000) Subject: Use filter() and zip() instead of itertools.ifilter() and itertools.izip() for compat... X-Git-Tag: v2.2_rc42~88 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=dbe76c6a138288980772d9b4a42280903df2daa9;p=portage.git Use filter() and zip() instead of itertools.ifilter() and itertools.izip() for compatibility with Python 3. (2to3-3.1 -f itertools -f itertools_imports -nw ${FILES}) svn path=/main/trunk/; revision=14314 --- diff --git a/bin/emaint b/bin/emaint index 52ed1f53b..407f8a66d 100755 --- a/bin/emaint +++ b/bin/emaint @@ -277,12 +277,11 @@ class MoveHandler(object): maxval = len(cpv_all) aux_update = self._tree.dbapi.aux_update update_keys = self._update_keys - from itertools import izip from portage.update import update_dbentries if onProgress: onProgress(maxval, 0) for i, cpv in enumerate(cpv_all): - metadata = dict(izip(update_keys, aux_get(cpv, update_keys))) + metadata = dict(zip(update_keys, aux_get(cpv, update_keys))) metadata_updates = update_dbentries(updates, metadata) if metadata_updates: errors.append("'%s' has outdated metadata" % cpv) diff --git a/bin/quickpkg b/bin/quickpkg index f885fff05..fd1728570 100755 --- a/bin/quickpkg +++ b/bin/quickpkg @@ -8,7 +8,6 @@ from __future__ import print_function import errno import signal import sys -from itertools import izip try: import portage @@ -118,7 +117,7 @@ def quickpkg_main(options, args, eout): return False excluded_config_files.append(filename) return True - existing_metadata = dict(izip(fix_metadata_keys, + existing_metadata = dict(zip(fix_metadata_keys, vardb.aux_get(cpv, fix_metadata_keys))) category, pf = portage.catsplit(cpv) required_metadata = {} diff --git a/bin/repoman b/bin/repoman index 613e1ec14..330250258 100755 --- a/bin/repoman +++ b/bin/repoman @@ -27,7 +27,7 @@ import time import platform from io import StringIO -from itertools import chain, izip +from itertools import chain from stat import S_ISDIR, ST_CTIME if not hasattr(__builtins__, "set"): @@ -947,7 +947,7 @@ for x in scanlist: ebuildlist.append(pf) cpv = "%s/%s" % (catdir, pf) try: - myaux = dict(izip(allvars, portdb.aux_get(cpv, allvars))) + myaux = dict(zip(allvars, portdb.aux_get(cpv, allvars))) except KeyError: stats["ebuild.syntax"] += 1 fails["ebuild.syntax"].append(os.path.join(x, y)) diff --git a/pym/_emerge/EbuildMetadataPhase.py b/pym/_emerge/EbuildMetadataPhase.py index 60b91edb8..07d993b7d 100644 --- a/pym/_emerge/EbuildMetadataPhase.py +++ b/pym/_emerge/EbuildMetadataPhase.py @@ -10,7 +10,6 @@ import portage from portage import os from portage import _encodings from portage import _unicode_encode -from itertools import izip import fcntl import codecs @@ -131,7 +130,7 @@ class EbuildMetadataPhase(SubProcess): # number of lines is incorrect. self.returncode = 1 else: - metadata = izip(portage.auxdbkeys, metadata_lines) + metadata = zip(portage.auxdbkeys, metadata_lines) self.metadata = self.metadata_callback(self.cpv, self.ebuild_path, self.repo_path, metadata, self.ebuild_mtime) diff --git a/pym/_emerge/FakeVartree.py b/pym/_emerge/FakeVartree.py index e895cc86b..98d08891c 100644 --- a/pym/_emerge/FakeVartree.py +++ b/pym/_emerge/FakeVartree.py @@ -2,7 +2,6 @@ # Distributed under the terms of the GNU General Public License v2 # $Id$ -from itertools import izip import portage from portage import os from _emerge.Package import Package @@ -50,7 +49,7 @@ class FakeVartree(portage.vartree): if pkg is not None: metadata = pkg.metadata else: - metadata = dict(izip(mykeys, real_dbapi.aux_get(cpv, mykeys))) + metadata = dict(zip(mykeys, real_dbapi.aux_get(cpv, mykeys))) myslot = metadata["SLOT"] mycp = portage.cpv_getkey(cpv) myslot_atom = "%s:%s" % (mycp, myslot) @@ -110,7 +109,7 @@ class FakeVartree(portage.vartree): self._aux_get_history.add(pkg) try: # Use the live ebuild metadata if possible. - live_metadata = dict(izip(self._portdb_keys, + live_metadata = dict(zip(self._portdb_keys, self._portdb.aux_get(pkg, self._portdb_keys))) if not portage.eapi_is_supported(live_metadata["EAPI"]): raise KeyError(pkg) @@ -195,7 +194,7 @@ class FakeVartree(portage.vartree): root_config = self._root_config real_vardb = root_config.trees["vartree"].dbapi pkg = Package(cpv=cpv, installed=True, - metadata=izip(self._db_keys, + metadata=zip(self._db_keys, real_vardb.aux_get(cpv, self._db_keys)), root_config=root_config, type_name="installed") @@ -224,7 +223,7 @@ def grab_global_updates(portdir): def perform_global_updates(mycpv, mydb, mycommands): from portage.update import update_dbentries aux_keys = ["DEPEND", "RDEPEND", "PDEPEND"] - aux_dict = dict(izip(aux_keys, mydb.aux_get(mycpv, aux_keys))) + aux_dict = dict(zip(aux_keys, mydb.aux_get(mycpv, aux_keys))) updates = update_dbentries(mycommands, aux_dict) if updates: mydb.aux_update(mycpv, updates) diff --git a/pym/_emerge/Scheduler.py b/pym/_emerge/Scheduler.py index 337a14f61..aa0a08475 100644 --- a/pym/_emerge/Scheduler.py +++ b/pym/_emerge/Scheduler.py @@ -10,7 +10,6 @@ import sys import textwrap import time import weakref -from itertools import izip import portage from portage import os from portage import _encodings @@ -1670,7 +1669,7 @@ class Scheduler(PollScheduler): db = root_config.trees[tree_type].dbapi db_keys = list(self.trees[root_config.root][ tree_type].dbapi._aux_cache_keys) - metadata = izip(db_keys, db.aux_get(cpv, db_keys)) + metadata = zip(db_keys, db.aux_get(cpv, db_keys)) return Package(built=(type_name != 'ebuild'), cpv=cpv, metadata=metadata, root_config=root_config, installed=installed) diff --git a/pym/_emerge/actions.py b/pym/_emerge/actions.py index 7366b82c7..5ac427d9f 100644 --- a/pym/_emerge/actions.py +++ b/pym/_emerge/actions.py @@ -19,7 +19,7 @@ import stat import sys import textwrap import time -from itertools import chain, izip +from itertools import chain import portage from portage import os @@ -1364,9 +1364,9 @@ def action_info(settings, trees, myopts, myfiles): out = EOutput() for cpv in mypkgs: # Get all package specific variables - metadata = dict(izip(auxkeys, vardb.aux_get(cpv, auxkeys))) + metadata = dict(zip(auxkeys, vardb.aux_get(cpv, auxkeys))) pkg = Package(built=True, cpv=cpv, - installed=True, metadata=izip(Package.metadata_keys, + installed=True, metadata=zip(Package.metadata_keys, (metadata.get(x, '') for x in Package.metadata_keys)), root_config=root_config, type_name='installed') diff --git a/pym/_emerge/depgraph.py b/pym/_emerge/depgraph.py index b157d77c3..0585b9c28 100644 --- a/pym/_emerge/depgraph.py +++ b/pym/_emerge/depgraph.py @@ -9,7 +9,7 @@ import logging import re import sys import textwrap -from itertools import chain, izip +from itertools import chain import portage from portage import os @@ -2538,7 +2538,7 @@ class depgraph(object): db_keys = list(self._frozen_config._trees_orig[root_config.root][ tree_type].dbapi._aux_cache_keys) try: - metadata = izip(db_keys, db.aux_get(cpv, db_keys)) + metadata = zip(db_keys, db.aux_get(cpv, db_keys)) except KeyError: raise portage.exception.PackageNotFound(cpv) pkg = Package(built=(type_name != "ebuild"), cpv=cpv, @@ -5140,7 +5140,7 @@ def get_mask_info(root_config, cpv, pkgsettings, db, pkg_type, built, installed, db_keys): eapi_masked = False try: - metadata = dict(izip(db_keys, + metadata = dict(zip(db_keys, db.aux_get(cpv, db_keys))) except KeyError: metadata = None diff --git a/pym/_emerge/search.py b/pym/_emerge/search.py index 82c49b39c..355307972 100644 --- a/pym/_emerge/search.py +++ b/pym/_emerge/search.py @@ -5,7 +5,6 @@ from __future__ import print_function import re -from itertools import izip import portage from portage import os from portage.output import bold, bold as white, darkgreen, green, red @@ -142,7 +141,7 @@ class search(object): else: db_keys = list(db._aux_cache_keys) for cpv in db.match(atom): - metadata = izip(db_keys, + metadata = zip(db_keys, db.aux_get(cpv, db_keys)) if not self._visible(db, cpv, metadata): continue @@ -165,7 +164,7 @@ class search(object): for cpv in reversed(db.match(atom)): if portage.cpv_getkey(cpv) != cp: continue - metadata = izip(db_keys, + metadata = zip(db_keys, db.aux_get(cpv, db_keys)) if not self._visible(db, cpv, metadata): continue diff --git a/pym/_emerge/unmerge.py b/pym/_emerge/unmerge.py index bb6224fe7..2ea77ab3b 100644 --- a/pym/_emerge/unmerge.py +++ b/pym/_emerge/unmerge.py @@ -7,7 +7,6 @@ from __future__ import print_function import logging import sys import textwrap -from itertools import izip import portage from portage import os from portage.output import bold, colorize, darkgreen, green @@ -42,7 +41,7 @@ def unmerge(root_config, myopts, unmerge_action, pkg = pkg_cache.get(cpv) if pkg is None: pkg = Package(cpv=cpv, installed=True, - metadata=izip(db_keys, vartree.dbapi.aux_get(cpv, db_keys)), + metadata=zip(db_keys, vartree.dbapi.aux_get(cpv, db_keys)), root_config=root_config, type_name="installed") pkg_cache[cpv] = pkg diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py index f0cc471e9..f85ae0c61 100644 --- a/pym/portage/__init__.py +++ b/pym/portage/__init__.py @@ -35,7 +35,7 @@ try: from commands import getstatusoutput as subprocess_getstatusoutput from time import sleep from random import shuffle - from itertools import chain, izip + from itertools import chain import platform import warnings @@ -2586,7 +2586,7 @@ class config(object): pkg_configdict.addLazySingleton(k, mydb.__getitem__, k) else: - for k, v in izip(aux_keys, mydb.aux_get(self.mycpv, aux_keys)): + for k, v in zip(aux_keys, mydb.aux_get(self.mycpv, aux_keys)): pkg_configdict[k] = v repository = pkg_configdict.pop("repository", None) if repository is not None: @@ -6653,7 +6653,7 @@ def doebuild(myebuild, mydo, myroot, mysettings, debug=0, listonly=0, fd_pipes=fd_pipes, returnpid=True, droppriv=droppriv) os.close(pw) # belongs exclusively to the child process now f = os.fdopen(pr, 'rb') - for k, v in izip(auxdbkeys, + for k, v in zip(auxdbkeys, (_unicode_decode(line).rstrip('\n') for line in f)): dbkey[k] = v f.close() @@ -7136,7 +7136,7 @@ def _validate_deps(mysettings, myroot, mydo, mydbapi): misc_keys = ["LICENSE", "PROPERTIES", "PROVIDE", "RESTRICT", "SRC_URI"] other_keys = ["SLOT"] all_keys = dep_keys + misc_keys + other_keys - metadata = dict(izip(all_keys, + metadata = dict(zip(all_keys, mydbapi.aux_get(mysettings.mycpv, all_keys))) class FakeTree(object): @@ -7690,7 +7690,7 @@ def dep_zapdeps(unreduced, reduced, myroot, use_binaries=0, trees=None): if unreduced[0] != "||": unresolved = [] - for x, satisfied in izip(unreduced, reduced): + for x, satisfied in zip(unreduced, reduced): if isinstance(x, list): unresolved += dep_zapdeps(x, satisfied, myroot, use_binaries=use_binaries, trees=trees) @@ -7732,7 +7732,7 @@ def dep_zapdeps(unreduced, reduced, myroot, use_binaries=0, trees=None): # Sort the deps into installed, not installed but already # in the graph and other, not installed and not in the graph # and other, with values of [[required_atom], availablility] - for x, satisfied in izip(deps, satisfieds): + for x, satisfied in zip(deps, satisfieds): if isinstance(x, list): atoms = dep_zapdeps(x, satisfied, myroot, use_binaries=use_binaries, trees=trees) @@ -8174,7 +8174,7 @@ def getmaskingreason(mycpv, metadata=None, settings=None, portdb=None, return_lo if metadata is None: db_keys = list(portdb._aux_cache_keys) try: - metadata = dict(izip(db_keys, portdb.aux_get(mycpv, db_keys))) + metadata = dict(zip(db_keys, portdb.aux_get(mycpv, db_keys))) except KeyError: if not portdb.cpv_exists(mycpv): raise @@ -8250,7 +8250,7 @@ def getmaskingstatus(mycpv, settings=None, portdb=None): if metadata is None: db_keys = list(portdb._aux_cache_keys) try: - metadata = dict(izip(db_keys, portdb.aux_get(mycpv, db_keys))) + metadata = dict(zip(db_keys, portdb.aux_get(mycpv, db_keys))) except KeyError: if not portdb.cpv_exists(mycpv): raise diff --git a/pym/portage/dbapi/__init__.py b/pym/portage/dbapi/__init__.py index ebcd785a0..c904d5d2c 100644 --- a/pym/portage/dbapi/__init__.py +++ b/pym/portage/dbapi/__init__.py @@ -221,14 +221,13 @@ class dbapi(object): aux_get = self.aux_get aux_update = self.aux_update update_keys = ["DEPEND", "RDEPEND", "PDEPEND", "PROVIDE"] - from itertools import izip from portage.update import update_dbentries if onUpdate: onUpdate(maxval, 0) if onProgress: onProgress(maxval, 0) for i, cpv in enumerate(cpv_all): - metadata = dict(izip(update_keys, aux_get(cpv, update_keys))) + metadata = dict(zip(update_keys, aux_get(cpv, update_keys))) metadata_updates = update_dbentries(updates, metadata) if metadata_updates: aux_update(cpv, metadata_updates) diff --git a/pym/portage/dbapi/bintree.py b/pym/portage/dbapi/bintree.py index bc91152a6..9473798e1 100644 --- a/pym/portage/dbapi/bintree.py +++ b/pym/portage/dbapi/bintree.py @@ -29,7 +29,7 @@ import codecs import errno import re import stat -from itertools import chain, izip +from itertools import chain class bindbapi(fakedbapi): _known_keys = frozenset(list(fakedbapi._known_keys) + \ @@ -610,7 +610,7 @@ class binarytree(object): d["MTIME"] = str(long(s.st_mtime)) d["SIZE"] = str(s.st_size) - d.update(izip(self._pkgindex_aux_keys, + d.update(zip(self._pkgindex_aux_keys, self.dbapi.aux_get(mycpv, self._pkgindex_aux_keys))) try: self._eval_use_flags(mycpv, d) @@ -933,7 +933,7 @@ class binarytree(object): pkg_path = self.getname(cpv) from portage.checksum import perform_multiple_checksums - d = dict(izip(self._pkgindex_aux_keys, + d = dict(zip(self._pkgindex_aux_keys, self.dbapi.aux_get(cpv, self._pkgindex_aux_keys))) d.update(perform_multiple_checksums( diff --git a/pym/portage/dbapi/porttree.py b/pym/portage/dbapi/porttree.py index b46abb2cc..ea22abd11 100644 --- a/pym/portage/dbapi/porttree.py +++ b/pym/portage/dbapi/porttree.py @@ -35,7 +35,6 @@ from portage import _unicode_encode import codecs import logging import stat -from itertools import izip def _src_uri_validate(cpv, eapi, src_uri): """ @@ -988,7 +987,7 @@ class portdbapi(dbapi): iterfunc = reversed for cpv in iterfunc(mylist): try: - metadata = dict(izip(aux_keys, + metadata = dict(zip(aux_keys, self.aux_get(cpv, aux_keys))) except KeyError: # ebuild masked by corruption @@ -1070,7 +1069,7 @@ class portdbapi(dbapi): getProfileMaskAtom = self.mysettings._getProfileMaskAtom for cpv in mylist: try: - metadata = dict(izip(db_keys, self.aux_get(cpv, db_keys))) + metadata = dict(zip(db_keys, self.aux_get(cpv, db_keys))) except KeyError: # masked by corruption continue @@ -1097,7 +1096,7 @@ class portdbapi(dbapi): for mycpv in mylist: metadata.clear() try: - metadata.update(izip(aux_keys, self.aux_get(mycpv, aux_keys))) + metadata.update(zip(aux_keys, self.aux_get(mycpv, aux_keys))) except KeyError: continue except PortageException as e: diff --git a/pym/portage/dbapi/vartree.py b/pym/portage/dbapi/vartree.py index 74d12c99a..31bde127a 100644 --- a/pym/portage/dbapi/vartree.py +++ b/pym/portage/dbapi/vartree.py @@ -51,7 +51,6 @@ import codecs import re, shutil, stat, errno, copy, subprocess import logging import sys -from itertools import izip try: import cPickle as pickle @@ -1231,7 +1230,7 @@ class vardbapi(dbapi): if pull_me: # pull any needed data and cache it aux_keys = list(pull_me) - for k, v in izip(aux_keys, + for k, v in zip(aux_keys, self._aux_get(mycpv, aux_keys, st=mydir_stat)): mydata[k] = v if not cache_valid or cache_these.difference(metadata): diff --git a/pym/portage/tests/env/config/test_PortageModulesFile.py b/pym/portage/tests/env/config/test_PortageModulesFile.py index 40472104b..41a44c4cc 100644 --- a/pym/portage/tests/env/config/test_PortageModulesFile.py +++ b/pym/portage/tests/env/config/test_PortageModulesFile.py @@ -6,7 +6,6 @@ from portage import os from portage.tests import TestCase from portage.env.config import PortageModulesFile from tempfile import mkstemp -from itertools import izip class PortageModulesFileTestCase(TestCase): @@ -16,7 +15,7 @@ class PortageModulesFileTestCase(TestCase): def setUp(self): self.items = {} - for k, v in izip(self.keys + self.invalid_keys, + for k, v in zip(self.keys + self.invalid_keys, self.modules): self.items[k] = v diff --git a/pym/repoman/utilities.py b/pym/repoman/utilities.py index 3d8d43aed..23b85ffe3 100644 --- a/pym/repoman/utilities.py +++ b/pym/repoman/utilities.py @@ -20,7 +20,6 @@ __all__ = [ import codecs import errno -import itertools import logging import sys try: @@ -221,7 +220,7 @@ def format_qa_output(formatter, stats, fails, dofull, dofail, options, qawarning full = options.mode == 'full' # we only want key value pairs where value > 0 for category, number in \ - itertools.ifilter(lambda myitem: myitem[1] > 0, stats.iteritems()): + filter(lambda myitem: myitem[1] > 0, stats.iteritems()): formatter.add_literal_data(_unicode_decode(" " + category.ljust(30))) if category in qawarnings: formatter.push_style("WARN")