diff options
author | ji-xuepeng <ji.xuepeng@zte.com.cn> | 2017-02-08 16:27:54 +0800 |
---|---|---|
committer | ji-xuepeng <ji.xuepeng@zte.com.cn> | 2017-02-08 16:33:46 +0800 |
commit | 5fca39dbde82d4cf836fa666b549b606f7ccdb7f (patch) | |
tree | c51fbbbf2a62b170cd7d4625ea5a7c7bab9ef190 /glanceclient/v1 | |
parent | c1f54742f9ed61cd33e1f20342583bee07f1dfae (diff) | |
download | python-glanceclient-5fca39dbde82d4cf836fa666b549b606f7ccdb7f.tar.gz |
Replace six.iteritems() with .items()
1.As mentioned in [1], we should avoid usingg
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: I71c13040318eca6e5ed993e8aa03f8003986a71c
Diffstat (limited to 'glanceclient/v1')
-rw-r--r-- | glanceclient/v1/apiclient/base.py | 4 | ||||
-rw-r--r-- | glanceclient/v1/apiclient/exceptions.py | 2 | ||||
-rw-r--r-- | glanceclient/v1/images.py | 8 | ||||
-rw-r--r-- | glanceclient/v1/shell.py | 3 |
4 files changed, 8 insertions, 9 deletions
diff --git a/glanceclient/v1/apiclient/base.py b/glanceclient/v1/apiclient/base.py index cb48096..a12a8cc 100644 --- a/glanceclient/v1/apiclient/base.py +++ b/glanceclient/v1/apiclient/base.py @@ -317,7 +317,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: @@ -475,7 +475,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 diff --git a/glanceclient/v1/apiclient/exceptions.py b/glanceclient/v1/apiclient/exceptions.py index 5bda5f0..f3d778c 100644 --- a/glanceclient/v1/apiclient/exceptions.py +++ b/glanceclient/v1/apiclient/exceptions.py @@ -421,7 +421,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) ) diff --git a/glanceclient/v1/images.py b/glanceclient/v1/images.py index 182f1e5..966d45a 100644 --- a/glanceclient/v1/images.py +++ b/glanceclient/v1/images.py @@ -72,7 +72,7 @@ class ImageManager(base.ManagerWithFind): def _image_meta_from_headers(self, headers): meta = {'properties': {}} safe_decode = encodeutils.safe_decode - for key, value in six.iteritems(headers): + for key, value in headers.items(): # NOTE(flaper87): this is a compatibility fix # for urllib3 >= 1.11. Please, refer to this # bug for more info: @@ -105,9 +105,9 @@ class ImageManager(base.ManagerWithFind): return str(value) return value - for key, value in six.iteritems(fields_copy.pop('properties', {})): + for key, value in fields_copy.pop('properties', {}).items(): headers['x-image-meta-property-%s' % key] = to_str(value) - for key, value in six.iteritems(fields_copy): + for key, value in fields_copy.items(): headers['x-image-meta-%s' % key] = to_str(value) return headers @@ -224,7 +224,7 @@ class ImageManager(base.ManagerWithFind): return not (image.owner == owner) def paginate(qp, return_request_id=None): - for param, value in six.iteritems(qp): + for param, value in qp.items(): if isinstance(value, six.string_types): # Note(flaper87) Url encoding should # be moved inside http utils, at least diff --git a/glanceclient/v1/shell.py b/glanceclient/v1/shell.py index e1df346..b5ccc93 100644 --- a/glanceclient/v1/shell.py +++ b/glanceclient/v1/shell.py @@ -18,7 +18,6 @@ from __future__ import print_function import copy import functools import os -import six import sys from oslo_utils import encodeutils @@ -128,7 +127,7 @@ def _image_show(image, human_readable=False, max_column_width=80): info = copy.deepcopy(image._info) if human_readable: info['size'] = utils.make_size_human_readable(info['size']) - for (k, v) in six.iteritems(info.pop('properties')): + for (k, v) in info.pop('properties').items(): info['Property \'%s\'' % k] = v utils.print_dict(info, max_column_width=max_column_width) |