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: Ib27b2784c6cfaa00c76a53b3c041c74866bbd66a
This commit is contained in:
sudhir_agarwal 2017-07-05 15:28:12 +05:30 committed by M V P Nitesh
parent 98806ade0d
commit ad6745453b

View File

@ -13,7 +13,6 @@
# under the License.
from itertools import chain
from six import iteritems
from six.moves import reduce
from oslo_log import log
@ -97,7 +96,7 @@ class StaticDriver(DriverBase):
def _pack_entity(cls, entities_dict, entity):
static_id = entity[StaticFields.STATIC_ID]
if static_id not in entities_dict:
metadata = {key: value for key, value in iteritems(entity)
metadata = {key: value for key, value in entity.items()
if key not in cls.BASE_FIELDS}
entities_dict[static_id] = entity
entity[StaticFields.RELATIONSHIPS] = []