Update hacking for Python3

The repo is Python 3 now, so update hacking to version 3.0 which
supports Python 3.

Fix problems found.

Change-Id: I82c745f5b1236844deec4538be84037a64eebeee
This commit is contained in:
Andreas Jaeger 2020-03-28 15:38:59 +01:00 committed by Andreas Jaeger
parent 6b071d397e
commit 9dede4eb2b
10 changed files with 16 additions and 12 deletions

View File

@ -53,6 +53,7 @@ def gen_ref(ver, title, names):
"signs": "=" * len(sec_title), "signs": "=" * len(sec_title),
"pkg": pkg, "name": name}) "pkg": pkg, "name": name})
gen_ref("", "Client Reference", {"client": "Client", "exc": "Exceptions"}) gen_ref("", "Client Reference", {"client": "Client", "exc": "Exceptions"})
gen_ref("v1", "Version 1 API Reference", gen_ref("v1", "Version 1 API Reference",
{"stacks": "Stacks", {"stacks": "Stacks",

View File

@ -182,9 +182,9 @@ def poll_for_events(hc, stack_name, action=None, poll_period=5, marker=None,
if action: if action:
stop_status = ('%s_FAILED' % action, '%s_COMPLETE' % action) stop_status = ('%s_FAILED' % action, '%s_COMPLETE' % action)
stop_check = lambda a: a in stop_status stop_check = lambda a: a in stop_status # noqa: E731
else: else:
stop_check = lambda a: a.endswith('_COMPLETE') or a.endswith('_FAILED') stop_check = lambda a: a.endswith('_COMPLETE') or a.endswith('_FAILED') # noqa E731
no_event_polls = 0 no_event_polls = 0
msg_template = _("\n Stack %(name)s %(status)s \n") msg_template = _("\n Stack %(name)s %(status)s \n")

View File

@ -340,7 +340,7 @@ class SessionClient(adapter.LegacyJsonAdapter):
raise exc.InvalidEndpoint(message=message) raise exc.InvalidEndpoint(message=message)
if (self.endpoint_override is not None and if (self.endpoint_override is not None and
location.lower().startswith(self.endpoint_override.lower())): location.lower().startswith(self.endpoint_override.lower())):
return location[len(self.endpoint_override):] return location[len(self.endpoint_override):]
else: else:
return location return location

View File

@ -39,6 +39,8 @@ def _construct_yaml_str(self, node):
# Override the default string handling function # Override the default string handling function
# to always return unicode objects # to always return unicode objects
return self.construct_scalar(node) return self.construct_scalar(node)
yaml_loader.add_constructor(u'tag:yaml.org,2002:str', _construct_yaml_str) yaml_loader.add_constructor(u'tag:yaml.org,2002:str', _construct_yaml_str)
# Unquoted dates like 2013-05-23 in yaml files get loaded as objects of type # Unquoted dates like 2013-05-23 in yaml files get loaded as objects of type
# datetime.data which causes problems in API layer when being processed by # datetime.data which causes problems in API layer when being processed by

View File

@ -377,8 +377,8 @@ def format_parameter_file(param_files, template_file=None,
param_file = {} param_file = {}
for key, value in params.items(): for key, value in params.items():
param_file[key] = resolve_param_get_file(value, param_file[key] = resolve_param_get_file(value,
template_base_url) template_base_url)
return param_file return param_file

View File

@ -615,5 +615,6 @@ def main(args=None):
print(encodeutils.safe_encode(six.text_type(e)), file=sys.stderr) print(encodeutils.safe_encode(six.text_type(e)), file=sys.stderr)
sys.exit(1) sys.exit(1)
if __name__ == "__main__": if __name__ == "__main__":
main() main()

View File

@ -291,9 +291,9 @@ class TempURLSignalTest(testtools.TestCase):
'[a-f0-9]{3}-[a-f0-9]{12}') '[a-f0-9]{3}-[a-f0-9]{12}')
url = deployment_utils.create_temp_url(swift_client, 'bar', 60) url = deployment_utils.create_temp_url(swift_client, 'bar', 60)
self.assertFalse(swift_client.post_account.called) self.assertFalse(swift_client.post_account.called)
regexp = ("http://fake-host.com:8080/v1/AUTH_demo/bar-%s" regexp = (r"http://fake-host.com:8080/v1/AUTH_demo/bar-%s"
"/%s\?temp_url_sig=[0-9a-f]{40}&" r"/%s\?temp_url_sig=[0-9a-f]{40}&"
"temp_url_expires=[0-9]{10}" % (uuid_pattern, uuid_pattern)) r"temp_url_expires=[0-9]{10}" % (uuid_pattern, uuid_pattern))
self.assertThat(url, matchers.MatchesRegex(regexp)) self.assertThat(url, matchers.MatchesRegex(regexp))
timeout = int(url.split('=')[-1]) timeout = int(url.split('=')[-1])

View File

@ -557,7 +557,7 @@ class ShellTestNoMox(ShellTestNoMoxBase):
template_file = os.path.join(TEST_VAR_DIR, 'minimal.template') template_file = os.path.join(TEST_VAR_DIR, 'minimal.template')
self.shell_error('stack-create -f %s stack' % template_file, self.shell_error('stack-create -f %s stack' % template_file,
'The Parameter \(key_name\) was not provided.', r'The Parameter \(key_name\) was not provided.',
exception=exc.HTTPBadRequest) exception=exc.HTTPBadRequest)
def test_event_list(self): def test_event_list(self):
@ -2437,7 +2437,7 @@ class ShellTestUserPass(ShellBase):
'{', '{',
'"output_key": "output2"', '"output_key": "output2"',
'"description": "test output 2"', '"description": "test output 2"',
'"output_value": \[', r'"output_value": \[',
'"output"', '"output"',
'"value"', '"value"',
'"2"', '"2"',

View File

@ -728,7 +728,7 @@ def do_output_list(hc, args):
utils.print_list(outputs['outputs'], fields, formatters=formatters) utils.print_list(outputs['outputs'], fields, formatters=formatters)
@utils.arg('id', metavar='<NAME or ID>', @utils.arg('id', metavar='<NAME or ID>', # noqa: C901
help=_('Name or ID of stack to query.')) help=_('Name or ID of stack to query.'))
@utils.arg('output', metavar='<OUTPUT NAME>', nargs='?', default=None, @utils.arg('output', metavar='<OUTPUT NAME>', nargs='?', default=None,
help=_('Name of an output to display.')) help=_('Name of an output to display.'))

View File

@ -3,7 +3,7 @@
# process, which may cause wedges in the gate later. # process, which may cause wedges in the gate later.
# Hacking already pins down pep8, pyflakes and flake8 # Hacking already pins down pep8, pyflakes and flake8
hacking!=0.13.0,<0.14,>=0.12.0 # Apache-2.0 hacking>=3.0,<3.1.0 # Apache-2.0
coverage!=4.4,>=4.0 # Apache-2.0 coverage!=4.4,>=4.0 # Apache-2.0
fixtures>=3.0.0 # Apache-2.0/BSD fixtures>=3.0.0 # Apache-2.0/BSD
requests-mock>=1.2.0 # Apache-2.0 requests-mock>=1.2.0 # Apache-2.0