Use dict.items() dirrectly instead of six.iteritems

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: I63b1e51597307862968f37803ffdbba63306d8c6
This commit is contained in:
ting.wang
2016-01-14 14:02:36 +08:00
parent dc6b8aad7e
commit 08fc69cfc4
6 changed files with 8 additions and 12 deletions

View File

@@ -42,7 +42,7 @@ CONF.register_opts(exc_log_opts)
def _cleanse_dict(original):
"""Strip all admin_password, new_pass, rescue_pass keys from a dict"""
return dict((k, v) for k, v in six.iteritems(original) if "_pass" not in k)
return dict((k, v) for k, v in original.items() if "_pass" not in k)
class WatcherException(Exception):
@@ -75,7 +75,7 @@ class WatcherException(Exception):
# kwargs doesn't match a variable in the message
# log the issue and the kwargs
LOG.exception(_LE('Exception in string format operation'))
for name, value in six.iteritems(kwargs):
for name, value in kwargs.items():
LOG.error("%s: %s", name, value)
if CONF.fatal_exception_format_errors: