From 1399cee171f62ea89f3e509eda3f412ee979cb2b Mon Sep 17 00:00:00 2001 From: melissaml Date: Wed, 14 Oct 2020 22:26:45 +0800 Subject: [PATCH] [Part3] Remove six We don't need this in a Python 3-only world. Remove six in follows: 1. zaqar/transport/wsgi/v1_0/* 2. zaqar/transport/wsgi/v1_1/* 3. zaqar/transport/wsgi/utils.py Change-Id: I10ad5001e5ef9e9ae32d7a57080e676d5be6fdf8 --- zaqar/transport/wsgi/utils.py | 3 +-- zaqar/transport/wsgi/v1_0/claims.py | 9 ++++----- zaqar/transport/wsgi/v1_0/messages.py | 17 ++++++++--------- zaqar/transport/wsgi/v1_0/metadata.py | 9 ++++----- zaqar/transport/wsgi/v1_0/pools.py | 7 +++---- zaqar/transport/wsgi/v1_0/queues.py | 3 +-- zaqar/transport/wsgi/v1_0/stats.py | 3 +-- zaqar/transport/wsgi/v1_1/claims.py | 9 ++++----- zaqar/transport/wsgi/v1_1/flavors.py | 5 ++--- zaqar/transport/wsgi/v1_1/messages.py | 15 +++++++-------- zaqar/transport/wsgi/v1_1/pools.py | 9 ++++----- zaqar/transport/wsgi/v1_1/queues.py | 9 ++++----- zaqar/transport/wsgi/v1_1/stats.py | 3 +-- 13 files changed, 44 insertions(+), 57 deletions(-) diff --git a/zaqar/transport/wsgi/utils.py b/zaqar/transport/wsgi/utils.py index e577bb605..bb612108e 100644 --- a/zaqar/transport/wsgi/utils.py +++ b/zaqar/transport/wsgi/utils.py @@ -16,7 +16,6 @@ import falcon import jsonschema from oslo_log import log as logging -import six from zaqar.i18n import _ from zaqar.transport import utils @@ -212,7 +211,7 @@ def validate(validator, document): validator.validate(document) except jsonschema.ValidationError as ex: raise errors.HTTPBadRequestBody( - '{0}: {1}'.format(ex.args, six.text_type(ex)) + '{0}: {1}'.format(ex.args, str(ex)) ) diff --git a/zaqar/transport/wsgi/v1_0/claims.py b/zaqar/transport/wsgi/v1_0/claims.py index 2a36b7c36..df9673113 100644 --- a/zaqar/transport/wsgi/v1_0/claims.py +++ b/zaqar/transport/wsgi/v1_0/claims.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 _ @@ -68,7 +67,7 @@ class CollectionResource(Resource): 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'Claim could not be created.') @@ -110,7 +109,7 @@ class ItemResource(Resource): 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'Claim could not be queried.') LOG.exception(description) @@ -147,11 +146,11 @@ class ItemResource(Resource): except validation.ValidationFailed as ex: LOG.debug(ex) - raise wsgi_errors.HTTPBadRequestAPI(six.text_type(ex)) + raise wsgi_errors.HTTPBadRequestAPI(str(ex)) 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'Claim could not be updated.') diff --git a/zaqar/transport/wsgi/v1_0/messages.py b/zaqar/transport/wsgi/v1_0/messages.py index 7cf6f4686..71f5e95d5 100644 --- a/zaqar/transport/wsgi/v1_0/messages.py +++ b/zaqar/transport/wsgi/v1_0/messages.py @@ -15,7 +15,6 @@ import falcon from oslo_log import log as logging -import six from zaqar.common import decorators from zaqar.common.transport.wsgi import helpers as wsgi_helpers @@ -55,7 +54,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'Message could not be retrieved.') @@ -94,11 +93,11 @@ 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 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'Messages could not be listed.') @@ -137,7 +136,7 @@ class CollectionResource(object): self._validate.message_length(req.content_length) except validation.ValidationFailed as ex: LOG.debug(ex) - raise wsgi_errors.HTTPBadRequestAPI(six.text_type(ex)) + raise wsgi_errors.HTTPBadRequestAPI(str(ex)) # Deserialize and validate the request body document = wsgi_utils.deserialize(req.stream, req.content_length) @@ -155,11 +154,11 @@ 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 storage_errors.DoesNotExist as ex: LOG.debug(ex) - raise wsgi_errors.HTTPNotFound(six.text_type(ex)) + raise wsgi_errors.HTTPNotFound(str(ex)) except storage_errors.MessageConflict: description = _(u'No messages could be enqueued.') @@ -220,7 +219,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'Messages could not be deleted.') @@ -247,7 +246,7 @@ class ItemResource(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'Message could not be retrieved.') diff --git a/zaqar/transport/wsgi/v1_0/metadata.py b/zaqar/transport/wsgi/v1_0/metadata.py index 3ea2db46e..23db1251c 100644 --- a/zaqar/transport/wsgi/v1_0/metadata.py +++ b/zaqar/transport/wsgi/v1_0/metadata.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 _ @@ -45,7 +44,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'Queue metadata could not be retrieved.') @@ -73,7 +72,7 @@ class Resource(object): raise validation.ValidationFailed(description) except validation.ValidationFailed as ex: LOG.debug(ex) - raise wsgi_errors.HTTPBadRequestAPI(six.text_type(ex)) + raise wsgi_errors.HTTPBadRequestAPI(str(ex)) try: self._queue_ctrl.set_metadata(queue_name, @@ -82,10 +81,10 @@ class Resource(object): except validation.ValidationFailed as ex: LOG.debug(ex) - raise wsgi_errors.HTTPBadRequestAPI(six.text_type(ex)) + raise wsgi_errors.HTTPBadRequestAPI(str(ex)) except storage_errors.QueueDoesNotExist as ex: - raise wsgi_errors.HTTPNotFound(six.text_type(ex)) + raise wsgi_errors.HTTPNotFound(str(ex)) except Exception: description = _(u'Metadata could not be updated.') diff --git a/zaqar/transport/wsgi/v1_0/pools.py b/zaqar/transport/wsgi/v1_0/pools.py index 48b51b27a..c1e53cc5b 100644 --- a/zaqar/transport/wsgi/v1_0/pools.py +++ b/zaqar/transport/wsgi/v1_0/pools.py @@ -38,7 +38,6 @@ registered, there is an optional field:: import falcon import jsonschema from oslo_log import log -import six from zaqar.common.api.schemas import pools as schema from zaqar.common import utils as common_utils @@ -144,7 +143,7 @@ class Resource(object): except errors.PoolDoesNotExist as ex: LOG.debug(ex) - raise wsgi_errors.HTTPNotFound(six.text_type(ex)) + raise wsgi_errors.HTTPNotFound(str(ex)) data['href'] = request.path @@ -180,7 +179,7 @@ class Resource(object): response.location = request.path except errors.PoolAlreadyExists as e: LOG.exception('Pool "%s" already exists', pool) - raise wsgi_errors.HTTPConflict(six.text_type(e)) + raise wsgi_errors.HTTPConflict(str(e)) def on_delete(self, request, response, project_id, pool): """Deregisters a pool. @@ -232,4 +231,4 @@ class Resource(object): self._ctrl.update(pool, **fields) except errors.PoolDoesNotExist as ex: LOG.exception('Pool "%s" does not exist', pool) - raise wsgi_errors.HTTPNotFound(six.text_type(ex)) + raise wsgi_errors.HTTPNotFound(str(ex)) diff --git a/zaqar/transport/wsgi/v1_0/queues.py b/zaqar/transport/wsgi/v1_0/queues.py index 0d115e8e0..362345284 100644 --- a/zaqar/transport/wsgi/v1_0/queues.py +++ b/zaqar/transport/wsgi/v1_0/queues.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 _ @@ -101,7 +100,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'Queues could not be listed.') diff --git a/zaqar/transport/wsgi/v1_0/stats.py b/zaqar/transport/wsgi/v1_0/stats.py index 00fae43ed..93552aeef 100644 --- a/zaqar/transport/wsgi/v1_0/stats.py +++ b/zaqar/transport/wsgi/v1_0/stats.py @@ -14,7 +14,6 @@ # limitations under the License. from oslo_log import log as logging -import six from zaqar.i18n import _ from zaqar.storage import errors as storage_errors @@ -65,7 +64,7 @@ class Resource(object): resp.body = utils.to_json(resp_dict) 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'Queue stats could not be read.') diff --git a/zaqar/transport/wsgi/v1_1/claims.py b/zaqar/transport/wsgi/v1_1/claims.py index 2b55aa84d..7aacec822 100644 --- a/zaqar/transport/wsgi/v1_1/claims.py +++ b/zaqar/transport/wsgi/v1_1/claims.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 _ @@ -88,7 +87,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'Claim could not be created.') @@ -137,7 +136,7 @@ class ItemResource(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'Claim could not be queried.') LOG.exception(description) @@ -174,11 +173,11 @@ class ItemResource(object): except validation.ValidationFailed as ex: LOG.debug(ex) - raise wsgi_errors.HTTPBadRequestAPI(six.text_type(ex)) + raise wsgi_errors.HTTPBadRequestAPI(str(ex)) 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'Claim could not be updated.') diff --git a/zaqar/transport/wsgi/v1_1/flavors.py b/zaqar/transport/wsgi/v1_1/flavors.py index 918561369..b39ebda51 100644 --- a/zaqar/transport/wsgi/v1_1/flavors.py +++ b/zaqar/transport/wsgi/v1_1/flavors.py @@ -16,7 +16,6 @@ import falcon import jsonschema from oslo_log import log -import six from zaqar.common.api.schemas.v1_1 import flavors as schema from zaqar.common import utils as common_utils @@ -122,7 +121,7 @@ class Resource(object): detailed=detailed) except errors.FlavorDoesNotExist as ex: LOG.debug(ex) - raise wsgi_errors.HTTPNotFound(six.text_type(ex)) + raise wsgi_errors.HTTPNotFound(str(ex)) data['href'] = request.path @@ -200,4 +199,4 @@ class Resource(object): self._ctrl.update(flavor, project=project_id, **fields) except errors.FlavorDoesNotExist as ex: LOG.exception('Flavor "%s" does not exist', flavor) - raise wsgi_errors.HTTPNotFound(six.text_type(ex)) + raise wsgi_errors.HTTPNotFound(str(ex)) diff --git a/zaqar/transport/wsgi/v1_1/messages.py b/zaqar/transport/wsgi/v1_1/messages.py index eff6111a2..374d07535 100644 --- a/zaqar/transport/wsgi/v1_1/messages.py +++ b/zaqar/transport/wsgi/v1_1/messages.py @@ -15,7 +15,6 @@ import falcon from oslo_log import log as logging -import six from zaqar.common import decorators from zaqar.common.transport.wsgi import helpers as wsgi_helpers @@ -68,7 +67,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'Message could not be retrieved.') @@ -110,7 +109,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 storage_errors.QueueDoesNotExist as ex: LOG.debug(ex) @@ -159,7 +158,7 @@ class CollectionResource(object): self._validate.message_length(req.content_length) except validation.ValidationFailed as ex: LOG.debug(ex) - raise wsgi_errors.HTTPBadRequestAPI(six.text_type(ex)) + raise wsgi_errors.HTTPBadRequestAPI(str(ex)) # Deserialize and validate the incoming messages document = wsgi_utils.deserialize(req.stream, req.content_length) @@ -186,11 +185,11 @@ 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 storage_errors.DoesNotExist as ex: LOG.debug(ex) - raise wsgi_errors.HTTPNotFound(six.text_type(ex)) + raise wsgi_errors.HTTPNotFound(str(ex)) except storage_errors.MessageConflict: description = _(u'No messages could be enqueued.') @@ -245,7 +244,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)) if ids: resp.status = self._delete_messages_by_id(queue_name, ids, @@ -312,7 +311,7 @@ class ItemResource(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'Message could not be retrieved.') diff --git a/zaqar/transport/wsgi/v1_1/pools.py b/zaqar/transport/wsgi/v1_1/pools.py index 2d65a955d..0f47c6ff2 100644 --- a/zaqar/transport/wsgi/v1_1/pools.py +++ b/zaqar/transport/wsgi/v1_1/pools.py @@ -39,7 +39,6 @@ registered, there is an optional field: import falcon import jsonschema from oslo_log import log -import six from zaqar.common.api.schemas import pools as schema from zaqar.common import utils as common_utils @@ -148,7 +147,7 @@ class Resource(object): except errors.PoolDoesNotExist as ex: LOG.debug(ex) - raise wsgi_errors.HTTPNotFound(six.text_type(ex)) + raise wsgi_errors.HTTPNotFound(str(ex)) data['href'] = request.path @@ -184,10 +183,10 @@ class Resource(object): except errors.PoolCapabilitiesMismatch as e: title = _(u'Unable to create pool') LOG.exception(title) - raise falcon.HTTPBadRequest(title, six.text_type(e)) + raise falcon.HTTPBadRequest(title, str(e)) except errors.PoolAlreadyExists as e: LOG.exception('Pool "%s" already exists', pool) - raise wsgi_errors.HTTPConflict(six.text_type(e)) + raise wsgi_errors.HTTPConflict(str(e)) def on_delete(self, request, response, project_id, pool): """Deregisters a pool. @@ -249,4 +248,4 @@ class Resource(object): self._ctrl.update(pool, **fields) except errors.PoolDoesNotExist as ex: LOG.exception('Pool "%s" does not exist', pool) - raise wsgi_errors.HTTPNotFound(six.text_type(ex)) + raise wsgi_errors.HTTPNotFound(str(ex)) diff --git a/zaqar/transport/wsgi/v1_1/queues.py b/zaqar/transport/wsgi/v1_1/queues.py index d0788edf5..504568fa5 100644 --- a/zaqar/transport/wsgi/v1_1/queues.py +++ b/zaqar/transport/wsgi/v1_1/queues.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 _ @@ -46,7 +45,7 @@ class ItemResource(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'Queue metadata could not be retrieved.') @@ -73,7 +72,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._queue_controller.create(queue_name, @@ -82,7 +81,7 @@ class ItemResource(object): except storage_errors.FlavorDoesNotExist as ex: LOG.exception('"%s" does not exist', queue_name) - raise wsgi_errors.HTTPBadRequestAPI(six.text_type(ex)) + raise wsgi_errors.HTTPBadRequestAPI(str(ex)) except Exception: description = _(u'Queue could not be created.') @@ -132,7 +131,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'Queues could not be listed.') diff --git a/zaqar/transport/wsgi/v1_1/stats.py b/zaqar/transport/wsgi/v1_1/stats.py index d1bf76bc6..6295901bd 100644 --- a/zaqar/transport/wsgi/v1_1/stats.py +++ b/zaqar/transport/wsgi/v1_1/stats.py @@ -14,7 +14,6 @@ # limitations under the License. from oslo_log import log as logging -import six from zaqar.i18n import _ from zaqar.storage import errors as storage_errors @@ -66,7 +65,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'Queue stats could not be read.')