From 9629270987100a9bd4b53313a3c775da62eea166 Mon Sep 17 00:00:00 2001 From: Luong Anh Tuan Date: Tue, 22 Nov 2016 11:17:58 +0700 Subject: [PATCH] Replace six.iteritems() with .items() We should avoid using six.iteritems/keys achieve iterators. We can use dict.items/keys instead, as it wil l return iterators in PY3 as well. And dict.items/keys will more readable. In py2, the performance about list should be negligible, see https://wiki.openstack.org/wiki/Python3 and http://lists.openstack.org/pipermail/openstack-dev/2015-June/066391.html Change-Id: I6f8ee2ed36ed94e2ef8347463f56eed44464a605 --- bifrost/inventory.py | 3 +-- playbooks/library/os_ironic_facts.py | 4 +--- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/bifrost/inventory.py b/bifrost/inventory.py index b1c7b9040..6ecaf1263 100755 --- a/bifrost/inventory.py +++ b/bifrost/inventory.py @@ -114,7 +114,6 @@ intended to support specific host queries. import csv import json import os -import six import sys import yaml @@ -329,7 +328,7 @@ def _process_shade(groups, hostvars): else: name = machine['name'] new_machine = {} - for key, value in six.iteritems(machine): + for key, value in machine.items(): # NOTE(TheJulia): We don't want to pass infomrational links # nor do we want to pass links about the ports since they # are API endpoint URLs. diff --git a/playbooks/library/os_ironic_facts.py b/playbooks/library/os_ironic_facts.py index 7983283ae..f1fdc2fed 100644 --- a/playbooks/library/os_ironic_facts.py +++ b/playbooks/library/os_ironic_facts.py @@ -22,8 +22,6 @@ try: except ImportError: HAS_SHADE = False -import six - DOCUMENTATION = ''' --- module: os_ironic_facts @@ -117,7 +115,7 @@ def main(): new_driver_info = dict() # Rebuild driver_info to remove any password values # as they will be masked. - for key, value in six.iteritems(facts['driver_info']): + for key, value in facts['driver_info'].items(): if 'password' not in key: new_driver_info[key] = value if new_driver_info: