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:
@@ -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:
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import six
|
||||
|
||||
from tempest_lib import exceptions as lib_exc
|
||||
|
||||
@@ -29,7 +28,7 @@ class TestAuditTemplate(base.BaseInfraOptimTest):
|
||||
|
||||
def _assertExpected(self, expected, actual):
|
||||
# Check if not expected keys/values exists in actual response body
|
||||
for key, value in six.iteritems(expected):
|
||||
for key, value in expected.items():
|
||||
if key not in ('created_at', 'updated_at', 'deleted_at'):
|
||||
self.assertIn(key, actual)
|
||||
self.assertEqual(value, actual[key])
|
||||
|
||||
@@ -14,7 +14,6 @@ import functools
|
||||
import json
|
||||
import urllib
|
||||
|
||||
import six
|
||||
|
||||
from tempest.common import service_client
|
||||
|
||||
@@ -79,7 +78,7 @@ class InfraOptimClient(service_client.ServiceClient):
|
||||
"""
|
||||
|
||||
def get_change(kw, path='/'):
|
||||
for name, value in six.iteritems(kw):
|
||||
for name, value in kw.items():
|
||||
if isinstance(value, dict):
|
||||
for ch in get_change(value, path + '%s/' % name):
|
||||
yield ch
|
||||
|
||||
@@ -53,7 +53,7 @@ def make_class_properties(cls):
|
||||
for name, field in supercls.fields.items():
|
||||
if name not in cls.fields:
|
||||
cls.fields[name] = field
|
||||
for name, typefn in six.iteritems(cls.fields):
|
||||
for name, typefn in cls.fields.items():
|
||||
|
||||
def getter(self, name=name):
|
||||
attrname = get_attrname(name)
|
||||
@@ -541,7 +541,7 @@ def obj_to_primitive(obj):
|
||||
return [obj_to_primitive(x) for x in obj]
|
||||
elif isinstance(obj, WatcherObject):
|
||||
result = {}
|
||||
for key, value in six.iteritems(obj):
|
||||
for key, value in obj.items():
|
||||
result[key] = obj_to_primitive(value)
|
||||
return result
|
||||
else:
|
||||
|
||||
@@ -18,7 +18,6 @@ Utils for testing the API service.
|
||||
import datetime
|
||||
import json
|
||||
|
||||
import six
|
||||
from watcher.api.controllers.v1 import action as action_ctrl
|
||||
from watcher.api.controllers.v1 import action_plan as action_plan_ctrl
|
||||
from watcher.api.controllers.v1 import audit as audit_ctrl
|
||||
@@ -78,7 +77,7 @@ def remove_internal(values, internal):
|
||||
# NOTE(yuriyz): internal attributes should not be posted, except uuid
|
||||
int_attr = [attr.lstrip('/') for attr in internal if attr != '/uuid']
|
||||
return dict(
|
||||
(k, v) for (k, v) in six.iteritems(values) if k not in int_attr
|
||||
(k, v) for (k, v) in values.items() if k not in int_attr
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -24,7 +24,6 @@ from oslo_log import log
|
||||
from oslotest import base
|
||||
import pecan
|
||||
from pecan import testing
|
||||
import six
|
||||
import testscenarios
|
||||
|
||||
from watcher.common import context as watcher_context
|
||||
@@ -102,7 +101,7 @@ class TestCase(BaseTestCase):
|
||||
def config(self, **kw):
|
||||
"""Override config options for a test."""
|
||||
group = kw.pop('group', None)
|
||||
for k, v in six.iteritems(kw):
|
||||
for k, v in kw.items():
|
||||
CONF.set_override(k, v, group, enforce_type=True)
|
||||
|
||||
def path_get(self, project_file=None):
|
||||
|
||||
Reference in New Issue
Block a user