From 1213ccb00f706680a963a9d4cdad756a9b51d31e Mon Sep 17 00:00:00 2001 From: Kiran_totad Date: Thu, 29 Jun 2017 10:07:30 +0530 Subject: [PATCH] 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: If5ab2f298e887a90cd43530e3fccc0294412f5c9 --- openstack/object_store/v1/obj.py | 3 +-- openstack/profile.py | 3 +-- openstack/telemetry/v2/capability.py | 3 +-- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/openstack/object_store/v1/obj.py b/openstack/object_store/v1/obj.py index c0fac8c6a..1be77ec16 100644 --- a/openstack/object_store/v1/obj.py +++ b/openstack/object_store/v1/obj.py @@ -12,7 +12,6 @@ # under the License. import copy -import six from openstack.object_store import object_store_service from openstack.object_store.v1 import _base @@ -168,7 +167,7 @@ class Object(_base.BaseResource): # Filter out items with empty values so the create metadata behaviour # is the same as account and container filtered_metadata = \ - {key: value for key, value in six.iteritems(metadata) if value} + {key: value for key, value in metadata.items() if value} # Get a copy of the original metadata so it doesn't get erased on POST # and update it with the new metadata values. diff --git a/openstack/profile.py b/openstack/profile.py index d82b88a6d..69994fafc 100644 --- a/openstack/profile.py +++ b/openstack/profile.py @@ -53,7 +53,6 @@ The resulting preference print out would look something like:: import copy import logging -import six from openstack.bare_metal import bare_metal_service from openstack.block_store import block_store_service @@ -166,7 +165,7 @@ class Profile(object): def get_services(self): """Get a list of all the known services.""" services = [] - for name, service in six.iteritems(self._services): + for name, service in self._services.items(): services.append(service) return services diff --git a/openstack/telemetry/v2/capability.py b/openstack/telemetry/v2/capability.py index cfe11571a..be93db841 100644 --- a/openstack/telemetry/v2/capability.py +++ b/openstack/telemetry/v2/capability.py @@ -10,7 +10,6 @@ # License for the specific language governing permissions and limitations # under the License. -import six from openstack import resource2 as resource from openstack.telemetry import telemetry_service @@ -34,5 +33,5 @@ class Capability(resource.Resource): resp = session.get(cls.base_path, endpoint_filter=cls.service, params=params) resp = resp.json() - for key, value in six.iteritems(resp['api']): + for key, value in resp['api'].items(): yield cls.existing(id=key, enabled=value)