From 772db810a02ee4e275b23449f06aa981095df781 Mon Sep 17 00:00:00 2001 From: melissaml Date: Wed, 14 Oct 2020 17:37:17 +0800 Subject: [PATCH] [Part1] Remove six We don't need this in a Python 3-only world. Remove six in follows: 1. zaqar/common/transport/wsgi/helpers.py 2. zaqar/common/urls.py 3. zaqar/common/utils.py 4. zaqar/notification/notifier.py 5. zaqar/notification/tasks/mailto.py Change-Id: Iae6d4f415b215b9fdf675a0fcf00282fc98d58b7 --- lower-constraints.txt | 1 - requirements.txt | 1 - zaqar/common/transport/wsgi/helpers.py | 7 +------ zaqar/common/urls.py | 12 ++++++------ zaqar/common/utils.py | 2 -- zaqar/notification/notifier.py | 2 +- zaqar/notification/tasks/mailto.py | 2 +- 7 files changed, 9 insertions(+), 18 deletions(-) diff --git a/lower-constraints.txt b/lower-constraints.txt index 28569c4c5..b7d718268 100644 --- a/lower-constraints.txt +++ b/lower-constraints.txt @@ -51,7 +51,6 @@ requests==2.14.2 requestsexceptions==1.2.0 restructuredtext-lint==1.1.1 rfc3986==0.3.1 -six==1.10.0 SQLAlchemy==1.3.19 sqlalchemy-migrate==0.11.0 stestr==2.0.0 diff --git a/requirements.txt b/requirements.txt index 515630f30..693ba508b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -15,7 +15,6 @@ python-memcached>=1.56 # PSF python-swiftclient>=3.2.0 # Apache-2.0 WebOb>=1.7.1 # MIT stevedore>=1.20.0 # Apache-2.0 -six>=1.10.0 # MIT oslo.cache>=1.26.0 # Apache-2.0 oslo.config>=5.2.0 # Apache-2.0 oslo.context>=2.19.2 # Apache-2.0 diff --git a/zaqar/common/transport/wsgi/helpers.py b/zaqar/common/transport/wsgi/helpers.py index 5d4448d42..8ffd3e55f 100644 --- a/zaqar/common/transport/wsgi/helpers.py +++ b/zaqar/common/transport/wsgi/helpers.py @@ -21,7 +21,6 @@ import uuid import falcon from oslo_log import log as logging -import six from zaqar.common import urls from zaqar import context @@ -131,7 +130,7 @@ def require_client_id(validate, req, resp, params): description = _(u'Malformed hexadecimal UUID.') raise falcon.HTTPBadRequest('Wrong UUID value', description) except validation.ValidationFailed as ex: - raise falcon.HTTPBadRequest(six.text_type(ex)) + raise falcon.HTTPBadRequest(str(ex)) else: # NOTE(wanghao): Since we changed the get_client_uuid to support # other format of client id, so need to check the uuid here for @@ -174,8 +173,6 @@ def validate_queue_identification(validate, req, resp, params): except validation.ValidationFailed: project = params['project_id'] queue = params['queue_name'] - if six.PY2: - queue = queue.decode('utf-8', 'replace') LOG.debug(u'Invalid queue name "%(queue)s" submitted for ' u'project: %(project)s', @@ -308,8 +305,6 @@ def validate_topic_identification(validate, req, resp, params): except validation.ValidationFailed: project = params['project_id'] queue = params['topic_name'] - if six.PY2: - queue = queue.decode('utf-8', 'replace') LOG.debug(u'Invalid topic name "%(topic)s" submitted for ' u'project: %(project)s', diff --git a/zaqar/common/urls.py b/zaqar/common/urls.py index afe7c08a2..774515079 100644 --- a/zaqar/common/urls.py +++ b/zaqar/common/urls.py @@ -18,7 +18,6 @@ import hashlib import hmac from oslo_utils import timeutils -import six _DATE_FORMAT = '%Y-%m-%dT%H:%M:%S' @@ -78,12 +77,13 @@ def create_signed_url(key, paths, project=None, expires=None, methods=None): methods = sorted(methods) paths = sorted(paths) expires_str = expires.strftime(_DATE_FORMAT) - hmac_body = six.b(r'%(paths)s\n%(methods)s\n%(project)s\n%(expires)s' % - {'paths': ','.join(paths), 'methods': ','.join(methods), - 'project': project, 'expires': expires_str}) + hmac_body = (r'%(paths)s\n%(methods)s\n%(project)s\n%(expires)s' % + {'paths': ','.join(paths), 'methods': ','.join(methods), + 'project': project, 'expires': + expires_str}).encode('utf-8') - if not isinstance(key, six.binary_type): - key = six.binary_type(key.encode('utf-8')) + if not isinstance(key, bytes): + key = bytes(key.encode('utf-8')) return {'paths': paths, 'methods': methods, diff --git a/zaqar/common/utils.py b/zaqar/common/utils.py index 8c605452c..a9408dd5a 100644 --- a/zaqar/common/utils.py +++ b/zaqar/common/utils.py @@ -16,7 +16,6 @@ """utils: general-purpose utilities.""" from oslo_config import cfg -import six def fields(d, names, pred=lambda x: True, @@ -41,7 +40,6 @@ def fields(d, names, pred=lambda x: True, _pytype_to_cfgtype = { - six.text_type: cfg.StrOpt, str: cfg.StrOpt, int: cfg.IntOpt, bool: cfg.BoolOpt, diff --git a/zaqar/notification/notifier.py b/zaqar/notification/notifier.py index 9e94f7ef7..b900958be 100644 --- a/zaqar/notification/notifier.py +++ b/zaqar/notification/notifier.py @@ -18,7 +18,7 @@ from stevedore import driver import futurist from oslo_log import log as logging -from six.moves import urllib_parse +from urllib import parse as urllib_parse from zaqar.common import auth from zaqar.common import urls diff --git a/zaqar/notification/tasks/mailto.py b/zaqar/notification/tasks/mailto.py index 3df4000e0..46fdc5f40 100644 --- a/zaqar/notification/tasks/mailto.py +++ b/zaqar/notification/tasks/mailto.py @@ -15,9 +15,9 @@ from email.mime import text import json -from six.moves import urllib_parse import smtplib import subprocess +from urllib import parse as urllib_parse from oslo_log import log as logging