Minor adjustments to migrate from py2 to py3

After using 2to3 tool minor changes on use of dict keys/values/items
as a list

Reference: https://python-future.org/compatible_idioms.html

story# https://storyboard.openstack.org/#!/story/2004586

Change-Id: Iceed4b890d8f5c4619f4ea8cae923051e65ab73c
Signed-off-by: Victor Rodriguez <victor.rodriguez.bahena@intel.com>
This commit is contained in:
VictorRodriguez 2019-02-04 03:10:49 -06:00
parent f4e2b2ab83
commit d9ddf09c39
4 changed files with 9 additions and 8 deletions

View File

@ -75,7 +75,7 @@ class ResourceManager(object):
json_objects = [json_response_key[item] for item in json_response_key]
resource = []
for json_object in json_objects:
data = json_object.get('usage').keys()
data = list(json_object.get('usage').keys())
for values in data:
resource.append(self.resource_class(self, values,
json_object['limits'][values],

View File

@ -244,7 +244,7 @@ class ManagerWithFind(BaseManager):
the Python side.
"""
found = []
searches = kwargs.items()
searches = list(kwargs.items())
for obj in self.list():
try:
@ -409,7 +409,7 @@ class Extension(HookableMixin):
def _parse_extension_module(self):
self.manager_class = None
for attr_name, attr_value in self.module.__dict__.items():
for attr_name, attr_value in list(self.module.__dict__.items()):
if attr_name in self.SUPPORTED_HOOKS:
self.add_hook(attr_name, attr_value)
else:
@ -446,7 +446,7 @@ class Resource(object):
def __repr__(self):
reprkeys = sorted(k
for k in self.__dict__.keys()
for k in list(self.__dict__.keys())
if k[0] != '_' and k != 'manager')
info = ", ".join("%s=%s" % (k, getattr(self, k)) for k in reprkeys)
return "<%s %s>" % (self.__class__.__name__, info)

View File

@ -363,7 +363,7 @@ class BaseClient(object):
"Must be one of: %(version_map)s") % \
{'api_name': api_name,
'version': version,
'version_map': ', '.join(version_map.keys())
'version_map': ', '.join(list(version_map.keys()))
}
raise exceptions.UnsupportedVersion(msg)

View File

@ -98,7 +98,8 @@ class BashCompletionCommand(command.Command):
commands = set()
options = set()
for option, _action in self.app.parser._option_string_actions.items():
for option, _action in list(
self.app.parser._option_string_actions.items()):
options.add(option)
for command_name, _cmd in self.app.command_manager:
@ -452,14 +453,14 @@ class DCManagerShell(app.App):
self.client_manager = ClientManager()
def _set_shell_commands(self, cmds_dict):
for k, v in cmds_dict.items():
for k, v in list(cmds_dict.items()):
self.command_manager.add_command(k, v)
def _clear_shell_commands(self):
exclude_cmds = ['help', 'complete']
cmds = self.command_manager.commands.copy()
for k, v in cmds.items():
for k, v in list(cmds.items()):
if k not in exclude_cmds:
self.command_manager.commands.pop(k)