From 25e04021fd23a038f0572934643c2c59adb55a25 Mon Sep 17 00:00:00 2001 From: M V P Nitesh Date: Tue, 4 Apr 2017 18:57:39 +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: I45fa65427318e1c35bb521de46e81ea12ca7b770 --- .../services/artifacts/artifacts_client.py | 3 +-- .../api/application_catalog/artifacts/test_versioning.py | 3 +-- .../artifacts/test_versioning_negative.py | 3 +-- murano_tempest_tests/utils.py | 8 ++++---- 4 files changed, 7 insertions(+), 10 deletions(-) diff --git a/murano_tempest_tests/services/artifacts/artifacts_client.py b/murano_tempest_tests/services/artifacts/artifacts_client.py index 3b3c1a1..789497b 100644 --- a/murano_tempest_tests/services/artifacts/artifacts_client.py +++ b/murano_tempest_tests/services/artifacts/artifacts_client.py @@ -20,7 +20,6 @@ from tempest import config from tempest.lib.common import rest_client from murano_tempest_tests import utils -import six CONF = config.CONF @@ -132,7 +131,7 @@ class ArtifactsClient(rest_client.RestClient): 'tags': manifest.get('Tags', []), 'class_definitions': package.classes.keys() } - for k, v in six.iteritems(body): + for k, v in body.items(): package_draft[k] = v inherits = utils.get_local_inheritance(package.classes) diff --git a/murano_tempest_tests/tests/api/application_catalog/artifacts/test_versioning.py b/murano_tempest_tests/tests/api/application_catalog/artifacts/test_versioning.py index ba704ef..3ce0320 100644 --- a/murano_tempest_tests/tests/api/application_catalog/artifacts/test_versioning.py +++ b/murano_tempest_tests/tests/api/application_catalog/artifacts/test_versioning.py @@ -13,7 +13,6 @@ # under the License. import os -import six import testtools from tempest import config @@ -60,7 +59,7 @@ class TestVersioning(base.BaseArtifactsTest): @classmethod def resource_cleanup(cls): - for pkg in six.itervalues(cls.packages): + for pkg in cls.packages.values(): cls.artifacts_client.delete_package(pkg['id']) map(os.remove, cls.abs_archive_paths) super(TestVersioning, cls).resource_cleanup() diff --git a/murano_tempest_tests/tests/api/application_catalog/artifacts/test_versioning_negative.py b/murano_tempest_tests/tests/api/application_catalog/artifacts/test_versioning_negative.py index 298e3b1..5e86b1b 100644 --- a/murano_tempest_tests/tests/api/application_catalog/artifacts/test_versioning_negative.py +++ b/murano_tempest_tests/tests/api/application_catalog/artifacts/test_versioning_negative.py @@ -13,7 +13,6 @@ # under the License. import os -import six import testtools from tempest import config @@ -54,7 +53,7 @@ class TestVersioningNegative(base.BaseArtifactsTest): @classmethod def resource_cleanup(cls): - for pkg in six.itervalues(cls.packages): + for pkg in cls.packages.values(): cls.artifacts_client.delete_package(pkg['id']) map(os.remove, cls.abs_archive_paths) super(TestVersioningNegative, cls).resource_cleanup() diff --git a/murano_tempest_tests/utils.py b/murano_tempest_tests/utils.py index 4049714..79d628d 100644 --- a/murano_tempest_tests/utils.py +++ b/murano_tempest_tests/utils.py @@ -319,8 +319,8 @@ class Package(FileWrapperMixin): def classes(self): if not hasattr(self, '_classes'): self._classes = {} - for class_name, class_file in six.iteritems( - self.manifest.get('Classes', {})): + for class_name, class_file in ( + self.manifest.get('Classes', {}).items()): filename = "Classes/%s" % class_file if filename not in self.contents.namelist(): continue @@ -431,7 +431,7 @@ class Package(FileWrapperMixin): def _get_direct_deps(package, base_url, path): result = [] if 'Require' in package.manifest: - for dep_name, ver in six.iteritems(package.manifest['Require']): + for dep_name, ver in package.manifest['Require'].items(): try: req_file = Package.from_location( dep_name, @@ -480,7 +480,7 @@ class NamespaceResolver(object): def get_local_inheritance(classes): result = {} - for class_name, klass in six.iteritems(classes): + for class_name, klass in classes.items(): if 'Extends' not in klass: continue ns = klass.get('Namespaces')