[gnome-continuous-yocto/gnomeostree-3.28-rocko: 284/8267] wic: don't use dict.keys and dict.has_key



commit 52ce79dcba4c161509a6cc3ee3afe5cd6a99d53f
Author: Ed Bartosh <ed bartosh linux intel com>
Date:   Wed May 4 16:06:16 2016 +0300

    wic: don't use dict.keys and dict.has_key
    
    Replaced calls of dict.keys and dict.has_key methods with the
    'key in dict' statement. 'key in dict' is more pythonic, faster
    and readable. dict.has_key doesn't exist in Python 3.
    
    [YOCTO #9412]
    
    (From OE-Core rev: 003df7dfb932c551953fbf1bd769b3c31bd16fb4)
    
    Signed-off-by: Ed Bartosh <ed bartosh linux intel com>
    Signed-off-by: Richard Purdie <richard purdie linuxfoundation org>

 scripts/lib/wic/imager/baseimager.py   |    2 +-
 scripts/lib/wic/plugin.py              |    2 +-
 scripts/lib/wic/utils/partitionedfs.py |    6 +++---
 3 files changed, 5 insertions(+), 5 deletions(-)
---
diff --git a/scripts/lib/wic/imager/baseimager.py b/scripts/lib/wic/imager/baseimager.py
index 760cf8a..557f536 100644
--- a/scripts/lib/wic/imager/baseimager.py
+++ b/scripts/lib/wic/imager/baseimager.py
@@ -68,7 +68,7 @@ class BaseImageCreator(object):
                      }
 
             # update setting from createopts
-            for key in createopts.keys():
+            for key in createopts:
                 if key in optmap:
                     option = optmap[key]
                 else:
diff --git a/scripts/lib/wic/plugin.py b/scripts/lib/wic/plugin.py
index 80c609c..933647d 100644
--- a/scripts/lib/wic/plugin.py
+++ b/scripts/lib/wic/plugin.py
@@ -137,7 +137,7 @@ class PluginMgr(object):
         return_methods = None
         for _source_name, klass in self.get_plugins('source').items():
             if _source_name == source_name:
-                for _method_name in methods.keys():
+                for _method_name in methods:
                     if not hasattr(klass, _method_name):
                         msger.warning("Unimplemented %s source interface for: %s"\
                                       % (_method_name, _source_name))
diff --git a/scripts/lib/wic/utils/partitionedfs.py b/scripts/lib/wic/utils/partitionedfs.py
index 534635b..89a7c13 100644
--- a/scripts/lib/wic/utils/partitionedfs.py
+++ b/scripts/lib/wic/utils/partitionedfs.py
@@ -132,7 +132,7 @@ class Image(object):
         for num in range(len(self.partitions)):
             part = self.partitions[num]
 
-            if not self.disks.has_key(part['disk_name']):
+            if part['disk_name'] not in self.disks:
                 raise ImageError("No disk %s for partition %s" \
                                  % (part['disk_name'], part['mountpoint']))
 
@@ -236,7 +236,7 @@ class Image(object):
     def __format_disks(self):
         self.layout_partitions()
 
-        for dev in self.disks.keys():
+        for dev in self.disks:
             disk = self.disks[dev]
             msger.debug("Initializing partition table for %s" % \
                         (disk['disk'].device))
@@ -354,7 +354,7 @@ class Image(object):
                 os.rename(source, image_file + '.p%d' % part['num'])
 
     def create(self):
-        for dev in self.disks.keys():
+        for dev in self.disks:
             disk = self.disks[dev]
             disk['disk'].create()
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]