]> code.ossystems Code Review - openembedded-core.git/commitdiff
wic: don't use dict.keys and dict.has_key
authorEd Bartosh <ed.bartosh@linux.intel.com>
Wed, 4 May 2016 13:06:16 +0000 (16:06 +0300)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Sat, 14 May 2016 06:26:42 +0000 (07:26 +0100)
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]

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
scripts/lib/wic/plugin.py
scripts/lib/wic/utils/partitionedfs.py

index 760cf8a58a95f398ea9f9f95ae3d44f470759283..557f5366770dda6dcc1333c6941d5abb48d6985f 100644 (file)
@@ -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:
index 80c609cf8c091b690be2b1c95c689b108ea1f820..933647d7c72b281dbba4e65e132a55043ae42dfe 100644 (file)
@@ -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))
index 534635b2ac8c961a92349b52c67a3e7fd511f824..89a7c13758887f1db5c2b53a37fa51c287c059cc 100644 (file)
@@ -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()