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: Ic4fe5a3badfda93af11683215f0dad9b886e4791
This commit is contained in:
@@ -54,7 +54,7 @@ def load_auth_system_opts(parser):
|
||||
"""
|
||||
group = parser.add_argument_group("Common auth options")
|
||||
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(
|
||||
"Auth-system '%s' options" % name,
|
||||
conflict_handler="resolve")
|
||||
|
@@ -304,7 +304,7 @@ class CrudManager(BaseManager):
|
||||
|
||||
def _filter_kwargs(self, kwargs):
|
||||
"""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:
|
||||
kwargs.pop(key)
|
||||
else:
|
||||
@@ -462,7 +462,7 @@ class Resource(object):
|
||||
return None
|
||||
|
||||
def _add_details(self, info):
|
||||
for (k, v) in six.iteritems(info):
|
||||
for (k, v) in info.items():
|
||||
try:
|
||||
setattr(self, k, v)
|
||||
self._info[k] = v
|
||||
|
@@ -23,7 +23,6 @@ Exception definitions.
|
||||
import inspect
|
||||
import sys
|
||||
|
||||
import six
|
||||
|
||||
from solumclient.i18n import _
|
||||
|
||||
@@ -411,7 +410,7 @@ class HttpVersionNotSupported(HttpServerError):
|
||||
# _code_map contains all the classes that have http_status attribute.
|
||||
_code_map = dict(
|
||||
(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)
|
||||
)
|
||||
|
||||
|
@@ -187,7 +187,7 @@ def print_dict(dct, dict_property="Property", wrap=0):
|
||||
"""
|
||||
pt = prettytable.PrettyTable([dict_property, 'Value'], caching=False)
|
||||
pt.align = 'l'
|
||||
for k, v in six.iteritems(dct):
|
||||
for k, v in dct.items():
|
||||
# convert dict to str to check length
|
||||
if isinstance(v, dict):
|
||||
v = six.text_type(v)
|
||||
|
@@ -12,8 +12,6 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import six
|
||||
|
||||
from solumclient.common.apiclient import exceptions
|
||||
from solumclient.common import exc
|
||||
from solumclient.tests import base
|
||||
@@ -23,7 +21,7 @@ class FakeResponse(object):
|
||||
json_data = {}
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
for key, value in six.iteritems(kwargs):
|
||||
for key, value in kwargs.items():
|
||||
setattr(self, key, value)
|
||||
|
||||
def json(self):
|
||||
|
@@ -12,8 +12,6 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import six
|
||||
|
||||
from solumclient.common.apiclient import base as apiclient_base
|
||||
from solumclient.common.apiclient import exceptions
|
||||
from solumclient.common import base as solum_base
|
||||
@@ -42,7 +40,7 @@ class Artifact(apiclient_base.Resource):
|
||||
for res in req_list if req_list]
|
||||
|
||||
def _add_details(self, info):
|
||||
for (k, v) in six.iteritems(info):
|
||||
for (k, v) in info.items():
|
||||
try:
|
||||
if k == 'requirements':
|
||||
v = self._add_requirements_details(v)
|
||||
@@ -66,7 +64,7 @@ class Plan(apiclient_base.Resource):
|
||||
for res in serv_list if serv_list]
|
||||
|
||||
def _add_details(self, info):
|
||||
for (k, v) in six.iteritems(info):
|
||||
for (k, v) in info.items():
|
||||
try:
|
||||
if k == 'artifacts':
|
||||
v = self._add_artifact_details(v)
|
||||
|
Reference in New Issue
Block a user