Merge "Remove all usage of six library"

This commit is contained in:
Zuul 2020-06-02 09:03:54 +00:00 committed by Gerrit Code Review
commit 3b5ceb2386
13 changed files with 23 additions and 31 deletions

View File

@ -82,7 +82,6 @@ requestsexceptions==1.2.0
rfc3986==0.3.1 rfc3986==0.3.1
setuptools==21.0.0 setuptools==21.0.0
simplejson==3.5.1 simplejson==3.5.1
six==1.10.0
snowballstemmer==1.2.1 snowballstemmer==1.2.1
stestr==2.0.0 stestr==2.0.0
stevedore==1.20.0 stevedore==1.20.0

View File

@ -14,4 +14,3 @@ oslo.utils>=3.33.0 # Apache-2.0
python-heatclient>=1.10.0 # Apache-2.0 python-heatclient>=1.10.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

View File

@ -15,7 +15,6 @@ from keystoneauth1.exceptions import http as kae_http
from openstack import exceptions as sdkexc from openstack import exceptions as sdkexc
from oslo_serialization import jsonutils from oslo_serialization import jsonutils
from requests import exceptions as reqexc from requests import exceptions as reqexc
import six
from senlinclient.common.i18n import _ from senlinclient.common.i18n import _
@ -272,7 +271,7 @@ def parse_exception(exc):
} }
} }
elif isinstance(exc, six.string_types): elif isinstance(exc, str):
record = jsonutils.loads(exc) record = jsonutils.loads(exc)
# some exception from keystoneauth1 is not shaped by SDK # some exception from keystoneauth1 is not shaped by SDK
elif isinstance(exc, kae_http.HttpError): elif isinstance(exc, kae_http.HttpError):

View File

@ -17,7 +17,6 @@ from heatclient.common import template_utils
from oslo_serialization import jsonutils from oslo_serialization import jsonutils
from oslo_utils import importutils from oslo_utils import importutils
import prettytable import prettytable
import six
import yaml import yaml
from senlinclient.common import exc from senlinclient.common import exc
@ -42,7 +41,7 @@ def format_nested_dict(d, fields, column_names):
keys = sorted(d.keys()) keys = sorted(d.keys())
for field in keys: for field in keys:
value = d[field] value = d[field]
if not isinstance(value, six.string_types): if not isinstance(value, str):
value = jsonutils.dumps(value, indent=2, ensure_ascii=False) value = jsonutils.dumps(value, indent=2, ensure_ascii=False)
if value is None: if value is None:
value = '-' value = '-'
@ -122,7 +121,7 @@ def get_spec_content(filename):
data = yaml.safe_load(f) data = yaml.safe_load(f)
except Exception as ex: except Exception as ex:
raise exc.CommandError(_('The specified file is not a valid ' raise exc.CommandError(_('The specified file is not a valid '
'YAML file: %s') % six.text_type(ex)) 'YAML file: %s') % str(ex))
return data return data
@ -133,7 +132,7 @@ def process_stack_spec(spec):
tmplfile = spec.get('template', None) tmplfile = spec.get('template', None)
except AttributeError as ex: except AttributeError as ex:
raise exc.FileFormatError(_('The specified file is not a valid ' raise exc.FileFormatError(_('The specified file is not a valid '
'YAML file: %s') % six.text_type(ex)) 'YAML file: %s') % str(ex))
if not tmplfile: if not tmplfile:
raise exc.FileFormatError(_('No template found in the given ' raise exc.FileFormatError(_('No template found in the given '
'spec file')) 'spec file'))

View File

@ -11,7 +11,6 @@
# under the License. # under the License.
import os import os
import six
import time import time
from oslo_utils import uuidutils from oslo_utils import uuidutils
@ -46,7 +45,7 @@ class OpenStackClientTestBase(base.ClientTestBase):
obj = {} obj = {}
items = self.parser.listing(output) items = self.parser.listing(output)
for item in items: for item in items:
obj[item['Field']] = six.text_type(item['Value']) obj[item['Field']] = str(item['Value'])
return dict((self._key_name(k), v) for k, v in obj.items()) return dict((self._key_name(k), v) for k, v in obj.items())
def _key_name(self, key): def _key_name(self, key):

View File

@ -13,7 +13,6 @@
from heatclient.common import template_utils from heatclient.common import template_utils
from unittest import mock from unittest import mock
import six
import testtools import testtools
from senlinclient.common import exc from senlinclient.common import exc
@ -49,7 +48,7 @@ class UtilTest(testtools.TestCase):
params) params)
msg = _('Malformed parameter(status:ACTIVE). ' msg = _('Malformed parameter(status:ACTIVE). '
'Use the key=value format.') 'Use the key=value format.')
self.assertEqual(msg, six.text_type(ex)) self.assertEqual(msg, str(ex))
@mock.patch.object(template_utils, @mock.patch.object(template_utils,
'process_multiple_environments_and_files') 'process_multiple_environments_and_files')

View File

@ -11,12 +11,12 @@
# under the License. # under the License.
import copy import copy
import io
import subprocess import subprocess
from unittest import mock from unittest import mock
from openstack import exceptions as sdk_exc from openstack import exceptions as sdk_exc
from osc_lib import exceptions as exc from osc_lib import exceptions as exc
import six
from senlinclient.tests.unit.v1 import fakes from senlinclient.tests.unit.v1 import fakes
from senlinclient.v1 import cluster as osc_cluster from senlinclient.v1 import cluster as osc_cluster
@ -393,7 +393,7 @@ class TestClusterDelete(TestCluster):
mock.call('cluster2', False, False)] mock.call('cluster2', False, False)]
) )
@mock.patch('sys.stdin', spec=six.StringIO) @mock.patch('sys.stdin', spec=io.StringIO)
def test_cluster_delete_prompt_yes(self, mock_stdin): def test_cluster_delete_prompt_yes(self, mock_stdin):
arglist = ['my_cluster'] arglist = ['my_cluster']
mock_stdin.isatty.return_value = True mock_stdin.isatty.return_value = True
@ -406,7 +406,7 @@ class TestClusterDelete(TestCluster):
self.mock_client.delete_cluster.assert_called_with( self.mock_client.delete_cluster.assert_called_with(
'my_cluster', False, False) 'my_cluster', False, False)
@mock.patch('sys.stdin', spec=six.StringIO) @mock.patch('sys.stdin', spec=io.StringIO)
def test_cluster_delete_prompt_no(self, mock_stdin): def test_cluster_delete_prompt_no(self, mock_stdin):
arglist = ['my_cluster'] arglist = ['my_cluster']
mock_stdin.isatty.return_value = True mock_stdin.isatty.return_value = True

View File

@ -11,11 +11,11 @@
# under the License. # under the License.
import copy import copy
import io
from unittest import mock from unittest import mock
from openstack import exceptions as sdk_exc from openstack import exceptions as sdk_exc
from osc_lib import exceptions as exc from osc_lib import exceptions as exc
import six
from senlinclient.tests.unit.v1 import fakes from senlinclient.tests.unit.v1 import fakes
from senlinclient.v1 import node as osc_node from senlinclient.v1 import node as osc_node
@ -394,7 +394,7 @@ class TestNodeDelete(TestNode):
mock.call('node2', False, False)] mock.call('node2', False, False)]
) )
@mock.patch('sys.stdin', spec=six.StringIO) @mock.patch('sys.stdin', spec=io.StringIO)
def test_node_delete_prompt_yes(self, mock_stdin): def test_node_delete_prompt_yes(self, mock_stdin):
arglist = ['my_node'] arglist = ['my_node']
mock_stdin.isatty.return_value = True mock_stdin.isatty.return_value = True
@ -407,7 +407,7 @@ class TestNodeDelete(TestNode):
self.mock_client.delete_node.assert_called_with( self.mock_client.delete_node.assert_called_with(
'my_node', False, False) 'my_node', False, False)
@mock.patch('sys.stdin', spec=six.StringIO) @mock.patch('sys.stdin', spec=io.StringIO)
def test_node_delete_prompt_no(self, mock_stdin): def test_node_delete_prompt_no(self, mock_stdin):
arglist = ['my_node'] arglist = ['my_node']
mock_stdin.isatty.return_value = True mock_stdin.isatty.return_value = True

View File

@ -11,11 +11,11 @@
# under the License. # under the License.
import copy import copy
import io
from unittest import mock from unittest import mock
from openstack import exceptions as sdk_exc from openstack import exceptions as sdk_exc
from osc_lib import exceptions as exc from osc_lib import exceptions as exc
import six
from senlinclient.tests.unit.v1 import fakes from senlinclient.tests.unit.v1 import fakes
from senlinclient.v1 import policy as osc_policy from senlinclient.v1 import policy as osc_policy
@ -353,7 +353,7 @@ class TestPolicyDelete(TestPolicy):
self.assertEqual('Failed to delete 1 of the 2 specified policy(s).', self.assertEqual('Failed to delete 1 of the 2 specified policy(s).',
str(error)) str(error))
@mock.patch('sys.stdin', spec=six.StringIO) @mock.patch('sys.stdin', spec=io.StringIO)
def test_policy_delete_prompt_yes(self, mock_stdin): def test_policy_delete_prompt_yes(self, mock_stdin):
arglist = ['my_policy'] arglist = ['my_policy']
mock_stdin.isatty.return_value = True mock_stdin.isatty.return_value = True
@ -366,7 +366,7 @@ class TestPolicyDelete(TestPolicy):
self.mock_client.delete_policy.assert_called_with('my_policy', self.mock_client.delete_policy.assert_called_with('my_policy',
False) False)
@mock.patch('sys.stdin', spec=six.StringIO) @mock.patch('sys.stdin', spec=io.StringIO)
def test_policy_delete_prompt_no(self, mock_stdin): def test_policy_delete_prompt_no(self, mock_stdin):
arglist = ['my_policy'] arglist = ['my_policy']
mock_stdin.isatty.return_value = True mock_stdin.isatty.return_value = True

View File

@ -11,12 +11,12 @@
# under the License. # under the License.
import copy import copy
import io
from unittest import mock from unittest import mock
from openstack import exceptions as sdk_exc from openstack import exceptions as sdk_exc
from osc_lib import exceptions as exc from osc_lib import exceptions as exc
from osc_lib import utils from osc_lib import utils
import six
from senlinclient.tests.unit.v1 import fakes from senlinclient.tests.unit.v1 import fakes
from senlinclient.v1 import profile as osc_profile from senlinclient.v1 import profile as osc_profile
@ -264,7 +264,7 @@ class TestProfileDelete(TestProfile):
self.assertEqual('Failed to delete 1 of the 2 specified profile(s).', self.assertEqual('Failed to delete 1 of the 2 specified profile(s).',
str(error)) str(error))
@mock.patch('sys.stdin', spec=six.StringIO) @mock.patch('sys.stdin', spec=io.StringIO)
def test_profile_delete_prompt_yes(self, mock_stdin): def test_profile_delete_prompt_yes(self, mock_stdin):
arglist = ['my_profile'] arglist = ['my_profile']
mock_stdin.isatty.return_value = True mock_stdin.isatty.return_value = True
@ -277,7 +277,7 @@ class TestProfileDelete(TestProfile):
self.mock_client.delete_profile.assert_called_with('my_profile', self.mock_client.delete_profile.assert_called_with('my_profile',
False) False)
@mock.patch('sys.stdin', spec=six.StringIO) @mock.patch('sys.stdin', spec=io.StringIO)
def test_profile_delete_prompt_no(self, mock_stdin): def test_profile_delete_prompt_no(self, mock_stdin):
arglist = ['my_profile'] arglist = ['my_profile']
mock_stdin.isatty.return_value = True mock_stdin.isatty.return_value = True

View File

@ -11,12 +11,12 @@
# under the License. # under the License.
import copy import copy
import io
from unittest import mock from unittest import mock
from openstack import exceptions as sdk_exc from openstack import exceptions as sdk_exc
from osc_lib import exceptions as exc from osc_lib import exceptions as exc
from osc_lib import utils from osc_lib import utils
import six
from senlinclient.common.i18n import _ from senlinclient.common.i18n import _
from senlinclient.tests.unit.v1 import fakes from senlinclient.tests.unit.v1 import fakes
@ -347,7 +347,7 @@ class TestReceiverDelete(TestReceiver):
self.assertEqual('Failed to delete 1 of the 2 specified receiver(s).', self.assertEqual('Failed to delete 1 of the 2 specified receiver(s).',
str(error)) str(error))
@mock.patch('sys.stdin', spec=six.StringIO) @mock.patch('sys.stdin', spec=io.StringIO)
def test_receiver_delete_prompt_yes(self, mock_stdin): def test_receiver_delete_prompt_yes(self, mock_stdin):
arglist = ['my_receiver'] arglist = ['my_receiver']
mock_stdin.isatty.return_value = True mock_stdin.isatty.return_value = True
@ -360,7 +360,7 @@ class TestReceiverDelete(TestReceiver):
self.mock_client.delete_receiver.assert_called_with('my_receiver', self.mock_client.delete_receiver.assert_called_with('my_receiver',
False) False)
@mock.patch('sys.stdin', spec=six.StringIO) @mock.patch('sys.stdin', spec=io.StringIO)
def test_receiver_delete_prompt_no(self, mock_stdin): def test_receiver_delete_prompt_no(self, mock_stdin):
arglist = ['my_receiver'] arglist = ['my_receiver']
mock_stdin.isatty.return_value = True mock_stdin.isatty.return_value = True

View File

@ -23,7 +23,6 @@ from osc_lib.command import command
from osc_lib import exceptions as exc from osc_lib import exceptions as exc
from osc_lib import utils from osc_lib import utils
from oslo_utils import strutils from oslo_utils import strutils
import six
from senlinclient.common.i18n import _ from senlinclient.common.i18n import _
from senlinclient.common import utils as senlin_utils from senlinclient.common import utils as senlin_utils
@ -363,7 +362,7 @@ class DeleteCluster(command.Command):
cid, False, parsed_args.force_delete) cid, False, parsed_args.force_delete)
result[cid] = ('OK', cluster_delete_action['id']) result[cid] = ('OK', cluster_delete_action['id'])
except Exception as ex: except Exception as ex:
result[cid] = ('ERROR', six.text_type(ex)) result[cid] = ('ERROR', str(ex))
for rid, res in result.items(): for rid, res in result.items():
senlin_utils.print_action_result(rid, res) senlin_utils.print_action_result(rid, res)

View File

@ -20,7 +20,6 @@ from osc_lib.command import command
from osc_lib import exceptions as exc from osc_lib import exceptions as exc
from osc_lib import utils from osc_lib import utils
from oslo_utils import strutils from oslo_utils import strutils
import six
from senlinclient.common.i18n import _ from senlinclient.common.i18n import _
from senlinclient.common import utils as senlin_utils from senlinclient.common import utils as senlin_utils
@ -349,7 +348,7 @@ class DeleteNode(command.Command):
nid, False, parsed_args.force_delete) nid, False, parsed_args.force_delete)
result[nid] = ('OK', node_delete_action['id']) result[nid] = ('OK', node_delete_action['id'])
except Exception as ex: except Exception as ex:
result[nid] = ('ERROR', six.text_type(ex)) result[nid] = ('ERROR', str(ex))
for rid, res in result.items(): for rid, res in result.items():
senlin_utils.print_action_result(rid, res) senlin_utils.print_action_result(rid, res)