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: I0c903ca9d566c89e4e0d6bd129dc1f7bc3e95db9
This commit is contained in:
gengchc2 2016-12-09 10:21:31 +08:00
parent 3fa48c297f
commit b133b85ec1
3 changed files with 5 additions and 9 deletions

View File

@ -48,7 +48,7 @@ class TripleoCommonException(Exception):
# kwargs doesn't match a variable in the message
# log the issue and the kwargs
LOG.exception(_LE('Exception in string format operation'))
for name, value in six.iteritems(kwargs):
for name, value in kwargs.items():
LOG.error(_LE("%(name)s: %(value)s"),
{'name': name, 'value': value}) # noqa

View File

@ -12,9 +12,6 @@
# License for the specific language governing permissions and limitations
# under the License.
import six
import json
import os
import yaml
@ -74,7 +71,7 @@ class BaseImageManager(object):
attr)
# If a new key is introduced, add it.
for key, value in six.iteritems(item):
for key, value in item.items():
if key not in existing_image:
existing_image[key] = item[key]

View File

@ -13,7 +13,6 @@
import copy
import six
from heat.engine.resources.openstack.neutron import net
from heat.engine.resources.openstack.neutron import port
@ -32,7 +31,7 @@ class ImmutableNet(net.Net):
properties_schema = {
k: _copy_schema_immutable(v)
for k, v in six.iteritems(net.Net.properties_schema)
for k, v in net.Net.properties_schema.items()
}
@ -41,7 +40,7 @@ class ImmutablePort(port.Port):
properties_schema = {
k: _copy_schema_immutable(v)
for k, v in six.iteritems(port.Port.properties_schema)
for k, v in port.Port.properties_schema.items()
}
@ -50,7 +49,7 @@ class ImmutableSubnet(subnet.Subnet):
properties_schema = {
k: _copy_schema_immutable(v)
for k, v in six.iteritems(subnet.Subnet.properties_schema)
for k, v in subnet.Subnet.properties_schema.items()
}