Remove six.PY3 conditions

As we have dropped support for python2 some time ago, we should also
get rid of the six conditions for py2/py3 support.

Change-Id: Ic91f762b684917159df07158f71a6f6e199b5cf6
This commit is contained in:
Martin Kopec 2020-11-13 19:12:03 +00:00
parent b26e4565da
commit e8061e7971
2 changed files with 6 additions and 20 deletions

View File

@ -37,7 +37,6 @@ obtained by querying the cloud.
import argparse import argparse
import logging import logging
import os import os
import six
import sys import sys
import openstack import openstack
@ -133,10 +132,7 @@ def read_deployer_input(deployer_input_file, conf):
""" """
LOG.info("Adding options from deployer-input file '%s'", LOG.info("Adding options from deployer-input file '%s'",
deployer_input_file) deployer_input_file)
if six.PY3: deployer_input = configparser.ConfigParser()
deployer_input = configparser.ConfigParser()
else:
deployer_input = configparser.SafeConfigParser()
deployer_input.read(deployer_input_file) deployer_input.read(deployer_input_file)
for section in deployer_input.sections(): for section in deployer_input.sections():
# There are no deployer input options in DEFAULT # There are no deployer input options in DEFAULT

View File

@ -14,7 +14,6 @@
# under the License. # under the License.
import os import os
import six
import sys import sys
from config_tempest import constants as C from config_tempest import constants as C
@ -23,7 +22,7 @@ from six.moves import configparser
import tempest.config import tempest.config
class TempestConf(configparser.SafeConfigParser): class TempestConf(configparser.ConfigParser):
# causes the config parser to preserve case of the options # causes the config parser to preserve case of the options
optionxform = str optionxform = str
@ -35,10 +34,7 @@ class TempestConf(configparser.SafeConfigParser):
def __init__(self, write_credentials=True, **kwargs): def __init__(self, write_credentials=True, **kwargs):
self.write_credentials = write_credentials self.write_credentials = write_credentials
if six.PY3: configparser.ConfigParser.__init__(self, **kwargs)
configparser.ConfigParser.__init__(self, **kwargs)
else:
configparser.SafeConfigParser.__init__(self, **kwargs)
def get_bool_value(self, value): def get_bool_value(self, value):
"""Returns boolean value of the string value given. """Returns boolean value of the string value given.
@ -76,7 +72,7 @@ class TempestConf(configparser.SafeConfigParser):
key, section) key, section)
def set(self, section, key, value, priority=False): def set(self, section, key, value, priority=False):
"""Set value in configuration, similar to `SafeConfigParser.set` """Set value in configuration, similar to `ConfigParser.set`
Creates non-existent sections. Keeps track of options which were Creates non-existent sections. Keeps track of options which were
specified by the user and should not be normally overwritten. specified by the user and should not be normally overwritten.
@ -105,10 +101,7 @@ class TempestConf(configparser.SafeConfigParser):
if priority: if priority:
self.priority_sectionkeys.add((section, key)) self.priority_sectionkeys.add((section, key))
C.LOG.debug("Setting [%s] %s = %s", section, key, value) C.LOG.debug("Setting [%s] %s = %s", section, key, value)
if six.PY3: configparser.ConfigParser.set(self, section, key, value)
configparser.ConfigParser.set(self, section, key, value)
else:
configparser.SafeConfigParser.set(self, section, key, value)
return True return True
def write(self, out_path): def write(self, out_path):
@ -118,10 +111,7 @@ class TempestConf(configparser.SafeConfigParser):
"writing credentials is disabled.") "writing credentials is disabled.")
self.remove_values(C.ALL_CREDENTIALS_KEYS) self.remove_values(C.ALL_CREDENTIALS_KEYS)
with open(out_path, 'w') as f: with open(out_path, 'w') as f:
if six.PY3: configparser.ConfigParser.write(self, f)
configparser.ConfigParser.write(self, f)
else:
configparser.SafeConfigParser.write(self, f)
def remove_values(self, to_remove): def remove_values(self, to_remove):
"""Remove values from configuration file specified in arguments. """Remove values from configuration file specified in arguments.