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
This commit is contained in:
M V P Nitesh 2017-04-04 18:57:39 +05:30
parent c25e1619ca
commit 25e04021fd
4 changed files with 7 additions and 10 deletions

View File

@ -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)

View File

@ -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()

View File

@ -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()

View File

@ -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')