TrivialFix: 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: I2a201cce19b66d61924738fb89ded7e265b780ec
This commit is contained in:
zhangjl 2016-12-09 09:01:37 +00:00
parent 41492cc911
commit 69460700a2
2 changed files with 2 additions and 3 deletions

View File

@ -114,7 +114,7 @@ class EtcdAPI(object):
def _filter_resources(self, resources, filters):
for c in list(resources):
for k, v in six.iteritems(filters):
for k, v in filters.items():
if c.get(k) != v:
resources.remove(c)
break

View File

@ -17,7 +17,6 @@ etcd models
"""
import etcd
import six
from zun.common import exception
import zun.db.etcd as db
@ -55,7 +54,7 @@ class Base(object):
def update(self, values):
"""Make the model object behave like a dict."""
for k, v in six.iteritems(values):
for k, v in values.items():
setattr(self, k, v)
def save(self, session=None):