py3:Remove six.iterXXX

1、As mentioned in [1], we should avoid using six.iteritems/keys
   achieve iterators. We can use dict.items/keys 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

TrivialFix.

Change-Id: I0cbe8af3210233a58d25f0df187c3d085405aa2a
This commit is contained in:
Lu lei 2016-08-23 11:08:25 +08:00
parent 755d5172b3
commit 2fb98a6b82
2 changed files with 2 additions and 4 deletions

View File

@ -861,7 +861,7 @@ class KollaWorker(object):
return
def list_children(images, ancestry):
children = six.next(six.itervalues(ancestry))
children = six.next(ancestry.values())
for image in images:
if image.status not in [STATUS_MATCHED]:
continue

View File

@ -18,7 +18,6 @@ from mock import patch
from oslo_log import fixture as log_fixture
from oslo_log import log as logging
from oslotest import base
import six
import testtools
sys.path.append(
@ -28,7 +27,6 @@ from kolla.image import build
LOG = logging.getLogger(__name__)
@six.add_metaclass(abc.ABCMeta)
class BuildTest(object):
excluded_images = abc.abstractproperty()
@ -46,7 +44,7 @@ class BuildTest(object):
bad_results, good_results, unmatched_results = build.run_build()
failures = 0
for image, result in six.iteritems(bad_results):
for image, result in bad_results.items():
if image in self.excluded_images:
if result is 'error':
continue