Merge "Remove six"

This commit is contained in:
Zuul 2022-08-16 11:20:34 +00:00 committed by Gerrit Code Review
commit 01aa850679
9 changed files with 23 additions and 32 deletions

View File

@ -13,7 +13,6 @@
# limitations under the License. # limitations under the License.
import os import os
import six
import stat import stat
import uuid import uuid
import time import time
@ -76,7 +75,7 @@ class SshTarballTransferMixin(object):
dest = self.recipe_dir[len(self.resource_dir):].lstrip('/') dest = self.recipe_dir[len(self.resource_dir):].lstrip('/')
else: else:
dest = '' dest = ''
for marker, recipes in six.iteritems(self._recipes): for marker, recipes in self._recipes.items():
for path in recipes: for path in recipes:
_dest = os.path.join(dest, os.path.basename(path)) _dest = os.path.join(dest, os.path.basename(path))
pack.add(path, arcname=_dest) pack.add(path, arcname=_dest)
@ -279,7 +278,7 @@ class Drone(object):
logger = logging.getLogger() logger = logging.getLogger()
skip = skip or [] skip = skip or []
lastmarker = None lastmarker = None
for mark, recipelist in six.iteritems(self._recipes): for mark, recipelist in self._recipes.items():
if marker and marker != mark: if marker and marker != mark:
logger.debug('Skipping marker %s for node %s.' % logger.debug('Skipping marker %s for node %s.' %
(mark, self.node)) (mark, self.node))

View File

@ -17,7 +17,6 @@ Container set for groups and parameters
""" """
from ..utils.datastructures import SortedDict from ..utils.datastructures import SortedDict
import six
class Parameter(object): class Parameter(object):
@ -32,7 +31,7 @@ class Parameter(object):
defaults = {}.fromkeys(self.allowed_keys) defaults = {}.fromkeys(self.allowed_keys)
defaults.update(attributes) defaults.update(attributes)
for key, value in six.iteritems(defaults): for key, value in defaults.items():
if key not in self.allowed_keys: if key not in self.allowed_keys:
raise KeyError('Given attribute %s is not allowed' % key) raise KeyError('Given attribute %s is not allowed' % key)
self.__dict__[key] = value self.__dict__[key] = value

View File

@ -11,17 +11,15 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
from six.moves import configparser import configparser
from six.moves import StringIO
from functools import cmp_to_key
import copy import copy
import datetime import datetime
from functools import cmp_to_key
import getpass import getpass
import logging import logging
from io import StringIO
import os import os
import re import re
import six
import sys import sys
import traceback import traceback
import types import types
@ -243,19 +241,19 @@ def mask(input):
output = copy.deepcopy(input) output = copy.deepcopy(input)
if isinstance(input, dict): if isinstance(input, dict):
for key in input: for key in input:
if isinstance(input[key], six.string_types): if isinstance(input[key], str):
output[key] = utils.mask_string(input[key], output[key] = utils.mask_string(input[key],
masked_value_set) masked_value_set)
if isinstance(input, list): if isinstance(input, list):
for item in input: for item in input:
org = item org = item
orgIndex = input.index(org) orgIndex = input.index(org)
if isinstance(item, six.string_types): if isinstance(item, str):
item = utils.mask_string(item, masked_value_set) item = utils.mask_string(item, masked_value_set)
if item != org: if item != org:
output.remove(org) output.remove(org)
output.insert(orgIndex, item) output.insert(orgIndex, item)
if isinstance(input, six.string_types): if isinstance(input, str):
output = utils.mask_string(input, masked_value_set) output = utils.mask_string(input, masked_value_set)
return output return output
@ -332,7 +330,7 @@ def _handleGroupCondition(config, conditionName, conditionValue):
# If the condition is a string - just read it to global conf # If the condition is a string - just read it to global conf
# We assume that if we get a string as a member it is the name of a member of conf_params # We assume that if we get a string as a member it is the name of a member of conf_params
elif isinstance(conditionName, six.string_types): elif isinstance(conditionName, str):
conditionValue = _loadParamFromFile(config, "general", conditionName) conditionValue = _loadParamFromFile(config, "general", conditionName)
else: else:
# Any other type is invalid # Any other type is invalid
@ -548,7 +546,7 @@ def _getConditionValue(matchMember):
returnValue = False returnValue = False
if isinstance(matchMember, types.FunctionType): if isinstance(matchMember, types.FunctionType):
returnValue = matchMember(controller.CONF) returnValue = matchMember(controller.CONF)
elif isinstance(matchMember, six.string_types): elif isinstance(matchMember, str):
# we assume that if we get a string as a member it is the name # we assume that if we get a string as a member it is the name
# of a member of conf_params # of a member of conf_params
if matchMember not in controller.CONF: if matchMember not in controller.CONF:

View File

@ -14,7 +14,6 @@
import re import re
import os import os
import six
import logging import logging
import subprocess import subprocess
@ -38,7 +37,7 @@ def execute(cmd, workdir=None, can_fail=True, mask_list=None,
mask_list = mask_list or [] mask_list = mask_list or []
repl_list = [("'", "'\\''")] repl_list = [("'", "'\\''")]
if not isinstance(cmd, six.string_types): if not isinstance(cmd, str):
import pipes import pipes
masked = ' '.join((pipes.quote(i) for i in cmd)) masked = ' '.join((pipes.quote(i) for i in cmd))
else: else:
@ -55,9 +54,9 @@ def execute(cmd, workdir=None, can_fail=True, mask_list=None,
env=environ) env=environ)
out, err = proc.communicate() out, err = proc.communicate()
if not isinstance(out, six.text_type): if not isinstance(out, str):
out = out.decode('utf-8') out = out.decode('utf-8')
if not isinstance(err, six.text_type): if not isinstance(err, str):
err = err.decode('utf-8') err = err.decode('utf-8')
masked_out = mask_string(out, mask_list, repl_list) masked_out = mask_string(out, mask_list, repl_list)
masked_err = mask_string(err, mask_list, repl_list) masked_err = mask_string(err, mask_list, repl_list)
@ -115,9 +114,9 @@ class ScriptRunner(object):
script = "function t(){ exit $? ; } \n trap t ERR \n %s" % script script = "function t(){ exit $? ; } \n trap t ERR \n %s" % script
out, err = obj.communicate(script.encode('utf-8')) out, err = obj.communicate(script.encode('utf-8'))
if not isinstance(out, six.text_type): if not isinstance(out, str):
out = out.decode('utf-8') out = out.decode('utf-8')
if not isinstance(err, six.text_type): if not isinstance(err, str):
err = err.decode('utf-8') err = err.decode('utf-8')
masked_out = mask_string(out, mask_list, repl_list) masked_out = mask_string(out, mask_list, repl_list)
masked_err = mask_string(err, mask_list, repl_list) masked_err = mask_string(err, mask_list, repl_list)

View File

@ -15,11 +15,10 @@
import grp import grp
import os import os
import pwd import pwd
import six
def host_iter(config): def host_iter(config):
for key, value in six.iteritems(config): for key, value in config.items():
if key.endswith("_HOST"): if key.endswith("_HOST"):
host = value.split('/')[0] host = value.split('/')[0]
if host: if host:

View File

@ -14,7 +14,6 @@
from functools import cmp_to_key from functools import cmp_to_key
import re import re
import six
STR_MASK = '*' * 8 STR_MASK = '*' * 8
@ -45,7 +44,7 @@ def mask_string(unmasked, mask_list=None, replace_list=None):
mask_list = mask_list or [] mask_list = mask_list or []
replace_list = replace_list or [] replace_list = replace_list or []
if isinstance(unmasked, six.text_type): if isinstance(unmasked, str):
masked = unmasked.encode('utf-8') masked = unmasked.encode('utf-8')
else: else:
masked = unmasked masked = unmasked

View File

@ -5,4 +5,3 @@ docutils>=0.11
pyOpenSSL>=16.2.0 pyOpenSSL>=16.2.0
netifaces netifaces
distro distro
six

View File

@ -15,7 +15,7 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
import six import io
import sys import sys
from unittest import TestCase from unittest import TestCase
@ -29,7 +29,7 @@ class StepTestCase(PackstackTestCaseMixin, TestCase):
def setUp(self): def setUp(self):
super(StepTestCase, self).setUp() super(StepTestCase, self).setUp()
self._stdout = sys.stdout self._stdout = sys.stdout
sys.stdout = six.StringIO() sys.stdout = io.StringIO()
def tearDown(self): def tearDown(self):
super(StepTestCase, self).tearDown() super(StepTestCase, self).tearDown()
@ -57,7 +57,7 @@ class SequenceTestCase(PackstackTestCaseMixin, TestCase):
def setUp(self): def setUp(self):
super(SequenceTestCase, self).setUp() super(SequenceTestCase, self).setUp()
self._stdout = sys.stdout self._stdout = sys.stdout
sys.stdout = six.StringIO() sys.stdout = io.StringIO()
self.steps = [{'name': '1', 'function': lambda x, y: True, self.steps = [{'name': '1', 'function': lambda x, y: True,
'title': 'Step 1'}, 'title': 'Step 1'},

View File

@ -19,7 +19,6 @@
Test cases for packstack.installer.core.parameters module. Test cases for packstack.installer.core.parameters module.
""" """
import six
from unittest import TestCase from unittest import TestCase
from ..test_base import PackstackTestCaseMixin from ..test_base import PackstackTestCaseMixin
@ -50,7 +49,7 @@ class ParameterTestCase(PackstackTestCaseMixin, TestCase):
initialization initialization
""" """
param = Parameter(self.data) param = Parameter(self.data)
for key, value in six.iteritems(self.data): for key, value in self.data.items():
self.assertEqual(getattr(param, key), value) self.assertEqual(getattr(param, key), value)
def test_default_attribute(self): def test_default_attribute(self):
@ -81,7 +80,7 @@ class GroupTestCase(PackstackTestCaseMixin, TestCase):
Test packstack.installer.core.parameters.Group initialization Test packstack.installer.core.parameters.Group initialization
""" """
group = Group(attributes=self.attrs, parameters=self.params) group = Group(attributes=self.attrs, parameters=self.params)
for key, value in six.iteritems(self.attrs): for key, value in self.attrs.items():
self.assertEqual(getattr(group, key), value) self.assertEqual(getattr(group, key), value)
for param in self.params: for param in self.params:
self.assertIn(param['CONF_NAME'], group.parameters) self.assertIn(param['CONF_NAME'], group.parameters)