Update hacking for Python3

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

Fix problems found.

Change-Id: I54f9f7c5f6ee87ee886658388541f45e23c7546d
This commit is contained in:
Andreas Jaeger 2020-03-28 15:30:28 +01:00
parent 69a14917e5
commit a9913ea35f
8 changed files with 69 additions and 68 deletions

View File

@ -385,5 +385,6 @@ def main(argv=sys.argv[1:]):
barbican_app = Barbican()
return barbican_app.run(argv)
if __name__ == '__main__': # pragma: no cover
sys.exit(main(sys.argv[1:]))

View File

@ -135,5 +135,5 @@ class CreateContainer(show.ShowOne):
raise ValueError("Must supply at least one secret.")
return dict(
(s.split('=')[0], s.split('=')[1])
for s in secrets if s.count('=') is 1
for s in secrets if s.count('=') == 1
)

View File

@ -418,8 +418,7 @@ class OrderManager(base.BaseEntityManager):
if resp_type == 'key' and (
set(response['meta'].keys()) - set(KeyOrder._validMeta)):
invalidFields = ', '.join(
map(str, set(
response['meta'].keys()) -
map(str, set(response['meta'].keys()) -
set(KeyOrder._validMeta)))
raise TypeError(
'Invalid KeyOrder meta field: [%s]' % invalidFields)

View File

@ -48,7 +48,7 @@ class ACLBehaviors(base_behaviors.BaseBehaviors):
argv.extend(['--project-access'])
else:
argv.extend(['--no-project-access'])
if operation_type and operation_type is not 'read':
if operation_type and operation_type != 'read':
argv.extend([self._args_map_list['operation_type'][index],
operation_type])

View File

@ -104,7 +104,7 @@ class BaseBehaviors(object):
"""
retval = {}
if str is not None and len(str) > 0:
table_body = re.split('\+-*\+-*\+\n', str)[2:-1]
table_body = re.split(r'\+-*\+-*\+\n', str)[2:-1]
lines = table_body[0].split('\n')
for line in lines:
if len(line) > 0:
@ -124,12 +124,12 @@ class BaseBehaviors(object):
"""
retval = []
if str is not None and len(str) > 0:
rows = re.findall('\|(.*?)\n', str)
rows = re.findall(r'\|(.*?)\n', str)
# Remove header
header_row = rows.pop(0)
key_names = re.findall('\s*(.*?)\s*\|', header_row)
key_names = re.findall(r'\s*(.*?)\s*\|', header_row)
for row in rows:
values = re.findall('\s*(.*?)\s*\|', row)
values = re.findall(r'\s*(.*?)\s*\|', row)
entry_dict = dict(zip(key_names, values))
retval.append(entry_dict)
return retval

View File

@ -1,8 +1,9 @@
# The order of packages is significant, because pip processes them in the order
# of appearance. Changing the order has an impact on the overall integration
# process, which may cause wedges in the gate later.
hacking>=3.1.0,<3.2.0 # Apache-2.0
coverage!=4.4,>=4.1 # Apache-2.0
hacking>=1.1.0,<1.2.0 # Apache-2.0
fixtures>=3.0.0 # Apache-2.0/BSD
requests-mock>=1.2.0 # Apache-2.0
mock>=2.0.0 # BSD

View File

@ -63,7 +63,7 @@ deps = {[testenv]deps}
commands = nosetests {toxinidir}/functionaltests/{posargs} -v
[flake8]
ignore = H202
ignore = H202,W504
show-source = True
exclude=.venv,.git,.tox,dist,doc,*lib/python*,*egg,build