Replace six.iteritems() with .items()

1.As mentioned in [1], we should avoid using
six.iteritems to achieve iterators. We can
use dict.items instead, as it will return
iterators in PY3 as well. And dict.items/keys
will more readable. 2.In py2, the performance
about list should be negligible, see the link [2].
[1] https://wiki.openstack.org/wiki/Python3
[2] http://lists.openstack.org/pipermail/openstack-dev/2015-June/066391.html

Change-Id: I2b2c1e76c4dda9a106ff3783fe882fb8a0f78112
This commit is contained in:
gengchc2 2016-12-09 11:24:04 +08:00
parent 1a94d657ec
commit b86f1cdad8
4 changed files with 4 additions and 7 deletions

View File

@ -98,7 +98,7 @@ class ModuleHelper(object):
"""
# Read in yaml
types_to_skip = (WidgetType.BUTTON, WidgetType.LABEL)
for setting, setting_def in six.iteritems(defaults):
for setting, setting_def in defaults.items():
if (setting_def.get('type') in types_to_skip or
ignoredparams and setting in ignoredparams):
continue

View File

@ -13,7 +13,6 @@
# under the License.
import logging
import six
from fuelmenu.common import utils
from fuelmenu import consts
@ -56,7 +55,7 @@ def puppetApply(classes):
continue
# Build params
for key, value in six.iteritems(cls["params"]):
for key, value in cls["params"].items():
cmd_input.extend([key, "=>", _to_string(value)])
cmd_input.append('}')

View File

@ -18,7 +18,6 @@ import re
import requests
import types
import six
import urwid
import urwid.raw_display
import urwid.web_display
@ -212,7 +211,7 @@ class BootstrapImage(urwid.WidgetWrap):
# on UI we have labels, but not keys...
label_to_key_mapping = dict((v['label'], k) for k, v in
six.iteritems(self.repo_value_scheme))
self.repo_value_scheme.items())
result = []
for lb in external_lw:
repo = {}

View File

@ -16,7 +16,6 @@
import logging
import netaddr
import re
import six
import socket
import urwid
@ -134,7 +133,7 @@ class Interfaces(urwid.WidgetWrap):
errors = []
# Check for the duplicate IP provided
for k, v in six.iteritems(self.netsettings):
for k, v in self.netsettings.items():
if (k != self.activeiface and responses["ipaddr"] != ''
and responses["ipaddr"] == v.get('addr')):
errors.append("The same IP address {0} is assigned for "