[OE-core] [wic][PATCH 14/14] wic: use next builtin instead of .next method

Ed Bartosh ed.bartosh at linux.intel.com
Wed May 4 13:06:27 UTC 2016


Generators in Python 3 don't have .next method. It's recommended
to use 'next' builtin instead. As it also present in Python >= 2.6
it should make wic code compatible with both Python 2 and Python 3.

[YOCTO #9412]

Signed-off-by: Ed Bartosh <ed.bartosh at linux.intel.com>
---
 scripts/lib/wic/filemap.py | 2 +-
 scripts/lib/wic/msger.py   | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/scripts/lib/wic/filemap.py b/scripts/lib/wic/filemap.py
index 2778be5..f3240ba 100644
--- a/scripts/lib/wic/filemap.py
+++ b/scripts/lib/wic/filemap.py
@@ -482,7 +482,7 @@ class FilemapFiemap(_FilemapBase):
         self._log.debug("FilemapFiemap: get_mapped_ranges(%d,  %d(%d))"
                         % (start, count, start + count - 1))
         iterator = self._do_get_mapped_ranges(start, count)
-        first_prev, last_prev = iterator.next()
+        first_prev, last_prev = next(iterator)
 
         for first, last in iterator:
             if last_prev == first - 1:
diff --git a/scripts/lib/wic/msger.py b/scripts/lib/wic/msger.py
index 4d8e704..fb8336d 100644
--- a/scripts/lib/wic/msger.py
+++ b/scripts/lib/wic/msger.py
@@ -148,7 +148,7 @@ def _split_msg(head, msg):
     return head, msg
 
 def get_loglevel():
-    return (k for k, v in LOG_LEVELS.items() if v == LOG_LEVEL).next()
+    return next((k for k, v in LOG_LEVELS.items() if v == LOG_LEVEL))
 
 def set_loglevel(level):
     global LOG_LEVEL
-- 
2.1.4




More information about the Openembedded-core mailing list