Remove all usage of six library

Convert all code to not require six library and instead
use python 3.x logic.

Change-Id: Ifbf5a9beb79f46940bf4e7647a0b6fda99a187fc
This commit is contained in:
jacky06 2020-05-08 00:46:52 +08:00
parent fed6cd7716
commit 880c952e49
19 changed files with 28 additions and 43 deletions

View File

@ -99,7 +99,6 @@ requestsexceptions==1.2.0
rfc3986==0.3.1 rfc3986==0.3.1
Routes==2.3.1 Routes==2.3.1
simplejson==3.5.1 simplejson==3.5.1
six==1.10.0
snowballstemmer==1.2.1 snowballstemmer==1.2.1
Sphinx==1.8.0 Sphinx==1.8.0
sphinxcontrib-websupport==1.0.1 sphinxcontrib-websupport==1.0.1

View File

@ -13,13 +13,13 @@
# limitations under the License. # limitations under the License.
import copy import copy
import six import urllib
from oslo_serialization import jsonutils from oslo_serialization import jsonutils
from keystoneauth1 import exceptions from keystoneauth1 import exceptions
urlparse = six.moves.urllib.parse urlparse = urllib.parse
class Resource(object): class Resource(object):

View File

@ -14,7 +14,6 @@
# limitations under the License. # limitations under the License.
import copy import copy
import six
from oslo_utils import importutils from oslo_utils import importutils
@ -48,7 +47,7 @@ class Client(object):
mistral_url = req.get('mistral_url') mistral_url = req.get('mistral_url')
profile = req.get('profile') profile = req.get('profile')
if mistral_url and not isinstance(mistral_url, six.string_types): if mistral_url and not isinstance(mistral_url, str):
raise RuntimeError('Mistral url should be a string.') raise RuntimeError('Mistral url should be a string.')
# If auth url was provided then we perform an authentication, otherwise # If auth url was provided then we perform an authentication, otherwise

View File

@ -12,7 +12,6 @@
# 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.
import six
from oslo_serialization import jsonutils from oslo_serialization import jsonutils
@ -26,7 +25,7 @@ class Environment(base.Resource):
def _set_attributes(self): def _set_attributes(self):
"""Override loading of the "variables" attribute from text to dict.""" """Override loading of the "variables" attribute from text to dict."""
for k, v in self._data.items(): for k, v in self._data.items():
if k == 'variables' and isinstance(v, six.string_types): if k == 'variables' and isinstance(v, str):
v = jsonutils.loads(v) v = jsonutils.loads(v)
try: try:

View File

@ -14,7 +14,6 @@
# 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.
import six
from oslo_serialization import jsonutils from oslo_serialization import jsonutils
from oslo_utils import uuidutils from oslo_utils import uuidutils
@ -51,7 +50,7 @@ class ExecutionManager(base.ResourceManager):
data.update({'workflow_namespace': namespace}) data.update({'workflow_namespace': namespace})
if workflow_input: if workflow_input:
if isinstance(workflow_input, six.string_types): if isinstance(workflow_input, str):
data.update({'input': workflow_input}) data.update({'input': workflow_input})
else: else:
data.update({'input': jsonutils.dumps(workflow_input)}) data.update({'input': jsonutils.dumps(workflow_input)})

View File

@ -14,7 +14,6 @@
import abc import abc
import six
from stevedore import driver from stevedore import driver
@ -28,8 +27,7 @@ def get_auth_handler(auth_type):
return mgr.driver return mgr.driver
@six.add_metaclass(abc.ABCMeta) class AuthHandler(metaclass=abc.ABCMeta):
class AuthHandler(object):
"""Abstract base class for an authentication plugin.""" """Abstract base class for an authentication plugin."""
@abc.abstractmethod @abc.abstractmethod

View File

@ -15,9 +15,9 @@
import logging import logging
import os import os
import pprint import pprint
import urllib
import requests import requests
from six.moves import urllib
from mistralclient import auth from mistralclient import auth

View File

@ -19,14 +19,12 @@ import datetime as dt
import textwrap import textwrap
from osc_lib.command import command from osc_lib.command import command
import six
DEFAULT_LIMIT = 100 DEFAULT_LIMIT = 100
@six.add_metaclass(abc.ABCMeta) class MistralFormatter(metaclass=abc.ABCMeta):
class MistralFormatter(object):
COLUMNS = [] COLUMNS = []
@classmethod @classmethod
@ -51,8 +49,7 @@ class MistralFormatter(object):
pass pass
@six.add_metaclass(abc.ABCMeta) class MistralLister(command.Lister, metaclass=abc.ABCMeta):
class MistralLister(command.Lister):
@abc.abstractmethod @abc.abstractmethod
def _get_format_function(self): def _get_format_function(self):
raise NotImplementedError raise NotImplementedError
@ -125,8 +122,7 @@ class MistralLister(command.Lister):
return f() return f()
@six.add_metaclass(abc.ABCMeta) class MistralExecutionLister(MistralLister, metaclass=abc.ABCMeta):
class MistralExecutionLister(MistralLister):
def get_parser(self, parsed_args): def get_parser(self, parsed_args):
parser = super(MistralExecutionLister, self).get_parser(parsed_args) parser = super(MistralExecutionLister, self).get_parser(parsed_args)
parser.set_defaults(limit=DEFAULT_LIMIT) parser.set_defaults(limit=DEFAULT_LIMIT)

View File

@ -12,11 +12,11 @@
# 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.
import io
import os import os
import sys import sys
from oslotest import base from oslotest import base
import six
from mistralclient import shell from mistralclient import shell
@ -29,8 +29,8 @@ class BaseShellTests(base.BaseTestCase):
_old_env, os.environ = os.environ, clean_env.copy() _old_env, os.environ = os.environ, clean_env.copy()
try: try:
sys.stdout = six.moves.cStringIO() sys.stdout = io.StringIO()
sys.stderr = six.moves.cStringIO() sys.stderr = io.StringIO()
_shell = shell.MistralShell() _shell = shell.MistralShell()
_shell.run(argstr.split()) _shell.run(argstr.split())
except SystemExit: except SystemExit:

View File

@ -16,7 +16,7 @@ import base64
import copy import copy
from unittest import mock from unittest import mock
from six.moves.urllib import parse as urlparse from urllib import parse as urlparse
from oslo_utils import uuidutils from oslo_utils import uuidutils
from osprofiler import _utils as osprofiler_utils from osprofiler import _utils as osprofiler_utils

View File

@ -15,8 +15,8 @@
import os.path import os.path
import pkg_resources as pkg import pkg_resources as pkg
from six.moves.urllib import parse from urllib import parse
from six.moves.urllib import request from urllib import request
from mistralclient.api import base as api_base from mistralclient.api import base as api_base
from mistralclient.api.v2 import actions from mistralclient.api.v2 import actions

View File

@ -15,12 +15,10 @@
# #
import copy import copy
import io
import sys import sys
from unittest import mock from unittest import mock
import six
from oslo_serialization import jsonutils from oslo_serialization import jsonutils
from mistralclient.api.v2 import action_executions as action_ex from mistralclient.api.v2 import action_executions as action_ex
@ -162,7 +160,7 @@ class TestCLIActionExecutions(base.BaseCommandTest):
# Redirect the stderr so it doesn't show during tox # Redirect the stderr so it doesn't show during tox
_stderr = sys.stderr _stderr = sys.stderr
sys.stderr = six.StringIO() sys.stderr = io.StringIO()
for state in states: for state in states:
self.assertRaises( self.assertRaises(

View File

@ -17,7 +17,6 @@
from unittest import mock from unittest import mock
import six
from mistralclient.api.v2 import actions from mistralclient.api.v2 import actions
from mistralclient.commands.v2 import actions as action_cmd from mistralclient.commands.v2 import actions as action_cmd
@ -90,7 +89,7 @@ class TestCLIActionsV2(base.BaseCommandTest):
def test_create_long_input(self, mock_open): def test_create_long_input(self, mock_open):
action_long_input_dict = ACTION_DICT.copy() action_long_input_dict = ACTION_DICT.copy()
long_input = ', '.join( long_input = ', '.join(
['var%s' % i for i in six.moves.xrange(10)] ['var%s' % i for i in range(10)]
) )
action_long_input_dict['input'] = long_input action_long_input_dict['input'] = long_input
workflow_long_input = actions.Action( workflow_long_input = actions.Action(

View File

@ -15,7 +15,6 @@
from unittest import mock from unittest import mock
import six
from mistralclient.api.v2 import workflows from mistralclient.api.v2 import workflows
from mistralclient.commands.v2 import base as cmd_base from mistralclient.commands.v2 import base as cmd_base
@ -90,7 +89,7 @@ class TestCLIWorkflowsV2(base.BaseCommandTest):
def test_create_long_input(self, mock_open): def test_create_long_input(self, mock_open):
wf_long_input_dict = WORKFLOW_DICT.copy() wf_long_input_dict = WORKFLOW_DICT.copy()
long_input = ', '.join( long_input = ', '.join(
['var%s' % i for i in six.moves.xrange(10)] ['var%s' % i for i in range(10)]
) )
wf_long_input_dict['input'] = long_input wf_long_input_dict['input'] = long_input
workflow_long_input = workflows.Workflow(mock, wf_long_input_dict) workflow_long_input = workflows.Workflow(mock, wf_long_input_dict)

View File

@ -19,8 +19,8 @@ import os.path
from oslo_serialization import jsonutils from oslo_serialization import jsonutils
import pkg_resources as pkg import pkg_resources as pkg
from six.moves.urllib import parse from urllib import parse
from six.moves.urllib import request from urllib import request
from mistralclient.api import base as api_base from mistralclient.api import base as api_base
from mistralclient.api.v2 import environments from mistralclient.api.v2 import environments

View File

@ -15,8 +15,8 @@
import os.path import os.path
import pkg_resources as pkg import pkg_resources as pkg
from six.moves.urllib import parse from urllib import parse
from six.moves.urllib import request from urllib import request
from mistralclient.api import base as api_base from mistralclient.api import base as api_base
from mistralclient.api.v2 import workbooks from mistralclient.api.v2 import workbooks

View File

@ -14,8 +14,8 @@
import os.path import os.path
import pkg_resources as pkg import pkg_resources as pkg
from six.moves.urllib import parse from urllib import parse
from six.moves.urllib import request from urllib import request
from mistralclient.api.v2 import workflows from mistralclient.api.v2 import workflows
from mistralclient.tests.unit.v2 import base from mistralclient.tests.unit.v2 import base

View File

@ -18,8 +18,8 @@ import yaml
from oslo_serialization import jsonutils from oslo_serialization import jsonutils
from six.moves.urllib import parse from urllib import parse
from six.moves.urllib import request from urllib import request
from mistralclient import exceptions from mistralclient import exceptions

View File

@ -10,5 +10,4 @@ pbr!=2.1.0,>=2.0.0 # Apache-2.0
keystoneauth1>=3.4.0 # Apache-2.0 keystoneauth1>=3.4.0 # Apache-2.0
PyYAML>=3.12 # MIT PyYAML>=3.12 # MIT
requests>=2.14.2 # Apache-2.0 requests>=2.14.2 # Apache-2.0
six>=1.10.0 # MIT
stevedore>=1.20.0 # Apache-2.0 stevedore>=1.20.0 # Apache-2.0