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: I3bdceff37eb43058b9a4c7a1f55c2875eb61c9a4
This commit is contained in:
@@ -54,7 +54,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")
|
||||||
|
|||||||
@@ -297,7 +297,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:
|
||||||
@@ -470,7 +470,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
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ Exception definitions.
|
|||||||
import inspect
|
import inspect
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
import six
|
|
||||||
|
|
||||||
from karborclient.i18n import _
|
from karborclient.i18n import _
|
||||||
|
|
||||||
@@ -410,7 +409,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)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -120,7 +120,7 @@ def print_dict(d, property="Property", dict_format_list=None,
|
|||||||
json_format_list=None):
|
json_format_list=None):
|
||||||
pt = prettytable.PrettyTable([property, 'Value'], caching=False)
|
pt = prettytable.PrettyTable([property, 'Value'], caching=False)
|
||||||
pt.align = 'l'
|
pt.align = 'l'
|
||||||
for r in six.iteritems(d):
|
for r in d.items():
|
||||||
r = list(r)
|
r = list(r)
|
||||||
if isinstance(r[1], six.string_types) and "\r" in r[1]:
|
if isinstance(r[1], six.string_types) and "\r" in r[1]:
|
||||||
r[1] = r[1].replace("\r", " ")
|
r[1] = r[1].replace("\r", " ")
|
||||||
|
|||||||
Reference in New Issue
Block a user