[master][py3][PATCH] Replace xrange() with range()

Vratislav Podzimek vpodzime at redhat.com
Fri Jan 30 13:41:33 UTC 2015


xrange() doesn't exist in Python3 where range() works the same way as xrange in
Python2. Using range() in Python2 doesn't bring any significant overhead to
installation.

Signed-off-by: Vratislav Podzimek <vpodzime at redhat.com>
---
 dracut/driver-updates      | 4 ++--
 pyanaconda/ui/gui/utils.py | 2 +-
 scripts/anaconda-yum       | 4 ++--
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/dracut/driver-updates b/dracut/driver-updates
index acd5cd3..7554b4e 100755
--- a/dracut/driver-updates
+++ b/dracut/driver-updates
@@ -313,7 +313,7 @@ def fake_drivers(num):
     """ Generate a number of fake drivers for testing
     """
     drivers = []
-    for i in xrange(0, num):
+    for i in range(0, num):
         d = Driver()
         d.source = "driver-%d" % i
         d.flags = "modules"
@@ -476,7 +476,7 @@ def selection_menu(items, title, info_func, multi_choice=True, refresh=False):
             num_items = page_length
         else:
             num_items = len(items) % page_length
-        for i in xrange(0, num_items):
+        for i in range(0, num_items):
             item_idx = ((page-1) * page_length) + i
             if multi_choice:
                 if items[item_idx].selected:
diff --git a/pyanaconda/ui/gui/utils.py b/pyanaconda/ui/gui/utils.py
index 0e3c50c..775b6d7 100644
--- a/pyanaconda/ui/gui/utils.py
+++ b/pyanaconda/ui/gui/utils.py
@@ -176,7 +176,7 @@ def gtk_batch_map(action, items, args=(), pre_func=None, batch_size=1):
 
         # process as many batches as user shouldn't notice
         while tstamp - tstamp_start < NOTICEABLE_FREEZE:
-            for _i in xrange(batch_size):
+            for _i in range(batch_size):
                 try:
                     action_item = queue.get_nowait()
                     if action_item is TERMINATOR:
diff --git a/scripts/anaconda-yum b/scripts/anaconda-yum
index 9c6dce1..82d7203 100755
--- a/scripts/anaconda-yum
+++ b/scripts/anaconda-yum
@@ -127,7 +127,7 @@ def run_yum_transaction(release, arch, yum_conf, install_root, ts_file, script_l
         print("INFO: populate transaction set")
         xdelay = xprogressive_delay()
 
-        for retry_count in xrange(0, MAX_DOWNLOAD_RETRIES+1):
+        for retry_count in range(0, MAX_DOWNLOAD_RETRIES+1):
             # retry count == 0 -> first attempt
             # retry count > 0  -> retry
             if retry_count:
@@ -292,7 +292,7 @@ class RPMCallback(object):
         exception_message = ""
         xdelay = xprogressive_delay()
 
-        for retry_count in xrange(0, MAX_DOWNLOAD_RETRIES+1):
+        for retry_count in range(0, MAX_DOWNLOAD_RETRIES+1):
             # retry count == 0 -> first attempt
             # retry count > 0  -> retry
             if retry_count and retry_message:
-- 
2.1.0



More information about the anaconda-patches mailing list