[PATCH 2/2] Use the built-in next() function for generators
Martin Kolman
mkolman at redhat.com
Fri Jun 27 13:17:39 UTC 2014
The next() function of the generator object has been removed
in Python 3 but the equivalent built-in next() function is available
in both Python 2 and 3.
Signed-off-by: Martin Kolman <mkolman at redhat.com>
---
pyanaconda/anaconda_argparse.py | 2 +-
pyanaconda/bootloader.py | 2 +-
pyanaconda/ui/gui/hubs/progress.py | 2 +-
scripts/anaconda-yum | 4 ++--
4 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/pyanaconda/anaconda_argparse.py b/pyanaconda/anaconda_argparse.py
index d9a58ee..b8242e0 100644
--- a/pyanaconda/anaconda_argparse.py
+++ b/pyanaconda/anaconda_argparse.py
@@ -281,7 +281,7 @@ def name_path_pairs(image_specs):
if name in names_seen:
names = ("%s_%d" % (name, n) for n in itertools.count())
- name = itertools.dropwhile(lambda n: n in names_seen, names).next()
+ name = next(itertools.dropwhile(lambda n: n in names_seen, names))
names_seen.append(name)
yield name, path
diff --git a/pyanaconda/bootloader.py b/pyanaconda/bootloader.py
index c0e34da..493b935 100644
--- a/pyanaconda/bootloader.py
+++ b/pyanaconda/bootloader.py
@@ -2322,7 +2322,7 @@ def writeSysconfigKernel(storage, version, instClass):
ts = rpm.TransactionSet(iutil.getSysroot())
mi = ts.dbMatch('basenames', kernel_file)
try:
- h = mi.next()
+ h = next(mi)
except StopIteration:
log.error("failed to get package name for default kernel")
return
diff --git a/pyanaconda/ui/gui/hubs/progress.py b/pyanaconda/ui/gui/hubs/progress.py
index 0dd0ef8..1c33abd 100644
--- a/pyanaconda/ui/gui/hubs/progress.py
+++ b/pyanaconda/ui/gui/hubs/progress.py
@@ -191,7 +191,7 @@ class ProgressHub(Hub):
# image's filename. Note that self._rnotesPages is an infinite list,
# so this will cycle through the images indefinitely.
try:
- nxt = self._rnotesPages.next()
+ nxt = next(self._rnotesPages)
except StopIteration:
# there are no rnotes
pass
diff --git a/scripts/anaconda-yum b/scripts/anaconda-yum
index e041b90..77067c7 100755
--- a/scripts/anaconda-yum
+++ b/scripts/anaconda-yum
@@ -132,7 +132,7 @@ def run_yum_transaction(release, arch, yum_conf, install_root, ts_file, script_l
# retry count > 0 -> retry
if retry_count:
# retry after waiting a bit
- time.sleep(xdelay.next())
+ time.sleep(next(xdelay))
print("PROGRESS_INSTALL: error populating transaction, retrying (%d/%d)"
% (retry_count, MAX_DOWNLOAD_RETRIES))
try:
@@ -296,7 +296,7 @@ class RPMCallback(object):
# retry count == 0 -> first attempt
# retry count > 0 -> retry
if retry_count and retry_message:
- time.sleep(xdelay.next()) # wait a bit before retry
+ time.sleep(next(xdelay)) # wait a bit before retry
print("PROGRESS_INSTALL: %s (%d/%d)" % (retry_message, retry_count, MAX_DOWNLOAD_RETRIES))
try:
--
1.9.3
More information about the anaconda-patches
mailing list