Python2/3 compatibility fixes

Results from running 2to3 tooling.

Change-Id: Ic30508fad422cca8d855830e7ea28dba10d7110f
This commit is contained in:
Thomas Bachman 2022-01-13 17:15:25 +00:00
parent 150c9b0d75
commit d90a042758
4 changed files with 14 additions and 10 deletions

View File

@ -599,11 +599,12 @@ class CreateL3Policy(neutronV20.CreateCommand):
external_segment_id = neutronV20.find_resourceid_by_name_or_id(
self.get_client(), 'external_segment',
list(external_segment.keys())[0])
ipaddrs = next(iter(external_segment.values()))
ipaddrs = next(iter(list(external_segment.values())))
if ipaddrs == "":
ipaddrs = []
else:
ipaddrs = next(iter(external_segment.values())).split(':')
ipaddrs = next(
iter(list(external_segment.values()))).split(':')
external_segments_dict[external_segment_id] = ipaddrs
body[self.resource]['external_segments'] = external_segments_dict
@ -682,11 +683,12 @@ class UpdateL3Policy(neutronV20.UpdateCommand):
external_segment_id = neutronV20.find_resourceid_by_name_or_id(
self.get_client(), 'external_segment',
list(external_segment.keys())[0])
ipaddrs = next(iter(external_segment.values()))
ipaddrs = next(iter(list(external_segment.values())))
if ipaddrs == "":
ipaddrs = []
else:
ipaddrs = next(iter(external_segment.values())).split(':')
ipaddrs = next(
iter(list(external_segment.values()))).split(':')
external_segments_dict[external_segment_id] = ipaddrs
body[self.resource]['external_segments'] = external_segments_dict

View File

@ -105,7 +105,7 @@ class Purge(n_purge.Purge):
deleted, failed, failures = self._purge_resources(neutron_client,
resource_types,
resources)
print('\n%s' % self._build_message(deleted, failed, failures))
print(('\n%s' % self._build_message(deleted, failed, failures)))
# clean up Neutron resources also
super(Purge, self).take_action(parsed_args)

View File

@ -15,7 +15,6 @@
Command-line interface to the GBP APIs
"""
from __future__ import print_function
import argparse
import logging
@ -331,7 +330,7 @@ class GBPShell(app.App):
version=VERSION,
command_manager=commandmanager.CommandManager('gbp.cli'), )
self.commands = COMMANDS
for k, v in self.commands[apiversion].items():
for k, v in list(self.commands[apiversion].items()):
self.command_manager.add_command(k, v)
# This is instantiated in initialize_app() only when using
@ -610,14 +609,16 @@ class GBPShell(app.App):
"""Prints all of the commands and options for bash-completion."""
commands = set()
options = set()
for option, _action in self.parser._option_string_actions.items():
for option, _action in list(
self.parser._option_string_actions.items()):
options.add(option)
for command_name, command in self.command_manager:
commands.add(command_name)
cmd_factory = command.load()
cmd = cmd_factory(self, None)
cmd_parser = cmd.get_parser('')
for option, _action in cmd_parser._option_string_actions.items():
for option, _action in list(
cmd_parser._option_string_actions.items()):
options.add(option)
print(' '.join(commands | options))

View File

@ -177,7 +177,8 @@ class CLITestV20ExceptionHandler(CLITestV20Base):
pass
def test_exception_handler_v20_unknown_error_to_per_code_exception(self):
for status_code, client_exc in exceptions.HTTP_EXCEPTION_MAP.items():
for status_code, client_exc in list(
exceptions.HTTP_EXCEPTION_MAP.items()):
error_msg = 'Unknown error'
error_detail = 'This is detail'
self._test_exception_handler_v20(