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: I8b1e3dd75c700c3c2d41223309cd6c3af1ebdddc
This commit is contained in:
gengchc2 2016-12-09 11:37:11 +08:00
parent bb8846a3ab
commit 036d245a5e
2 changed files with 3 additions and 4 deletions

View File

@ -2156,7 +2156,7 @@ class _CachedArgumentParser(argparse.ArgumentParser):
# not touch positional. For the reason optional opts go first in
# the values we only need to find an index of the first positional
# option and then sort the values slice.
for container, values in six.iteritems(self._args_cache):
for container, values in self._args_cache.items():
index = 0
has_positional = False
for index, argument in enumerate(values):

View File

@ -16,7 +16,6 @@
# under the License.
import fixtures
import six
from oslo_config import cfg
@ -70,7 +69,7 @@ class Config(fixtures.Fixture):
group = kw.pop('group', None)
enforce_type = kw.pop('enforce_type', False)
for k, v in six.iteritems(kw):
for k, v in kw.items():
self.conf.set_override(k, v, group, enforce_type=enforce_type)
def _unregister_config_opts(self):
@ -174,7 +173,7 @@ class Config(fixtures.Fixture):
raw_config = dict()
raw_config[group] = dict()
for key, value in six.iteritems(kwargs):
for key, value in kwargs.items():
# Parsed values are an array of raw strings.
raw_config[group][key] = [str(value)]