From: Arfrever Frehtes Taifersar Arahesis Date: Mon, 21 Sep 2009 12:49:33 +0000 (-0000) Subject: Use range() instead of xrange() for compatibility with Python 3. X-Git-Tag: v2.2_rc42~85 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=fa8ea8ef3cc8a7433d496e3dc54d56a0bd2ffd06;p=portage.git Use range() instead of xrange() for compatibility with Python 3. (2to3-3.1 -f xrange -nw ${FILES}) svn path=/main/trunk/; revision=14317 --- diff --git a/bin/archive-conf b/bin/archive-conf index 96c2ea1a8..d36dc49d9 100755 --- a/bin/archive-conf +++ b/bin/archive-conf @@ -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() diff --git a/bin/portageq b/bin/portageq index 6a0ec5eb0..59eedc59f 100755 --- a/bin/portageq +++ b/bin/portageq @@ -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: diff --git a/bin/repoman b/bin/repoman index 823cdce62..13c126e30 100755 --- a/bin/repoman +++ b/bin/repoman @@ -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 diff --git a/pym/_emerge/actions.py b/pym/_emerge/actions.py index 5ac427d9f..5c351a092 100644 --- a/pym/_emerge/actions.py +++ b/pym/_emerge/actions.py @@ -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) diff --git a/pym/_emerge/countdown.py b/pym/_emerge/countdown.py index 12c3e2c07..efb648c76 100644 --- a/pym/_emerge/countdown.py +++ b/pym/_emerge/countdown.py @@ -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)+" ")) diff --git a/pym/_emerge/depgraph.py b/pym/_emerge/depgraph.py index af609a0e4..4954c1a3e 100644 --- a/pym/_emerge/depgraph.py +++ b/pym/_emerge/depgraph.py @@ -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] diff --git a/pym/_emerge/getloadavg.py b/pym/_emerge/getloadavg.py index d252e8c0a..5ff0890cd 100644 --- a/pym/_emerge/getloadavg.py +++ b/pym/_emerge/getloadavg.py @@ -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: diff --git a/pym/_emerge/main.py b/pym/_emerge/main.py index 2ed7667ef..9a101803f 100644 --- a/pym/_emerge/main.py +++ b/pym/_emerge/main.py @@ -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 diff --git a/pym/_emerge/unmerge.py b/pym/_emerge/unmerge.py index 2ea77ab3b..710a57b28 100644 --- a/pym/_emerge/unmerge.py +++ b/pym/_emerge/unmerge.py @@ -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+")") diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py index 6fce50b2c..d4b44d29a 100644 --- a/pym/portage/__init__.py +++ b/pym/portage/__init__.py @@ -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 = "" diff --git a/pym/portage/cache/metadata.py b/pym/portage/cache/metadata.py index 2b8047d43..8518c0e69 100644 --- a/pym/portage/cache/metadata.py +++ b/pym/portage/cache/metadata.py @@ -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, diff --git a/pym/portage/cache/template.py b/pym/portage/cache/template.py index 7fc4e9495..f4e9dfb8d 100644 --- a/pym/portage/cache/template.py +++ b/pym/portage/cache/template.py @@ -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, diff --git a/pym/portage/dbapi/bintree.py b/pym/portage/dbapi/bintree.py index 3728e3e9f..c37242419 100644 --- a/pym/portage/dbapi/bintree.py +++ b/pym/portage/dbapi/bintree.py @@ -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 diff --git a/pym/portage/getbinpkg.py b/pym/portage/getbinpkg.py index 2003fdbdc..5d3864fd1 100644 --- a/pym/portage/getbinpkg.py +++ b/pym/portage/getbinpkg.py @@ -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("/"))), diff --git a/pym/portage/manifest.py b/pym/portage/manifest.py index e60850e5f..cd2609c3b 100644 --- a/pym/portage/manifest.py +++ b/pym/portage/manifest.py @@ -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 diff --git a/pym/portage/output.py b/pym/portage/output.py index 570de78e9..5f310d300 100644 --- a/pym/portage/output.py +++ b/pym/portage/output.py @@ -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 diff --git a/pym/portage/process.py b/pym/portage/process.py index d24b6f28a..b49f061f1 100644 --- a/pym/portage/process.py +++ b/pym/portage/process.py @@ -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)) diff --git a/pym/portage/proxy/lazyimport.py b/pym/portage/proxy/lazyimport.py index 77e80e02e..62428543e 100644 --- a/pym/portage/proxy/lazyimport.py +++ b/pym/portage/proxy/lazyimport.py @@ -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]) diff --git a/pym/portage/tests/xpak/test_decodeint.py b/pym/portage/tests/xpak/test_decodeint.py index 27e8ab7cf..b949b031d 100644 --- a/pym/portage/tests/xpak/test_decodeint.py +++ b/pym/portage/tests/xpak/test_decodeint.py @@ -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,):