Use range() instead of xrange() for compatibility with Python 3.
authorArfrever Frehtes Taifersar Arahesis <arfrever@gentoo.org>
Mon, 21 Sep 2009 12:49:33 +0000 (12:49 -0000)
committerArfrever Frehtes Taifersar Arahesis <arfrever@gentoo.org>
Mon, 21 Sep 2009 12:49:33 +0000 (12:49 -0000)
(2to3-3.1 -f xrange -nw ${FILES})

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

19 files changed:
bin/archive-conf
bin/portageq
bin/repoman
pym/_emerge/actions.py
pym/_emerge/countdown.py
pym/_emerge/depgraph.py
pym/_emerge/getloadavg.py
pym/_emerge/main.py
pym/_emerge/unmerge.py
pym/portage/__init__.py
pym/portage/cache/metadata.py
pym/portage/cache/template.py
pym/portage/dbapi/bintree.py
pym/portage/getbinpkg.py
pym/portage/manifest.py
pym/portage/output.py
pym/portage/process.py
pym/portage/proxy/lazyimport.py
pym/portage/tests/xpak/test_decodeint.py

index 96c2ea1a8fd891c6f789de83208f72b0fce1e64e..d36dc49d9744cea21506137af6fb6188cba58f41 100755 (executable)
@@ -34,7 +34,7 @@ except ImportError:
     import md5
     def md5_to_hex(md5sum):
         hexform = ""
-        for ix in xrange(len(md5sum)):
+        for ix in range(len(md5sum)):
             hexform = hexform + "%02x" % ord(md5sum[ix])
         return hexform.lower()
     
index 6a0ec5eb03ad251bd0ad249f300e41cabd643314..59eedc59f82e652982fb595f03f23c72f2a0ff4a 100755 (executable)
@@ -611,7 +611,7 @@ def main():
 
        args = sys.argv[2:]
        if args and not isinstance(args[0], unicode):
-               for i in xrange(len(args)):
+               for i in range(len(args)):
                        args[i] = portage._unicode_decode(args[i])
 
        try:
index 823cdce625d34734d5f73a6c5a057856bbbc0fd9..13c126e303c099903765f66f5d7327f4fdf27ad8 100755 (executable)
@@ -968,12 +968,12 @@ for x in scanlist:
 
        # Sort ebuilds in ascending order for the KEYWORDS.dropped check.
        pkgsplits = {}
-       for i in xrange(len(ebuildlist)):
+       for i in range(len(ebuildlist)):
                ebuild_split = portage.pkgsplit(ebuildlist[i])
                pkgsplits[ebuild_split] = ebuildlist[i]
                ebuildlist[i] = ebuild_split
        ebuildlist.sort(key=cmp_sort_key(portage.pkgcmp))
-       for i in xrange(len(ebuildlist)):
+       for i in range(len(ebuildlist)):
                ebuildlist[i] = pkgsplits[ebuildlist[i]]
        del pkgsplits
 
index 5ac427d9f6271a6bfd7096e0512521e2a7b8491b..5c351a0920e2687b14aeaa54fc1be8be991189b0 100644 (file)
@@ -1148,7 +1148,7 @@ def calc_depclean(settings, trees, ldpath_mtimes,
        
                        ignore_priority_range = [None]
                        ignore_priority_range.extend(
-                               xrange(UnmergeDepPriority.MIN, UnmergeDepPriority.MAX + 1))
+                               range(UnmergeDepPriority.MIN, UnmergeDepPriority.MAX + 1))
                        while not graph.empty():
                                for ignore_priority in ignore_priority_range:
                                        nodes = graph.root_nodes(ignore_priority=ignore_priority)
index 12c3e2c07f878465bb1b43f5e2f5fe98b35cc2bd..efb648c764f22eb2d01ad9b5c9bdb3cc7287308c 100644 (file)
@@ -13,7 +13,7 @@ def countdown(secs=5, doing="Starting"):
        if secs:
                print(">>> Waiting",secs,"seconds before starting...")
                print(">>> (Control-C to abort)...\n"+doing+" in: ", end=' ')
-               ticks=range(secs)
+               ticks=list(range(secs))
                ticks.reverse()
                for sec in ticks:
                        sys.stdout.write(colorize("UNMERGE_WARN", str(sec+1)+" "))
index af609a0e43627f6b0ecde282902f97c6386ab978..4954c1a3eb7742a1ad538ff01ebfe4d5ce5663a3 100644 (file)
@@ -1830,11 +1830,11 @@ class depgraph(object):
                # If two packages conflict, discard the lower version.
                discard_pkgs = set()
                greedy_pkgs.sort(reverse=True)
-               for i in xrange(len(greedy_pkgs) - 1):
+               for i in range(len(greedy_pkgs) - 1):
                        pkg1 = greedy_pkgs[i]
                        if pkg1 in discard_pkgs:
                                continue
-                       for j in xrange(i + 1, len(greedy_pkgs)):
+                       for j in range(i + 1, len(greedy_pkgs)):
                                pkg2 = greedy_pkgs[j]
                                if pkg2 in discard_pkgs:
                                        continue
@@ -3148,7 +3148,7 @@ class depgraph(object):
                                                break
                        if not selected_nodes and \
                                not (prefer_asap and asap_nodes):
-                               for i in xrange(priority_range.NONE,
+                               for i in range(priority_range.NONE,
                                        priority_range.MEDIUM_SOFT + 1):
                                        ignore_priority = priority_range.ignore_priority[i]
                                        nodes = get_nodes(ignore_priority=ignore_priority)
@@ -3194,7 +3194,7 @@ class depgraph(object):
                                        mergeable_nodes = set(nodes)
                                        if prefer_asap and asap_nodes:
                                                nodes = asap_nodes
-                                       for i in xrange(priority_range.SOFT,
+                                       for i in range(priority_range.SOFT,
                                                priority_range.MEDIUM_SOFT + 1):
                                                ignore_priority = priority_range.ignore_priority[i]
                                                for node in nodes:
@@ -3930,7 +3930,7 @@ class depgraph(object):
                        mylist.append((x, 0, True))
 
                last_merge_depth = 0
-               for i in xrange(len(mylist)-1,-1,-1):
+               for i in range(len(mylist)-1,-1,-1):
                        graph_key, depth, ordered = mylist[i]
                        if not ordered and depth == 0 and i > 0 \
                                and graph_key == mylist[i-1][0] and \
@@ -3955,7 +3955,7 @@ class depgraph(object):
                # and disable the entire repo display in this case.
                repoadd_set = set()
 
-               for mylist_index in xrange(len(mylist)):
+               for mylist_index in range(len(mylist)):
                        x, depth, ordered = mylist[mylist_index]
                        pkg_type = x[0]
                        myroot = x[1]
index d252e8c0aacfe999a5e829825578e7d146a16a9f..5ff0890cd5225a0065a5f764b6d8421a6165819f 100644 (file)
@@ -20,7 +20,7 @@ if getloadavg is None:
                if len(loadavg_split) < 3:
                        raise OSError('unknown')
                loadavg_floats = []
-               for i in xrange(3):
+               for i in range(3):
                        try:
                                loadavg_floats.append(float(loadavg_split[i]))
                        except ValueError:
index 2ed7667ef6f9879338697cbb26e7baf11354f924..9a101803fb7eed5c9912fa9292caedaf242c74ab 100644 (file)
@@ -770,7 +770,7 @@ def parse_opts(tmpcmdline, silent=False):
                myaction = 'deselect'
 
        if myargs and not isinstance(myargs[0], unicode):
-               for i in xrange(len(myargs)):
+               for i in range(len(myargs)):
                        myargs[i] = portage._unicode_decode(myargs[i])
 
        myfiles += myargs
index 2ea77ab3b7f3f394edff99353b8ad75cb57de770..710a57b2869cb53ae0ec1c0f6b4e5894f74f8c4e 100644 (file)
@@ -305,7 +305,7 @@ def unmerge(root_config, myopts, unmerge_action,
        # listed in "world" as they would be remerged on the next update of "world" or the 
        # relevant package sets.
        unknown_sets = set()
-       for cp in xrange(len(pkgmap)):
+       for cp in range(len(pkgmap)):
                for cpv in pkgmap[cp]["selected"].copy():
                        try:
                                pkg = _pkg(cpv)
@@ -415,7 +415,7 @@ def unmerge(root_config, myopts, unmerge_action,
                                cp_dict[k].update(v)
                pkgmap = [unordered[cp] for cp in sorted(unordered)]
 
-       for x in xrange(len(pkgmap)):
+       for x in range(len(pkgmap)):
                selected = pkgmap[x]["selected"]
                if not selected:
                        continue
@@ -493,7 +493,7 @@ def unmerge(root_config, myopts, unmerge_action,
        if clean_delay and not autoclean:
                countdown(int(settings["CLEAN_DELAY"]), ">>> Unmerging")
 
-       for x in xrange(len(pkgmap)):
+       for x in range(len(pkgmap)):
                for y in pkgmap[x]["selected"]:
                        writemsg_level(">>> Unmerging "+y+"...\n", noiselevel=-1)
                        emergelog(xterm_titles, "=== Unmerging... ("+y+")")
index 6fce50b2cdb71863c09e5e79525ae3e04d485a74..d4b44d29aecf4db05fcc6167486f608085b77b8e 100644 (file)
@@ -2728,7 +2728,7 @@ class config(object):
                        x_split = x.split('_')
                        if len(x_split) == 1:
                                continue
-                       for i in xrange(len(x_split) - 1):
+                       for i in range(len(x_split) - 1):
                                k = '_'.join(x_split[:i+1])
                                if k in use_expand_split:
                                        v = use_expand_iuses.get(k)
@@ -8208,7 +8208,7 @@ def getmaskingreason(mycpv, metadata=None, settings=None, portdb=None, return_lo
                                comment_valid = -1
                                for pmask in pmasklists:
                                        pmask_filename = os.path.join(pmask[0], "package.mask")
-                                       for i in xrange(len(pmask[1])):
+                                       for i in range(len(pmask[1])):
                                                l = pmask[1][i].strip()
                                                if l == "":
                                                        comment = ""
index 2b8047d433c19eea499f89f6466152c9f965809b..8518c0e69820653f8522108b69a6b32584b7d8b5 100644 (file)
@@ -87,7 +87,7 @@ class database(flat_hash.database):
                for k in self.auxdbkey_order:
                        new_content.append(values.get(k, ''))
                        new_content.append('\n')
-               for i in xrange(magic_line_count - len(self.auxdbkey_order)):
+               for i in range(magic_line_count - len(self.auxdbkey_order)):
                        new_content.append('\n')
                new_content = ''.join(new_content)
                new_content = _unicode_encode(new_content,
index 7fc4e9495d2c45eeec38345f729b816e8966e57c..f4e9dfb8de0ace5f5d2c44943aae1961e35730d2 100644 (file)
@@ -221,11 +221,11 @@ def reconstruct_eclasses(cpv, eclass_string):
        d={}
        try:
                if eclasses[1].isdigit():
-                       for x in xrange(0, len(eclasses), 2):
+                       for x in range(0, len(eclasses), 2):
                                d[eclasses[x]] = ("", long(eclasses[x + 1]))
                else:
                        # The old format contains paths that will be discarded.
-                       for x in xrange(0, len(eclasses), 3):
+                       for x in range(0, len(eclasses), 3):
                                d[eclasses[x]] = (eclasses[x + 1], long(eclasses[x + 2]))
        except IndexError:
                raise cache_errors.CacheCorruption(cpv,
index 3728e3e9f4834dec43480d1888a6f5d41dfd74df..c37242419b398e0f6291de653263a5eb3c035e00 100644 (file)
@@ -894,7 +894,7 @@ class binarytree(object):
 
                        # If found, remove package(s) with duplicate path.
                        path = d.get("PATH", "")
-                       for i in xrange(len(pkgindex.packages) - 1, -1, -1):
+                       for i in range(len(pkgindex.packages) - 1, -1, -1):
                                d2 = pkgindex.packages[i]
                                if path and path == d2.get("PATH"):
                                        # Handle path collisions in $PKGDIR/All
index 2003fdbdc0a3bdaf5c5f2e5261cfc3259782154b..5d3864fd123e182e0ef10d44b8dd9fadc5ddeac2 100644 (file)
@@ -648,7 +648,7 @@ def dir_get_metadata(baseurl, conn=None, chunk_size=3000, verbose=1, usingcache=
                                cache_stats.update()
                        metadata[baseurl]["modified"] = 1
                        myid = None
-                       for retry in xrange(3):
+                       for retry in range(3):
                                try:
                                        myid = file_get_metadata(
                                                "/".join((baseurl.rstrip("/"), x.lstrip("/"))),
index e60850e5f501ea5d254ec069e67c5713a761eeea..cd2609c3bf00c56a771aa89f707b8d3a9b4a56d0 100644 (file)
@@ -239,7 +239,7 @@ class Manifest(object):
                                        f.close()
                                        if len(oldentries) == len(myentries):
                                                update_manifest = False
-                                               for i in xrange(len(oldentries)):
+                                               for i in range(len(oldentries)):
                                                        if oldentries[i] != myentries[i]:
                                                                update_manifest = True
                                                                break
index 570de78e98438301d763bcf1916f6a51a50f9499..5f310d30010657c69599d7a4ff177818f5090cf1 100644 (file)
@@ -77,7 +77,7 @@ def color(fg, bg="default", attr=["normal"]):
 
 
 ansi_codes = []
-for x in xrange(30, 38):
+for x in range(30, 38):
        ansi_codes.append("%im" % x)
        ansi_codes.append("%i;01m" % x)
 
@@ -85,7 +85,7 @@ rgb_ansi_colors = ['0x000000', '0x555555', '0xAA0000', '0xFF5555', '0x00AA00',
        '0x55FF55', '0xAA5500', '0xFFFF55', '0x0000AA', '0x5555FF', '0xAA00AA',
        '0xFF55FF', '0x00AAAA', '0x55FFFF', '0xAAAAAA', '0xFFFFFF']
 
-for x in xrange(len(rgb_ansi_colors)):
+for x in range(len(rgb_ansi_colors)):
        codes[rgb_ansi_colors[x]] = esc_seq + ansi_codes[x]
 
 del x
index d24b6f28a27ea8ec94222919d1ed8d7210500f83..b49f061f14b353de8830b6c7ab759d1d0fd51f27 100644 (file)
@@ -35,7 +35,7 @@ if os.path.isdir("/proc/%i/fd" % os.getpid()):
                        if fd.isdigit())
 else:
        def get_open_fds():
-               return xrange(max_fd_limit)
+               return range(max_fd_limit)
 
 sandbox_capable = (os.path.isfile(SANDBOX_BINARY) and
                    os.access(SANDBOX_BINARY, os.X_OK))
index 77e80e02e23a74e621c7e167e5216997b9f6e83a..62428543ef60dcd8699c9880bf527545f0347740 100644 (file)
@@ -137,7 +137,7 @@ def lazyimport(scope, *args):
 
                        components = name.split('.')
                        parent_scope = scope
-                       for i in xrange(len(components)):
+                       for i in range(len(components)):
                                alias = components[i]
                                if i < len(components) - 1:
                                        parent_name = ".".join(components[:i+1])
index 27e8ab7cf841abc1a4edbe7eb488140fa6b355cb..b949b031dcbff45395b91cdcd2590b3200d5e55b 100644 (file)
@@ -10,7 +10,7 @@ class testDecodeIntTestCase(TestCase):
 
        def testDecodeInt(self):
                
-               for n in xrange(1000):
+               for n in range(1000):
                        self.assertEqual(decodeint(encodeint(n)), n)
 
                for n in (2 ** 32 - 1,):