Remove six library

Remove six-library Replace the following items with Python 3 style code.
- six.interger_types
- six.itervalues
- six.text_type
- six.string_types
- six.StringIO
- six.next
- six.b
- six.PY3

Change-Id: I299c90d5cbeb41be0132691265b8dcbeae65520e
This commit is contained in:
Q.hongtao 2020-09-22 10:12:23 +08:00
parent da5ac25415
commit 4bc6162515
35 changed files with 88 additions and 156 deletions

View File

@ -36,7 +36,6 @@ PyJWT==1.5
PyYAML==5.1
requests-mock==1.2.0
requests==2.14.2
six==1.10.0
SQLAlchemy==1.2.5
stestr==2.0.0
stevedore==1.20.0

View File

@ -22,7 +22,6 @@ from urllib import parse
from oslo_log import log as logging
import requests
import six
from mistral import exceptions as exc
from mistral import utils
@ -172,7 +171,7 @@ class HTTPAction(actions.Action):
if isinstance(headers, dict):
for key, val in headers.items():
if isinstance(val, (six.integer_types, float)):
if isinstance(val, (int, float)):
headers[key] = str(val)
if body and json:

View File

@ -15,7 +15,6 @@
from oslo_config import cfg
from oslo_log import log as logging
from pecan import rest
import six
import tooz.coordination
import wsmeext.pecan as wsme_pecan
@ -79,7 +78,7 @@ class ServicesController(rest.RestController):
# connection shutdown, ToozError will be raised.
raise exc.CoordinationException(
"Failed to get service members from coordination backend. %s"
% six.text_type(e)
% str(e)
)
return resources.Services(services=services_list)

View File

@ -15,7 +15,6 @@ import json
from mistral.utils import filter_utils
from oslo_utils import uuidutils
import six
from wsme import types as wtypes
from mistral import exceptions as exc
@ -34,7 +33,7 @@ class ListType(wtypes.UserType):
:param value: A comma separated string of values
:returns: A list of values.
"""
items = [v.strip().lower() for v in six.text_type(value).split(',')]
items = [v.strip().lower() for v in str(value).split(',')]
# remove empty items.
return [x for x in items if x]

View File

@ -21,7 +21,6 @@ from alembic import util as alembic_u
from oslo_config import cfg
from oslo_log import log as logging
from oslo_utils import importutils
import six
import sys
from mistral.services import action_manager
@ -41,7 +40,7 @@ def do_alembic_command(config, cmd, *args, **kwargs):
try:
getattr(alembic_cmd, cmd)(config, *args, **kwargs)
except alembic_u.CommandError as e:
alembic_u.err(six.text_type(e))
alembic_u.err(str(e))
def do_check_migration(config, _cmd):

View File

@ -16,7 +16,6 @@ from cachetools import keys as cachetools_keys
import decorator
import functools
import inspect
import six
from sqlalchemy import exc as sqla_exc
@ -156,7 +155,7 @@ def tx_cached(use_args=None, ignore_args=None):
arg_dict = inspect.getcallargs(func, *args, **kw)
if ignore_args:
if not isinstance(ignore_args, (six.string_types, tuple)):
if not isinstance(ignore_args, (str, tuple)):
raise ValueError(
"'ignore_args' must be either a tuple or a string,"
" actual type: %s" % type(ignore_args)
@ -171,7 +170,7 @@ def tx_cached(use_args=None, ignore_args=None):
arg_dict.pop(arg_name, None)
if use_args:
if not isinstance(use_args, (six.string_types, tuple)):
if not isinstance(use_args, (str, tuple)):
raise ValueError(
"'use_args' must be either a tuple or a string,"
" actual type: %s" % type(use_args)

View File

@ -13,8 +13,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import six
from mistral.db import utils as db_utils
from mistral.db.v2 import api as db_api
from mistral.engine import base
@ -77,7 +75,7 @@ def build_wait_before_policy(policies_spec):
wait_before = policies_spec.get_wait_before()
if isinstance(wait_before, six.string_types) or wait_before > 0:
if isinstance(wait_before, str) or wait_before > 0:
return WaitBeforePolicy(wait_before)
else:
return None
@ -89,7 +87,7 @@ def build_wait_after_policy(policies_spec):
wait_after = policies_spec.get_wait_after()
if isinstance(wait_after, six.string_types) or wait_after > 0:
if isinstance(wait_after, str) or wait_after > 0:
return WaitAfterPolicy(wait_after)
else:
return None
@ -118,7 +116,7 @@ def build_timeout_policy(policies_spec):
timeout_policy = policies_spec.get_timeout()
if isinstance(timeout_policy, six.string_types) or timeout_policy > 0:
if isinstance(timeout_policy, str) or timeout_policy > 0:
return TimeoutPolicy(timeout_policy)
else:
return None

View File

@ -22,7 +22,6 @@ import json
from oslo_config import cfg
from oslo_log import log as logging
from osprofiler import profiler
import six
from mistral.db.v2 import api as db_api
from mistral.engine import actions
@ -828,7 +827,7 @@ class WithItemsTask(RegularTask):
with_items_values = self._get_with_items_values()
if self._is_new():
action_count = len(six.next(iter(with_items_values.values())))
action_count = len(next(iter(with_items_values.values())))
self._prepare_runtime_context(action_count)

View File

@ -20,7 +20,6 @@ import json
from oslo_config import cfg
from oslo_log import log as logging
from osprofiler import profiler
import six
from mistral.db.v2 import api as db_api
from mistral.db.v2.sqlalchemy import models as db_models
@ -603,7 +602,7 @@ def _get_environment(params):
if isinstance(env, dict):
env_dict = env
elif isinstance(env, six.string_types):
elif isinstance(env, str):
env_db = db_api.load_environment(env)
if not env_db:

View File

@ -23,7 +23,6 @@ from oslo_config import cfg
from oslo_log import log as logging
from oslo_service import threadgroup
from oslo_utils import fnmatch
import six
from mistral import context as auth_ctx
from mistral.db.v2 import api as db_api
@ -60,7 +59,7 @@ class EventDefinition(object):
"Required field %s not specified" % err.args[0]
)
if isinstance(self.event_types, six.string_types):
if isinstance(self.event_types, str):
self.event_types = [self.event_types]
def match_type(self, event_type):
@ -207,7 +206,7 @@ class DefaultEventEngine(base.EventEngine):
self.exchange_topic_listener_map[key] = listener
def stop_all_listeners(self):
for listener in six.itervalues(self.exchange_topic_listener_map):
for listener in self.exchange_topic_listener_map.values():
listener.stop()
listener.wait()

View File

@ -17,7 +17,6 @@
import copy
from oslo_log import log as logging
import six
from stevedore import extension
from mistral import exceptions as exc
@ -41,7 +40,7 @@ for name in sorted(_mgr.names()):
def validate(expression):
LOG.debug("Validating expression [expression='%s']", expression)
if not isinstance(expression, six.string_types):
if not isinstance(expression, str):
return
expression_found = None
@ -66,7 +65,7 @@ def evaluate(expression, context):
for name, evaluator in _evaluators:
# Check if the passed value is expression so we don't need to do this
# every time on a caller side.
if (isinstance(expression, six.string_types) and
if (isinstance(expression, str) and
evaluator.is_expression(expression)):
return evaluator.evaluate(expression, context)
@ -74,7 +73,7 @@ def evaluate(expression, context):
def _evaluate_item(item, context):
if isinstance(item, six.string_types):
if isinstance(item, str):
try:
return evaluate(item, context)
except AttributeError as e:
@ -101,7 +100,7 @@ def evaluate_recursively(data, context):
elif isinstance(data, list):
for index, item in enumerate(data):
data[index] = _evaluate_item(item, context)
elif isinstance(data, six.string_types):
elif isinstance(data, str):
return _evaluate_item(data, context)
return data

View File

@ -20,7 +20,6 @@ from jinja2 import parser as jinja_parse
from jinja2.sandbox import SandboxedEnvironment
from oslo_db import exception as db_exc
from oslo_log import log as logging
import six
from mistral import exceptions as exc
from mistral.expressions import base
@ -72,7 +71,7 @@ class JinjaEvaluator(base.Evaluator):
@classmethod
def validate(cls, expression):
if not isinstance(expression, six.string_types):
if not isinstance(expression, str):
raise exc.JinjaEvaluationException(
"Unsupported type '%s'." % type(expression)
)
@ -114,7 +113,7 @@ class InlineJinjaEvaluator(base.Evaluator):
@classmethod
def validate(cls, expression):
if not isinstance(expression, six.string_types):
if not isinstance(expression, str):
raise exc.JinjaEvaluationException(
"Unsupported type '%s'." % type(expression)
)

View File

@ -20,7 +20,6 @@ import re
from oslo_db import exception as db_exc
from oslo_log import log as logging
import six
from yaml import representer
import yaql
from yaql.language import exceptions as yaql_exc
@ -198,7 +197,7 @@ class InlineYAQLEvaluator(YAQLEvaluator):
@classmethod
def validate(cls, expression):
if not isinstance(expression, six.string_types):
if not isinstance(expression, str):
raise exc.YaqlEvaluationException(
"Unsupported type '%s'." % type(expression)
)

View File

@ -24,7 +24,6 @@ please see pep8.py.
import ast
import re
import six
from hacking import core
@ -201,7 +200,7 @@ class CheckForLoggingIssues(BaseASTChecker):
method_name = node.attr
return obj_name + '.' + method_name
elif isinstance(node, six.string_types):
elif isinstance(node, str):
return node
else: # Could be Subscript, Call or many more
return None

View File

@ -18,7 +18,6 @@ import json
import jsonschema
from osprofiler import profiler
import re
import six
from mistral import exceptions as exc
from mistral import expressions as expr
@ -33,7 +32,7 @@ ACTION_PATTERNS = {
"jinja_expression": ANY_JINJA_REGEXP,
}
CMD_PTRN = re.compile(
"^({})".format("|".join(six.itervalues(ACTION_PATTERNS)))
"^({})".format("|".join(ACTION_PATTERNS.values()))
)
EXPRESSION = '|'.join([expr.patterns[name] for name in expr.patterns])
@ -245,15 +244,15 @@ class BaseSpec(object):
pass
def validate_expr(self, dsl_part):
if isinstance(dsl_part, six.string_types):
if isinstance(dsl_part, str):
expr.validate(dsl_part)
elif isinstance(dsl_part, (list, tuple)):
for expression in dsl_part:
if isinstance(expression, six.string_types):
if isinstance(expression, str):
expr.validate(expression)
elif isinstance(dsl_part, dict):
for expression in dsl_part.values():
if isinstance(expression, six.string_types):
if isinstance(expression, str):
expr.validate(expression)
def _spec_property(self, prop_name, spec_cls):
@ -300,7 +299,7 @@ class BaseSpec(object):
result.update(t if isinstance(t, dict) else {t: ''})
return result
elif isinstance(prop_val, six.string_types):
elif isinstance(prop_val, str):
return {prop_val: ''}
@staticmethod
@ -415,7 +414,7 @@ class BaseSpecList(object):
return self.items.keys()
def __iter__(self):
return six.itervalues(self.items)
return iter(self.items.values())
def __getitem__(self, name):
return self.items.get(name)

View File

@ -17,7 +17,7 @@ import cachetools
import threading
from yaml import error
import six
import io as six_io
from mistral.db.v2 import api as db_api
from mistral import exceptions as exc
@ -170,7 +170,7 @@ def get_action_definition(wb_def, action_name):
def _parse_def_from_wb(wb_def, section_name, item_name):
io = six.StringIO(wb_def[wb_def.index(section_name):])
io = six_io.StringIO(wb_def[wb_def.index(section_name):])
io.readline()
definition = []

View File

@ -13,8 +13,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import six
from mistral.lang import types
from mistral.lang.v2 import base
from mistral_lib import utils
@ -58,7 +56,7 @@ class ActionSpec(base.BaseSpec):
self.validate_expr(self._data.get('base-input', {}))
if isinstance(self._data.get('output'), six.string_types):
if isinstance(self._data.get('output'), str):
self.validate_expr(self._data.get('output'))
def get_name(self):

View File

@ -13,8 +13,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import six
from mistral.lang import types
from mistral.lang.v2 import base
from mistral.lang.v2 import publish
@ -121,7 +119,7 @@ def _as_list_of_tuples(data):
if not data:
return []
if isinstance(data, six.string_types):
if isinstance(data, str):
return [_as_tuple(data)]
return [_as_tuple(item) for item in data]

View File

@ -13,8 +13,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import six
from mistral.lang import types
from mistral.lang.v2 import base
@ -65,7 +63,7 @@ class RetrySpec(base.BaseSpec):
self._delay = data['delay']
def _transform_retry_one_line(self, retry):
if isinstance(retry, six.string_types):
if isinstance(retry, str):
_, params = self._parse_cmd_and_input(retry)
return params

View File

@ -13,8 +13,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import six
from mistral.lang import types
from mistral.lang.v2 import base
from mistral.lang.v2 import on_clause
@ -98,7 +96,7 @@ class TaskDefaultsSpec(base.BaseSpec):
return
[self.validate_expr(t)
for t in ([val] if isinstance(val, six.string_types) else val)]
for t in ([val] if isinstance(val, str) else val)]
def get_policies(self):
return self._policies
@ -116,7 +114,7 @@ class TaskDefaultsSpec(base.BaseSpec):
return self._safe_rerun
def get_requires(self):
if isinstance(self._requires, six.string_types):
if isinstance(self._requires, str):
return [self._requires]
return self._requires

View File

@ -17,7 +17,6 @@
import copy
import json
import re
import six
from mistral import exceptions as exc
from mistral import expressions
@ -170,11 +169,11 @@ class TaskSpec(base.BaseSpec):
with_items = {}
if isinstance(raw, six.string_types):
if isinstance(raw, str):
raw = [raw]
for item in raw:
if not isinstance(item, six.string_types):
if not isinstance(item, str):
raise exc.InvalidModelException(
"'with-items' elements should be strings: %s" % self._data
)
@ -331,7 +330,7 @@ class DirectWorkflowTaskSpec(TaskSpec):
return
[self.validate_expr(t)
for t in ([val] if isinstance(val, six.string_types) else val)]
for t in ([val] if isinstance(val, str) else val)]
def get_publish(self, state):
spec = super(DirectWorkflowTaskSpec, self).get_publish(state)
@ -392,7 +391,7 @@ class ReverseWorkflowTaskSpec(TaskSpec):
self._requires = data.get('requires', [])
def get_requires(self):
if isinstance(self._requires, six.string_types):
if isinstance(self._requires, str):
return [self._requires]
return self._requires

View File

@ -15,7 +15,6 @@
from oslo_utils import uuidutils
from osprofiler import profiler
import six
from mistral import exceptions as exc
from mistral.lang import types
@ -75,7 +74,7 @@ class WorkflowSpec(base.BaseSpec):
# Inject 'type' here, so instantiate_spec function can recognize the
# specific subclass of TaskSpec.
for task in six.itervalues(self._data.get('tasks')):
for task in self._data.get('tasks').values():
task['type'] = self._type
self._tasks = self._spec_property('tasks', tasks.TaskSpecList)

View File

@ -15,7 +15,6 @@
import itertools
import random
import six
import oslo_messaging as messaging
@ -33,4 +32,4 @@ class KombuHosts(object):
self._hosts_cycle = itertools.cycle(self.hosts)
def get_host(self):
return six.next(self._hosts_cycle)
return next(self._hosts_cycle)

View File

@ -16,7 +16,6 @@
import itertools
from kombu.mixins import ConsumerMixin
import queue
import six
import threading
from oslo_log import log as logging
@ -34,7 +33,7 @@ class KombuRPCListener(ConsumerMixin):
self._connections = itertools.cycle(connections)
self._callback_queue = callback_queue
self._thread = None
self.connection = six.next(self._connections)
self.connection = next(self._connections)
self.ready = eventletutils.Event()
@ -107,7 +106,7 @@ class KombuRPCListener(ConsumerMixin):
def on_connection_error(self, exc, interval):
self.ready.clear()
self.connection = six.next(self._connections)
self.connection = next(self._connections)
LOG.debug("Broker connection failed: %s", exc)
LOG.debug(

View File

@ -12,8 +12,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import six
from oslo_concurrency import lockutils
from oslo_config import cfg
from oslo_log import log
@ -39,7 +37,8 @@ class ServiceCoordinator(object):
def __init__(self, my_id=None):
self._coordinator = None
self._my_id = six.b(my_id or utils.get_process_identifier())
self._my_id = my_id or utils.get_process_identifier()
self._my_id = self._my_id.encode("latin-1")
self._started = False
def start(self):
@ -60,7 +59,7 @@ class ServiceCoordinator(object):
self._started = False
LOG.exception('Error connecting to coordination backend. '
'%s', six.text_type(e))
'%s', str(e))
def stop(self):
if not self.is_active():
@ -83,7 +82,7 @@ class ServiceCoordinator(object):
return
try:
join_req = self._coordinator.join_group(six.b(group_id))
join_req = self._coordinator.join_group(group_id.encode("latin-1"))
join_req.get()
LOG.info(
@ -96,7 +95,8 @@ class ServiceCoordinator(object):
except tooz.coordination.MemberAlreadyExist:
return
except tooz.coordination.GroupNotCreated as e:
create_grp_req = self._coordinator.create_group(six.b(group_id))
create_grp_req = self._coordinator.create_group(
group_id.encode("latin-1"))
try:
create_grp_req.get()
@ -108,7 +108,7 @@ class ServiceCoordinator(object):
def leave_group(self, group_id):
if self.is_active():
self._coordinator.leave_group(six.b(group_id))
self._coordinator.leave_group(group_id.encode("latin-1"))
LOG.info(
'Left service group:%s, member:%s',
@ -125,7 +125,8 @@ class ServiceCoordinator(object):
if not self.is_active():
return []
get_members_req = self._coordinator.get_members(six.b(group_id))
get_members_req = self._coordinator.get_members(
group_id.encode("latin-1"))
try:
members = get_members_req.get()

View File

@ -15,7 +15,6 @@
import croniter
import datetime
import json
import six
from oslo_log import log as logging
@ -77,7 +76,7 @@ def create_cron_trigger(name, workflow_name, workflow_input,
if not start_time:
start_time = datetime.datetime.utcnow()
if isinstance(first_time, six.string_types):
if isinstance(first_time, str):
try:
first_time = datetime.datetime.strptime(
first_time,

View File

@ -19,7 +19,6 @@ from email.header import decode_header
from email import parser
from unittest import mock
import six
import testtools
from mistral.actions import std_actions as std
@ -153,26 +152,15 @@ class SendEmailActionTest(base.BaseTest):
self.assertEqual(self.from_addr, message['from'])
self.assertEqual(self.to_addrs_str, message['to'])
if six.PY3:
self.assertEqual(
self.subject,
decode_header(message['subject'])[0][0].decode('utf-8')
)
else:
self.assertEqual(
self.subject.decode('utf-8'),
decode_header(message['subject'])[0][0].decode('utf-8')
)
if six.PY3:
self.assertEqual(
self.body,
base64.b64decode(message.get_payload()).decode('utf-8')
)
else:
self.assertEqual(
self.body.decode('utf-8'),
base64.b64decode(message.get_payload()).decode('utf-8')
)
self.assertEqual(
self.subject,
decode_header(message['subject'])[0][0].decode('utf-8')
)
self.assertEqual(
self.body,
base64.b64decode(message.get_payload()).decode('utf-8')
)
@mock.patch('smtplib.SMTP')
def test_send_email_with_cc(self, smtp):
@ -294,38 +282,20 @@ class SendEmailActionTest(base.BaseTest):
self.assertEqual(self.from_addr, message['from'])
self.assertEqual(self.to_addrs_str, message['to'])
if six.PY3:
self.assertEqual(
self.subject,
decode_header(message['subject'])[0][0].decode('utf-8')
)
else:
self.assertEqual(
self.subject.decode('utf-8'),
decode_header(message['subject'])[0][0].decode('utf-8')
)
self.assertEqual(
self.subject,
decode_header(message['subject'])[0][0].decode('utf-8')
)
body_payload = message.get_payload(0).get_payload()
if six.PY3:
self.assertEqual(
self.body,
base64.b64decode(body_payload).decode('utf-8')
)
else:
self.assertEqual(
self.body.decode('utf-8'),
base64.b64decode(body_payload).decode('utf-8')
)
self.assertEqual(
self.body,
base64.b64decode(body_payload).decode('utf-8')
)
html_body_payload = message.get_payload(1).get_payload()
if six.PY3:
self.assertEqual(
self.html_body,
base64.b64decode(html_body_payload).decode('utf-8')
)
else:
self.assertEqual(
self.html_body.decode('utf-8'),
base64.b64decode(html_body_payload).decode('utf-8')
)
self.assertEqual(
self.html_body,
base64.b64decode(html_body_payload).decode('utf-8')
)
@mock.patch('smtplib.SMTP')
def test_with_password(self, smtp):

View File

@ -17,7 +17,6 @@ import datetime
import json
from unittest import mock
import six
import sqlalchemy as sa
from mistral.api.controllers.v2 import resources
@ -120,7 +119,7 @@ MOCK_DELETE = mock.MagicMock(return_value=None)
def _convert_vars_to_dict(env_dict):
"""Converts 'variables' in the given environment dict into dictionary."""
if ('variables' in env_dict and
isinstance(env_dict.get('variables'), six.string_types)):
isinstance(env_dict.get('variables'), str)):
env_dict['variables'] = json.loads(env_dict['variables'])
return env_dict

View File

@ -13,8 +13,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import six
from oslo_config import cfg
from mistral.db.v2 import api as db_api
@ -1119,7 +1117,7 @@ class DirectWorkflowEngineTest(base.EngineTestCase):
# versions of Python. On Python 3 this field's value was always
# converted into a string no matter what we tried to assign. But
# that didn't happen on Python 2.7 which caused an SQL exception.
self.assertIsInstance(task_ex.state_info, six.string_types)
self.assertIsInstance(task_ex.state_info, str)
def test_single_fail_with_next_noop(self):
wf_text = """---

View File

@ -15,7 +15,6 @@
from unittest import mock
from oslo_config import cfg
import six
from mistral.service import coordination
from mistral.tests.unit import base
@ -93,7 +92,7 @@ class ServiceCoordinatorTest(base.BaseTest):
members = coordinator.get_members('fake_group')
self.assertEqual(1, len(members))
self.assertCountEqual((six.b('fake_id'),), members)
self.assertCountEqual(('fake_id'.encode("latin-1"),), members)
def test_join_group_and_leave_group(self):
cfg.CONF.set_default(
@ -112,7 +111,7 @@ class ServiceCoordinatorTest(base.BaseTest):
members_after = coordinator.get_members('fake_group')
self.assertEqual(1, len(members_before))
self.assertEqual(set([six.b('fake_id')]), members_before)
self.assertEqual(set(['fake_id'.encode("latin-1")]), members_before)
self.assertEqual(0, len(members_after))
self.assertEqual(set([]), members_after)
@ -144,4 +143,4 @@ class ServiceTest(base.BaseTest):
members = srv_coordinator.get_members('fake_group')
mock_get_identifier.assert_called_once_with()
self.assertEqual(set([six.b('fake_id')]), members)
self.assertEqual(set(['fake_id'.encode("latin-1")]), members)

View File

@ -12,8 +12,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import six
from mistral import exceptions
from mistral.tests.unit import base
from mistral_lib.utils import inspect_utils
@ -25,19 +23,19 @@ class ExceptionTest(base.BaseTest):
def test_nf_with_message(self):
exc = exceptions.DBEntityNotFoundError('check_for_this')
self.assertIn('check_for_this', six.text_type(exc))
self.assertIn('check_for_this', str(exc))
self.assertEqual(404, exc.http_code)
def test_nf_with_no_message(self):
exc = exceptions.DBEntityNotFoundError()
self.assertIn("Object not found", six.text_type(exc))
self.assertIn("Object not found", str(exc))
self.assertEqual(404, exc.http_code,)
def test_duplicate_obj_code(self):
exc = exceptions.DBDuplicateEntryError()
self.assertIn("Database object already exists", six.text_type(exc))
self.assertIn("Database object already exists", str(exc))
self.assertEqual(409, exc.http_code,)
def test_default_code(self):
@ -48,7 +46,7 @@ class ExceptionTest(base.BaseTest):
def test_default_message(self):
exc = exceptions.EngineException()
self.assertIn("An unknown exception occurred", six.text_type(exc))
self.assertIn("An unknown exception occurred", str(exc))
def test_one_param_initializer(self):
# NOTE: this test is needed because at some places in the code we

View File

@ -13,8 +13,6 @@
# License for the specific language governing permissions and limitations
# under the License.
import six
EQUALS = 'eq'
NOT_EQUAL = 'neq'
LESS_THAN = 'lt'
@ -42,7 +40,7 @@ def create_filters_from_request_params(none_values=None, **params):
for column, data in params.items():
if (data is None and column in none_values) or data is not None:
if isinstance(data, six.string_types):
if isinstance(data, str):
f_type, value = extract_filter_type_and_value(data)
create_or_update_filter(column, value, f_type, filters)
@ -83,7 +81,7 @@ def extract_filter_type_and_value(data):
"""
if has_filters(data):
filter_type, value = data.split(':', 1)
value = six.text_type(value)
value = str(value)
if data.startswith((IN, NOT_IN)):
value = list(value.split(","))
else:

View File

@ -20,7 +20,6 @@ import json
from oslo_db import exception as db_exc
from oslo_log import log as logging
import pecan
import six
import sqlalchemy as sa
from sqlalchemy.orm import exc as sa_exc
import tenacity
@ -53,7 +52,7 @@ def wrap_wsme_controller_exception(func):
LOG.error('Error during API call: %s', str(e))
raise wsme_exc.ClientSideError(
msg=six.text_type(e),
msg=str(e),
status_code=e.http_code
)
@ -76,7 +75,7 @@ def wrap_pecan_controller_exception(func):
return webob.Response(
status=e.http_code,
content_type='application/json',
body=json.dumps(dict(faultstring=six.text_type(e))),
body=json.dumps(dict(faultstring=str(e))),
charset='UTF-8'
)

View File

@ -14,7 +14,7 @@
from os import path
import six
import io
from oslo_log import log as logging
import paramiko
@ -42,7 +42,7 @@ def _to_paramiko_private_key(private_key_filename,
password=None):
if private_key:
return paramiko.RSAKey.from_private_key(
file_obj=six.StringIO(private_key),
file_obj=io.StringIO(private_key),
password=password)
if private_key_filename:

View File

@ -33,7 +33,6 @@ PyJWT>=1.5 # MIT
PyYAML>=5.1 # MIT
requests>=2.14.2 # Apache-2.0
tenacity>=5.0.1 # Apache-2.0
six>=1.10.0 # MIT
SQLAlchemy>=1.2.5 # MIT
stevedore>=1.20.0 # Apache-2.0
WSME>=0.8.0 # MIT