From da1faab51b4942914d499cffe6d5683e2c874493 Mon Sep 17 00:00:00 2001 From: Tony Breeds Date: Thu, 6 Sep 2018 14:33:53 +1000 Subject: [PATCH] Make the owners code work with python3 When generating electorate rolls under python3 we get the following: Traceback (most recent call last): File ".tox/venv/bin/generate-rolls", line 10, in sys.exit(main()) File "/home/tony/projects/openstack/openstack/election/openstack_election/cmds/generate_rolls.py", line 84, in main owners.main(options) File "/home/tony/projects/openstack/openstack/election/openstack_election/owners.py", line 532, in main normalized_project = normalize_project(project) File "/home/tony/projects/openstack/openstack/election/openstack_election/owners.py", line 60, in normalize_project return project.translate(maketrans(' -', '__')).lower() TypeError: a bytes-like object is required, not 'str' Remove the python2 compat code and just use str.maketrans() always. Change-Id: I12e351886d3e431144eeeb3a0efbd94dd0552946 --- openstack_election/owners.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/openstack_election/owners.py b/openstack_election/owners.py index ca493b3c..ad646b97 100644 --- a/openstack_election/owners.py +++ b/openstack_election/owners.py @@ -27,11 +27,6 @@ import yaml from openstack_election import utils -try: - from string import maketrans -except ImportError: # Python3 - maketrans = bytes.maketrans - def dumper(data, stream): """Convenience wrapper to consistently set YAML formatting""" @@ -57,7 +52,7 @@ def normalize_project(project): Replace spaces and hyphens with underscores in project teams and then lower-case them, for more convenient filenames """ - return project.translate(maketrans(' -', '__')).lower() + return project.translate(str.maketrans(' -', '__')).lower() def date_merged(change, after=None, before=None):