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: Ia082e1a64efbd5f3e9dc6830f14181cb30a11fd2
This commit is contained in:
gengchc2 2016-12-09 10:17:25 +08:00
parent a238d7e22f
commit 5434c8fd86
1 changed files with 1 additions and 2 deletions

View File

@ -19,7 +19,6 @@ import datetime
from dateutil import parser as date_parser
import itertools
import os
import six
from six.moves import configparser as ConfigParser
from six.moves.urllib import parse
import tempfile
@ -265,7 +264,7 @@ def _group_runs_by_key(runs_by_time, groupby_key):
keyfunc = lambda c: c['metadata'][groupby_key]
grouped_runs_by = {}
for timestamp, runs_by_time in six.iteritems(runs_by_time):
for timestamp, runs_by_time in runs_by_time.items():
if timestamp not in grouped_runs_by:
grouped_runs_by[timestamp] = {}
for key, val in itertools.groupby(runs_by_time, keyfunc):