Replace six iteration methods with standard ones

1.As mentioned in [1], we should avoid using six.iterXXX
  to achieve iterators. We can use dict.XXX instead, as it
  will return iterators in PY3 as well.
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: If90a56fad941e4bb55da1e9f14a8133983efc027
This commit is contained in:
LiuNanke 2016-12-01 15:59:42 +08:00
parent aab84fbb2f
commit 2506030cf1
4 changed files with 5 additions and 8 deletions

View File

@ -55,7 +55,7 @@ class TokenSanitizer(object):
:return: Sanitized object
"""
if isinstance(obj, dict):
return dict([self.sanitize(item) for item in six.iteritems(obj)])
return dict([self.sanitize(item) for item in obj.items()])
elif isinstance(obj, list):
return [self.sanitize(item) for item in obj]
elif isinstance(obj, tuple):

View File

@ -67,7 +67,7 @@ def bind(obj, mappings):
return [bind(t, mappings) for t in obj]
elif isinstance(obj, collections.Mapping):
result = {}
for key, value in six.iteritems(obj):
for key, value in obj.items():
result[bind(key, mappings)] = bind(value, mappings)
return result
elif isinstance(obj, six.string_types) and obj.startswith('$'):

View File

@ -13,8 +13,6 @@
# License for the specific language governing permissions and limitations
# under the License.
import six
from murano.dsl import helpers
@ -101,7 +99,7 @@ class CongressRulesManager(object):
for v in obj:
self._walk(v, new_owner, path)
elif isinstance(obj, dict):
for key, value in six.iteritems(obj):
for key, value in obj.items():
self._walk(value, new_owner, path + (key, ))
def _process_item(self, obj, owner_id, path):
@ -152,7 +150,7 @@ class CongressRulesManager(object):
prefix.split('.')[0]))
return rules
for key, value in six.iteritems(obj):
for key, value in obj.items():
if key == '?':
continue

View File

@ -18,7 +18,6 @@ Default actions reside in this module.
These action are available out of the box for Murano users.
"""
import six
import yaql.language.utils as utils
import murano.dsl.exceptions as exceptions
@ -42,7 +41,7 @@ class ActionUtils(object):
for item in obj:
self._get_objects_by_id(item, objects)
elif isinstance(obj, utils.FrozenDict):
for k, v in six.iteritems(obj):
for k, v in obj.items():
self._get_objects_by_id(k, objects)
self._get_objects_by_id(v, objects)
return objects