Merge "Replace six.iteritems() with .items()"

This commit is contained in:
Jenkins 2016-12-13 07:00:07 +00:00 committed by Gerrit Code Review
commit 38f50e0f0e
4 changed files with 10 additions and 13 deletions

View File

@ -166,7 +166,7 @@ class ExtensionDescriptor(object):
if not extension_attrs_map: if not extension_attrs_map:
return return
for resource, attrs in six.iteritems(extension_attrs_map): for resource, attrs in extension_attrs_map.items():
extended_attrs = extended_attributes.get(resource) extended_attrs = extended_attributes.get(resource)
if extended_attrs: if extended_attrs:
attrs.update(extended_attrs) attrs.update(extended_attrs)
@ -196,7 +196,7 @@ class ActionExtensionController(wsgi.Controller):
def action(self, request, id): def action(self, request, id):
input_dict = self._deserialize(request.body, input_dict = self._deserialize(request.body,
request.get_content_type()) request.get_content_type())
for action_name, handler in six.iteritems(self.action_handlers): for action_name, handler in (self.action_handlers).items():
if action_name in input_dict: if action_name in input_dict:
return handler(input_dict, request, id) return handler(input_dict, request, id)
# no action handler found (bump to downstream application) # no action handler found (bump to downstream application)
@ -238,7 +238,7 @@ class ExtensionController(wsgi.Controller):
def index(self, request): def index(self, request):
extensions = [] extensions = []
for _alias, ext in six.iteritems(self.extension_manager.extensions): for _alias, ext in (self.extension_manager.extensions).items():
extensions.append(self._translate(ext)) extensions.append(self._translate(ext))
return dict(extensions=extensions) return dict(extensions=extensions)
@ -279,7 +279,7 @@ class ExtensionMiddleware(wsgi.Middleware):
LOG.debug(_('Extended resource: %s'), LOG.debug(_('Extended resource: %s'),
resource.collection) resource.collection)
for action, method in six.iteritems(resource.collection_actions): for action, method in (resource.collection_actions).items():
conditions = dict(method=[method]) conditions = dict(method=[method])
path = "/%s/%s" % (resource.collection, action) path = "/%s/%s" % (resource.collection, action)
with mapper.submapper(controller=resource.controller, with mapper.submapper(controller=resource.controller,
@ -479,8 +479,7 @@ class ExtensionManager(object):
continue continue
try: try:
extended_attrs = ext.get_extended_resources(version) extended_attrs = ext.get_extended_resources(version)
for resource, resource_attrs in six.iteritems( for resource, resource_attrs in extended_attrs.items():
extended_attrs):
if attr_map.get(resource): if attr_map.get(resource):
attr_map[resource].update(resource_attrs) attr_map[resource].update(resource_attrs)
else: else:

View File

@ -102,7 +102,7 @@ def _should_validate_sub_attributes(attribute, sub_attr):
validate = attribute.get('validate') validate = attribute.get('validate')
return (validate and isinstance(sub_attr, collections.Iterable) and return (validate and isinstance(sub_attr, collections.Iterable) and
any([k.startswith('type:dict') and any([k.startswith('type:dict') and
v for (k, v) in six.iteritems(validate)])) v for (k, v) in validate.items()]))
def _build_subattr_match_rule(attr_name, attr, action, target): def _build_subattr_match_rule(attr_name, attr, action, target):

View File

@ -541,7 +541,7 @@ class JSONV2TestCase(APIv2TestBase, testlib_api.WebTestCase):
output_dict = res['networks'][0] output_dict = res['networks'][0]
input_dict['shared'] = False input_dict['shared'] = False
self.assertEqual(len(input_dict), len(output_dict)) self.assertEqual(len(input_dict), len(output_dict))
for k, v in six.iteritems(input_dict): for k, v in input_dict.items():
self.assertEqual(v, output_dict[k]) self.assertEqual(v, output_dict[k])
else: else:
# expect no results # expect no results
@ -1125,8 +1125,7 @@ class SubresourceTest(base.BaseTestCase):
# Save the global RESOURCE_ATTRIBUTE_MAP # Save the global RESOURCE_ATTRIBUTE_MAP
self.saved_attr_map = {} self.saved_attr_map = {}
for resource, attrs in six.iteritems( for resource, attrs in (attributes.RESOURCE_ATTRIBUTE_MAP).items():
attributes.RESOURCE_ATTRIBUTE_MAP):
self.saved_attr_map[resource] = attrs.copy() self.saved_attr_map[resource] = attrs.copy()
self.config_parse() self.config_parse()
@ -1294,8 +1293,7 @@ class ExtensionTestCase(base.BaseTestCase):
# Save the global RESOURCE_ATTRIBUTE_MAP # Save the global RESOURCE_ATTRIBUTE_MAP
self.saved_attr_map = {} self.saved_attr_map = {}
for resource, attrs in six.iteritems( for resource, attrs in (attributes.RESOURCE_ATTRIBUTE_MAP).items():
attributes.RESOURCE_ATTRIBUTE_MAP):
self.saved_attr_map[resource] = attrs.copy() self.saved_attr_map[resource] = attrs.copy()
# Create the default configurations # Create the default configurations

View File

@ -654,7 +654,7 @@ class Debug(Middleware):
resp = req.get_response(self.application) resp = req.get_response(self.application)
print(("*" * 40) + " RESPONSE HEADERS") print(("*" * 40) + " RESPONSE HEADERS")
for (key, value) in six.iteritems(resp.headers): for (key, value) in (resp.headers).items():
print(key, "=", value) print(key, "=", value)
print() print()