py3.x: Use six.iteritems for Iterable dict items.
py3.x: Use six.iteritems for Iterable dict items instead of dict.iteritems. Change-Id: Ibc4dbee779c1da52eba5b9ed34b982103c404e7f Related-Bug: #1547712
This commit is contained in:
@@ -278,7 +278,7 @@ def parse_args_to_dict(values_specs):
|
|||||||
|
|
||||||
# populate the parser with arguments
|
# populate the parser with arguments
|
||||||
_parser = argparse.ArgumentParser(add_help=False)
|
_parser = argparse.ArgumentParser(add_help=False)
|
||||||
for opt, optspec in _options.iteritems():
|
for opt, optspec in six.iteritems(_options):
|
||||||
_parser.add_argument(opt, **optspec)
|
_parser.add_argument(opt, **optspec)
|
||||||
_args = _parser.parse_args(_values_specs)
|
_args = _parser.parse_args(_values_specs)
|
||||||
|
|
||||||
@@ -302,7 +302,7 @@ def _merge_args(qCmd, parsed_args, _extra_values, value_specs):
|
|||||||
@param values_specs: the unparsed unknown parts
|
@param values_specs: the unparsed unknown parts
|
||||||
"""
|
"""
|
||||||
temp_values = _extra_values.copy()
|
temp_values = _extra_values.copy()
|
||||||
for key, value in temp_values.iteritems():
|
for key, value in six.iteritems(temp_values):
|
||||||
if hasattr(parsed_args, key):
|
if hasattr(parsed_args, key):
|
||||||
arg_value = getattr(parsed_args, key)
|
arg_value = getattr(parsed_args, key)
|
||||||
if arg_value is not None and value is not None:
|
if arg_value is not None and value is not None:
|
||||||
@@ -388,7 +388,7 @@ class TackerCommand(command.OpenStackCommand):
|
|||||||
if self.resource in data:
|
if self.resource in data:
|
||||||
data[self.resource] = strutils.mask_dict_password(
|
data[self.resource] = strutils.mask_dict_password(
|
||||||
data[self.resource])
|
data[self.resource])
|
||||||
for k, v in data[self.resource].iteritems():
|
for k, v in six.iteritems(data[self.resource]):
|
||||||
if isinstance(v, list):
|
if isinstance(v, list):
|
||||||
value = '\n'.join(jsonutils.dumps(
|
value = '\n'.join(jsonutils.dumps(
|
||||||
i, indent=self.json_indent) if isinstance(i, dict)
|
i, indent=self.json_indent) if isinstance(i, dict)
|
||||||
@@ -451,7 +451,7 @@ class CreateCommand(TackerCommand, show.ShowOne):
|
|||||||
info.pop(f)
|
info.pop(f)
|
||||||
else:
|
else:
|
||||||
info = {'': ''}
|
info = {'': ''}
|
||||||
return zip(*sorted(info.iteritems()))
|
return zip(*sorted(six.iteritems(info)))
|
||||||
|
|
||||||
|
|
||||||
class UpdateCommand(TackerCommand):
|
class UpdateCommand(TackerCommand):
|
||||||
@@ -682,6 +682,6 @@ class ShowCommand(TackerCommand, show.ShowOne):
|
|||||||
self.format_output_data(data)
|
self.format_output_data(data)
|
||||||
resource = data[self.resource]
|
resource = data[self.resource]
|
||||||
if self.resource in data:
|
if self.resource in data:
|
||||||
return zip(*sorted(resource.iteritems()))
|
return zip(*sorted(six.iteritems(resource)))
|
||||||
else:
|
else:
|
||||||
return None
|
return None
|
||||||
|
@@ -20,6 +20,7 @@ import contextlib
|
|||||||
import cStringIO
|
import cStringIO
|
||||||
import fixtures
|
import fixtures
|
||||||
import mox
|
import mox
|
||||||
|
from six import iteritems
|
||||||
import sys
|
import sys
|
||||||
import testtools
|
import testtools
|
||||||
|
|
||||||
@@ -111,7 +112,7 @@ class MyComparator(mox.Comparator):
|
|||||||
def _com_dict(self, lhs, rhs):
|
def _com_dict(self, lhs, rhs):
|
||||||
if len(lhs) != len(rhs):
|
if len(lhs) != len(rhs):
|
||||||
return False
|
return False
|
||||||
for key, value in lhs.iteritems():
|
for key, value in iteritems(lhs):
|
||||||
if key not in rhs:
|
if key not in rhs:
|
||||||
return False
|
return False
|
||||||
rhs_value = rhs[key]
|
rhs_value = rhs[key]
|
||||||
|
Reference in New Issue
Block a user