From 23d2e7838ab0cfb526830bd77628eeda2e278d3a Mon Sep 17 00:00:00 2001 From: melissaml Date: Wed, 14 Oct 2020 18:42:19 +0800 Subject: [PATCH] [Part9] Remove six We don't need this in a Python 3-only world. Remove six in follows: Change-Id: Ibfb9170e451deebc651758ad8c2db3a1fe58ae1b --- zaqar/transport/wsgi/v2_0/topic.py | 15 +++++++-------- zaqar/transport/wsgi/v2_0/topic_purge.py | 3 +-- zaqar/transport/wsgi/v2_0/topic_stats.py | 3 +-- zaqar/transport/wsgi/v2_0/urls.py | 7 +++---- 4 files changed, 12 insertions(+), 16 deletions(-) diff --git a/zaqar/transport/wsgi/v2_0/topic.py b/zaqar/transport/wsgi/v2_0/topic.py index 7f1bc3b08..2d9a48801 100644 --- a/zaqar/transport/wsgi/v2_0/topic.py +++ b/zaqar/transport/wsgi/v2_0/topic.py @@ -16,7 +16,6 @@ import copy import falcon from oslo_log import log as logging -import six from zaqar.common import decorators from zaqar.i18n import _ @@ -63,7 +62,7 @@ class ItemResource(object): resp_dict[meta] = value except storage_errors.DoesNotExist as ex: LOG.debug(ex) - raise wsgi_errors.HTTPNotFound(six.text_type(ex)) + raise wsgi_errors.HTTPNotFound(str(ex)) except Exception: description = _(u'Topic metadata could not be retrieved.') @@ -88,7 +87,7 @@ class ItemResource(object): self._validate.queue_metadata_putting(metadata) except validation.ValidationFailed as ex: LOG.debug(ex) - raise wsgi_errors.HTTPBadRequestAPI(six.text_type(ex)) + raise wsgi_errors.HTTPBadRequestAPI(str(ex)) try: created = self._topic_controller.create(topic_name, @@ -97,7 +96,7 @@ class ItemResource(object): except storage_errors.FlavorDoesNotExist as ex: LOG.exception('Flavor "%s" does not exist', topic_name) - raise wsgi_errors.HTTPBadRequestAPI(six.text_type(ex)) + raise wsgi_errors.HTTPBadRequestAPI(str(ex)) except Exception: description = _(u'Topic could not be created.') LOG.exception(description) @@ -141,7 +140,7 @@ class ItemResource(object): self._validate.queue_metadata_length(req.content_length) except validation.ValidationFailed as ex: LOG.debug(ex) - raise wsgi_errors.HTTPBadRequestBody(six.text_type(ex)) + raise wsgi_errors.HTTPBadRequestBody(str(ex)) # NOTE(flwang): See below link to get more details about draft 10, # tools.ietf.org/html/draft-ietf-appsawg-json-patch-10 @@ -201,10 +200,10 @@ class ItemResource(object): project_id) except storage_errors.DoesNotExist as ex: LOG.debug(ex) - raise wsgi_errors.HTTPNotFound(six.text_type(ex)) + raise wsgi_errors.HTTPNotFound(str(ex)) except validation.ValidationFailed as ex: LOG.debug(ex) - raise wsgi_errors.HTTPBadRequestBody(six.text_type(ex)) + raise wsgi_errors.HTTPBadRequestBody(str(ex)) except wsgi_errors.HTTPConflict: raise except Exception: @@ -261,7 +260,7 @@ class CollectionResource(object): except validation.ValidationFailed as ex: LOG.debug(ex) - raise wsgi_errors.HTTPBadRequestAPI(six.text_type(ex)) + raise wsgi_errors.HTTPBadRequestAPI(str(ex)) except Exception: description = _(u'Topics could not be listed.') diff --git a/zaqar/transport/wsgi/v2_0/topic_purge.py b/zaqar/transport/wsgi/v2_0/topic_purge.py index e982256dd..88a68083e 100644 --- a/zaqar/transport/wsgi/v2_0/topic_purge.py +++ b/zaqar/transport/wsgi/v2_0/topic_purge.py @@ -15,7 +15,6 @@ import falcon from oslo_log import log as logging -import six from zaqar.common import decorators from zaqar.i18n import _ @@ -51,7 +50,7 @@ class Resource(object): document = {'resource_types': ['messages', 'subscriptions']} except validation.ValidationFailed as ex: LOG.debug(ex) - raise wsgi_errors.HTTPBadRequestAPI(six.text_type(ex)) + raise wsgi_errors.HTTPBadRequestAPI(str(ex)) try: if "messages" in document['resource_types']: diff --git a/zaqar/transport/wsgi/v2_0/topic_stats.py b/zaqar/transport/wsgi/v2_0/topic_stats.py index bd0d84547..3911c89df 100644 --- a/zaqar/transport/wsgi/v2_0/topic_stats.py +++ b/zaqar/transport/wsgi/v2_0/topic_stats.py @@ -14,7 +14,6 @@ # limitations under the License. from oslo_log import log as logging -import six from zaqar.common import decorators from zaqar.i18n import _ @@ -70,7 +69,7 @@ class Resource(object): except storage_errors.DoesNotExist as ex: LOG.debug(ex) - raise wsgi_errors.HTTPNotFound(six.text_type(ex)) + raise wsgi_errors.HTTPNotFound(str(ex)) except Exception: description = _(u'Topic stats could not be read.') diff --git a/zaqar/transport/wsgi/v2_0/urls.py b/zaqar/transport/wsgi/v2_0/urls.py index ed5a4c194..8256752ea 100644 --- a/zaqar/transport/wsgi/v2_0/urls.py +++ b/zaqar/transport/wsgi/v2_0/urls.py @@ -15,7 +15,6 @@ import os from oslo_log import log as logging -import six from zaqar.common import decorators from zaqar.common import urls @@ -50,11 +49,11 @@ class Resource(object): document = wsgi_utils.deserialize(req.stream, req.content_length) except ValueError as ex: LOG.debug(ex) - raise wsgi_errors.HTTPBadRequestAPI(six.text_type(ex)) + raise wsgi_errors.HTTPBadRequestAPI(str(ex)) diff = set(document.keys()) - _KNOWN_KEYS if diff: - msg = six.text_type('Unknown keys: %s' % diff) + msg = str('Unknown keys: %s' % diff) raise wsgi_errors.HTTPBadRequestAPI(msg) key = self._conf.signed_url.secret_key @@ -64,7 +63,7 @@ class Resource(object): else: diff = set(paths) - _VALID_PATHS if diff: - msg = six.text_type('Invalid paths: %s' % diff) + msg = str('Invalid paths: %s' % diff) raise wsgi_errors.HTTPBadRequestAPI(msg) paths = [os.path.join(req.path[:-6], path) for path in paths]