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: I522e8f06e8a31b0d591db825d0c1608f162cbbc6
This commit is contained in:
parent
d594bc2438
commit
77be8fa29c
|
@ -25,7 +25,6 @@ from apscheduler.schedulers import background
|
||||||
from freezerclient.v1 import client
|
from freezerclient.v1 import client
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
from oslo_log import log
|
from oslo_log import log
|
||||||
import six
|
|
||||||
|
|
||||||
from freezer.scheduler import arguments
|
from freezer.scheduler import arguments
|
||||||
from freezer.scheduler import scheduler_job
|
from freezer.scheduler import scheduler_job
|
||||||
|
@ -181,7 +180,7 @@ class FreezerScheduler(object):
|
||||||
job.process_event(job_doc)
|
job.process_event(job_doc)
|
||||||
|
|
||||||
# request removal of any job that has been removed in the api
|
# request removal of any job that has been removed in the api
|
||||||
for job_id, job in six.iteritems(self.jobs):
|
for job_id, job in self.jobs.items():
|
||||||
if job_id not in work_job_id_list:
|
if job_id not in work_job_id_list:
|
||||||
job.remove()
|
job.remove()
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@ import tempfile
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
import paramiko
|
import paramiko
|
||||||
import six
|
|
||||||
from six.moves import range
|
from six.moves import range
|
||||||
|
|
||||||
FREEZERC = distutils.spawn.find_executable('freezer-agent')
|
FREEZERC = distutils.spawn.find_executable('freezer-agent')
|
||||||
|
@ -47,7 +47,7 @@ class CommandFailed(Exception):
|
||||||
|
|
||||||
|
|
||||||
def dict_to_args(d):
|
def dict_to_args(d):
|
||||||
l = [['--' + k.replace('_', '-'), v] for k, v in six.iteritems(d)]
|
l = [['--' + k.replace('_', '-'), v] for k, v in d.items()]
|
||||||
return list(itertools.chain.from_iterable(l))
|
return list(itertools.chain.from_iterable(l))
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,6 @@
|
||||||
import ctypes
|
import ctypes
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
import six
|
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
|
||||||
|
@ -75,5 +74,5 @@ def set_environment(home):
|
||||||
json_env = os.path.join(home, 'env.json')
|
json_env = os.path.join(home, 'env.json')
|
||||||
with open(json_env, 'rb') as fp:
|
with open(json_env, 'rb') as fp:
|
||||||
env = json.loads(fp.read())
|
env = json.loads(fp.read())
|
||||||
for k, v in six.iteritems(env):
|
for k, v in env.items():
|
||||||
os.environ[str(k).strip()] = str(v).strip()
|
os.environ[str(k).strip()] = str(v).strip()
|
||||||
|
|
Loading…
Reference in New Issue