From b7a494e7d4318877a0a98811841a282212b40607 Mon Sep 17 00:00:00 2001 From: rajat29 Date: Wed, 14 Jun 2017 12:07:28 +0530 Subject: [PATCH] Replace six.iteritems() with .items() 1.As mentioned in [1], we should avoid usingg 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: I988ff08fe1d6bc52c4a601641c564db7881accf4 --- tackerclient/tacker/v1_0/__init__.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tackerclient/tacker/v1_0/__init__.py b/tackerclient/tacker/v1_0/__init__.py index 884dd98a..09014cb0 100644 --- a/tackerclient/tacker/v1_0/__init__.py +++ b/tackerclient/tacker/v1_0/__init__.py @@ -279,7 +279,7 @@ def parse_args_to_dict(values_specs): # populate the parser with arguments _parser = argparse.ArgumentParser(add_help=False) - for opt, optspec in six.iteritems(_options): + for opt, optspec in _options.items(): _parser.add_argument(opt, **optspec) _args = _parser.parse_args(_values_specs) @@ -303,7 +303,7 @@ def _merge_args(qCmd, parsed_args, _extra_values, value_specs): @param values_specs: the unparsed unknown parts """ temp_values = _extra_values.copy() - for key, value in six.iteritems(temp_values): + for key, value in temp_values.items(): if hasattr(parsed_args, key): arg_value = getattr(parsed_args, key) if arg_value is not None and value is not None: @@ -387,7 +387,7 @@ class TackerCommand(command.OpenStackCommand): def format_output_data(self, data): # Modify data to make it more readable if self.resource in data: - for k, v in six.iteritems(data[self.resource]): + for k, v in data[self.resource].items(): if isinstance(v, list): value = '\n'.join(jsonutils.dumps( i, indent=self.json_indent) if isinstance(i, dict) @@ -450,7 +450,7 @@ class CreateCommand(TackerCommand, show.ShowOne): info.pop(f) else: info = {'': ''} - return zip(*sorted(six.iteritems(info))) + return zip(*sorted(info.items())) class UpdateCommand(TackerCommand): @@ -712,6 +712,6 @@ class ShowCommand(TackerCommand, show.ShowOne): self.format_output_data(data) resource = data[self.resource] if self.resource in data: - return zip(*sorted(six.iteritems(resource))) + return zip(*sorted(resource.items())) else: return None