Use filter() and zip() instead of itertools.ifilter() and itertools.izip() for compat...
authorArfrever Frehtes Taifersar Arahesis <arfrever@gentoo.org>
Mon, 21 Sep 2009 11:49:13 +0000 (11:49 -0000)
committerArfrever Frehtes Taifersar Arahesis <arfrever@gentoo.org>
Mon, 21 Sep 2009 11:49:13 +0000 (11:49 -0000)
(2to3-3.1 -f itertools -f itertools_imports -nw ${FILES})

svn path=/main/trunk/; revision=14314

17 files changed:
bin/emaint
bin/quickpkg
bin/repoman
pym/_emerge/EbuildMetadataPhase.py
pym/_emerge/FakeVartree.py
pym/_emerge/Scheduler.py
pym/_emerge/actions.py
pym/_emerge/depgraph.py
pym/_emerge/search.py
pym/_emerge/unmerge.py
pym/portage/__init__.py
pym/portage/dbapi/__init__.py
pym/portage/dbapi/bintree.py
pym/portage/dbapi/porttree.py
pym/portage/dbapi/vartree.py
pym/portage/tests/env/config/test_PortageModulesFile.py
pym/repoman/utilities.py

index 52ed1f53b907c84eb6c18aeff315ec2acdfaf09d..407f8a66d7371926f8fc6eb1bd7e5f0edefe7654 100755 (executable)
@@ -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)
index f885fff057813c5e90b9a79e552c1c23c9a255a3..fd172857083ade9eb51dc377361e8a98de324ca9 100755 (executable)
@@ -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 = {}
index 613e1ec140ef6791da17e8989e83bc2f56874e6c..33025025886d1bb56f4a6e00975bfea337a72b9a 100755 (executable)
@@ -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))
index 60b91edb8713d74108850258609640e7106b8cdf..07d993b7d1d14ba45eadd24663140345213773fd 100644 (file)
@@ -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)
index e895cc86bde378f4be9bc278586f084d23a40cdf..98d08891c3d3f26372af026b79dd0c2e9774943b 100644 (file)
@@ -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)
index 337a14f6151ed38b2b8958d1a9b1e71c742663a5..aa0a08475e48a3eb5b5c3e096ba2b5672198382e 100644 (file)
@@ -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)
index 7366b82c78c3be93c3defa00acf78fb55825a529..5ac427d9f6271a6bfd7096e0512521e2a7b8491b 100644 (file)
@@ -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')
 
index b157d77c393014488551c91c101fb4ab4f26c578..0585b9c28b6176f1b5c6af54804eb5cbdc4b5c8b 100644 (file)
@@ -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
index 82c49b39c4c8892d5040560a8a425c0f03e855fa..355307972920e3e60b6aa18034b381df1504653e 100644 (file)
@@ -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
index bb6224fe7c6a6e995b42a19380d71db5d1895d78..2ea77ab3b7f3f394edff99353b8ad75cb57de770 100644 (file)
@@ -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
index f0cc471e960fe56b581e708e9a9f68fba29753a3..f85ae0c6184e407139a25bd35348eb9a8c310111 100644 (file)
@@ -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
index ebcd785a0fb5bd44b8cfb4bc57e8b0cfb1038458..c904d5d2cb43887a87e9eee1ce63b5e76cec21e2 100644 (file)
@@ -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)
index bc91152a66393974486b7f25ad541e79b599b592..9473798e1ceefaf153e6a4af9c5145877f9f6ee5 100644 (file)
@@ -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(
index b46abb2cc01c0813edb833fe29846a7d54be2693..ea22abd11ac5b24ea2d4fcbc97ef0312dadf2a94 100644 (file)
@@ -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:
index 74d12c99a0cf5906a7c634a370510e927d366c69..31bde127ae20f39b4726925174ec27ae4cbc1343 100644 (file)
@@ -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):
index 40472104b8bc24951e47375dd2b703cf2758c264..41a44c4cc0ff9c1cebdc64ca659dd136a92ae803 100644 (file)
@@ -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
 
index 3d8d43aed7a080aeb0c1d930fa56ec3029d9899a..23b85ffe31cf0ebc98c6c1689a73de02fd7bf29a 100644 (file)
@@ -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")