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: I8432a85b025a46d20484a0d8a3ec72dca54d23cb
This commit is contained in:
parent
b2f25e97a4
commit
a6ad471636
|
@ -18,7 +18,6 @@ from flask import jsonify
|
|||
from functools import wraps
|
||||
import jsonschema
|
||||
import math
|
||||
import six
|
||||
from six.moves import xrange
|
||||
from sqlalchemy import and_
|
||||
from sqlalchemy import or_
|
||||
|
@ -185,7 +184,7 @@ def split_new_dicts_and_updated_objs(dicts, dict_to_obj_fields_mapping,
|
|||
if obj_idx in existed_objs_idx:
|
||||
# Updating existed object
|
||||
obj = existed_objs_idx[obj_idx]
|
||||
for k, v in six.iteritems(d_copy):
|
||||
for k, v in d_copy.items():
|
||||
setattr(obj, k, v)
|
||||
else:
|
||||
new_dicts.append(d_copy)
|
||||
|
|
|
@ -15,8 +15,6 @@
|
|||
import logging
|
||||
import os
|
||||
|
||||
import six
|
||||
|
||||
|
||||
class Production(object):
|
||||
DEBUG = False
|
||||
|
@ -127,7 +125,7 @@ def index_filtering_rules(app):
|
|||
if not filtering_rules:
|
||||
return
|
||||
|
||||
for release, rules in six.iteritems(filtering_rules):
|
||||
for release, rules in filtering_rules.items():
|
||||
if not rules:
|
||||
continue
|
||||
filtering_rules[release] = convert_rules_to_dict(rules)
|
||||
|
|
|
@ -15,7 +15,6 @@
|
|||
# under the License.
|
||||
|
||||
import argparse
|
||||
import six
|
||||
import yaml
|
||||
|
||||
from migration.test.test_env import configure_test_env
|
||||
|
@ -33,7 +32,7 @@ def handle_external_config(params):
|
|||
|
||||
content = yaml.load(f)
|
||||
if isinstance(content, dict):
|
||||
for k, v in six.iteritems(content):
|
||||
for k, v in content.items():
|
||||
setattr(config, k, v)
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue