Replace six.iteritems(dict) with dict.items()

Replacing dict.iteritems()/.itervalues() with
six.iteritems(dict)/six.itervalues(dict) was preferred in the past
but there was a discussion suggesting to avoid six for this.
ref:
http://lists.openstack.org/pipermail/openstack-dev/2015-June/066391.html

Change-Id: I60cf0f7f23d26528835966f57bc5624c4b446376
This commit is contained in:
wangqun
2016-01-19 03:55:45 +00:00
parent 3570fee8be
commit 0d6aad6486
4 changed files with 5 additions and 5 deletions

View File

@@ -67,7 +67,7 @@ def load_auth_system_opts(parser):
""" """
group = parser.add_argument_group("Common auth options") group = parser.add_argument_group("Common auth options")
BaseAuthPlugin.add_common_opts(group) BaseAuthPlugin.add_common_opts(group)
for name, auth_plugin in six.iteritems(_discovered_plugins): for name, auth_plugin in _discovered_plugins.items():
group = parser.add_argument_group( group = parser.add_argument_group(
"Auth-system '%s' options" % name, "Auth-system '%s' options" % name,
conflict_handler="resolve") conflict_handler="resolve")

View File

@@ -317,7 +317,7 @@ class CrudManager(BaseManager):
def _filter_kwargs(self, kwargs): def _filter_kwargs(self, kwargs):
"""Drop null values and handle ids.""" """Drop null values and handle ids."""
for key, ref in six.iteritems(kwargs.copy()): for key, ref in kwargs.copy().items():
if ref is None: if ref is None:
kwargs.pop(key) kwargs.pop(key)
else: else:
@@ -476,7 +476,7 @@ class Resource(object):
return None return None
def _add_details(self, info): def _add_details(self, info):
for (k, v) in six.iteritems(info): for (k, v) in info.items():
try: try:
setattr(self, k, v) setattr(self, k, v)
self._info[k] = v self._info[k] = v

View File

@@ -423,7 +423,7 @@ class HttpVersionNotSupported(HttpServerError):
# _code_map contains all the classes that have http_status attribute. # _code_map contains all the classes that have http_status attribute.
_code_map = dict( _code_map = dict(
(getattr(obj, 'http_status', None), obj) (getattr(obj, 'http_status', None), obj)
for name, obj in six.iteritems(vars(sys.modules[__name__])) for name, obj in vars(sys.modules[__name__]).items()
if inspect.isclass(obj) and getattr(obj, 'http_status', False) if inspect.isclass(obj) and getattr(obj, 'http_status', False)
) )

View File

@@ -210,7 +210,7 @@ def print_dict(dct, dict_property="Property", wrap=0):
""" """
pt = prettytable.PrettyTable([dict_property, 'Value']) pt = prettytable.PrettyTable([dict_property, 'Value'])
pt.align = 'l' pt.align = 'l'
for k, v in six.iteritems(dct): for k, v in dct.items():
# convert dict to str to check length # convert dict to str to check length
if isinstance(v, dict): if isinstance(v, dict):
v = six.text_type(keys_and_vals_to_strs(v)) v = six.text_type(keys_and_vals_to_strs(v))