diff options
author | gengchc2 <geng.changcai2@zte.com.cn> | 2016-12-09 11:37:11 +0800 |
---|---|---|
committer | gengchc2 <geng.changcai2@zte.com.cn> | 2016-12-09 11:37:11 +0800 |
commit | 036d245a5ef6c6f6f11b6c5915179bae392eae1e (patch) | |
tree | 5a2a388699e4d6bd96add31c2a934a530e2fb124 | |
parent | bb8846a3ab0dc92f31a343b7493ada533624a490 (diff) | |
download | oslo-config-036d245a5ef6c6f6f11b6c5915179bae392eae1e.tar.gz |
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
-rw-r--r-- | oslo_config/cfg.py | 2 | ||||
-rw-r--r-- | oslo_config/fixture.py | 5 |
2 files changed, 3 insertions, 4 deletions
diff --git a/oslo_config/cfg.py b/oslo_config/cfg.py index 33db907..82e97aa 100644 --- a/oslo_config/cfg.py +++ b/oslo_config/cfg.py @@ -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): diff --git a/oslo_config/fixture.py b/oslo_config/fixture.py index ca21182..62860f2 100644 --- a/oslo_config/fixture.py +++ b/oslo_config/fixture.py @@ -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)] |