Remove six usage from openstack_auth package

We don't support Python 2 anymore so we don't need this
compatibility library.

Change-Id: I0ecd706af1b4432fe439472189444141853c9d0b
This commit is contained in:
Ivan Kolodyazhny 2020-01-08 22:38:31 +02:00
parent e0eb3c3912
commit 5dd2bf5fb6
4 changed files with 13 additions and 17 deletions
openstack_auth

@ -17,7 +17,6 @@ import re
from django.utils.translation import ugettext_lazy as _
from keystoneauth1 import exceptions as keystone_exceptions
from keystoneclient.v3 import client as v3_client
import six
from openstack_auth import exceptions
from openstack_auth import utils
@ -26,8 +25,7 @@ LOG = logging.getLogger(__name__)
__all__ = ['BasePlugin']
@six.add_metaclass(abc.ABCMeta)
class BasePlugin(object):
class BasePlugin(object, metaclass=abc.ABCMeta):
"""Base plugin to provide ways to log in to dashboard.
Provides a framework for keystoneclient plugins that can be used with the

@ -17,7 +17,6 @@ import logging
from django.contrib.auth import models
from django.db import models as db_models
from keystoneauth1 import exceptions as keystone_exceptions
import six
from openstack_auth import utils
@ -379,7 +378,7 @@ class User(models.AbstractBaseUser, models.AnonymousUser):
if not perm_list:
return True
for perm in perm_list:
if isinstance(perm, six.string_types):
if isinstance(perm, str):
# check that the permission matches
if not self.has_perm(perm, obj):
return False

@ -14,6 +14,7 @@
import datetime
import logging
import re
from urllib import parse
from django.conf import settings
from django.contrib import auth
@ -23,7 +24,6 @@ from keystoneauth1.identity import v3 as v3_auth
from keystoneauth1 import session
from keystoneauth1 import token_endpoint
from keystoneclient.v3 import client as client_v3
from six.moves.urllib import parse as urlparse
from openstack_auth import defaults
@ -252,7 +252,7 @@ def get_websso_url(request, auth_url, websso_auth):
def has_in_url_path(url, subs):
"""Test if any of `subs` strings is present in the `url` path."""
scheme, netloc, path, query, fragment = urlparse.urlsplit(url)
scheme, netloc, path, query, fragment = parse.urlsplit(url)
return any([sub in path for sub in subs])
@ -264,17 +264,17 @@ def url_path_replace(url, old, new, count=None):
occurrences are replaced.
"""
args = []
scheme, netloc, path, query, fragment = urlparse.urlsplit(url)
scheme, netloc, path, query, fragment = parse.urlsplit(url)
if count is not None:
args.append(count)
return urlparse.urlunsplit((
return parse.urlunsplit((
scheme, netloc, path.replace(old, new, *args), query, fragment))
def url_path_append(url, suffix):
scheme, netloc, path, query, fragment = urlparse.urlsplit(url)
scheme, netloc, path, query, fragment = parse.urlsplit(url)
path = (path + suffix).replace('//', '/')
return urlparse.urlunsplit((scheme, netloc, path, query, fragment))
return parse.urlunsplit((scheme, netloc, path, query, fragment))
def _augment_url_with_version(auth_url):
@ -316,8 +316,8 @@ def clean_up_auth_url(auth_url):
# NOTE(mnaser): This drops the query and fragment because we're only
# trying to extract the Keystone URL.
scheme, netloc, path, query, fragment = urlparse.urlsplit(auth_url)
return urlparse.urlunsplit((
scheme, netloc, path, query, fragment = parse.urlsplit(auth_url)
return parse.urlunsplit((
scheme, netloc, re.sub(r'/auth.*', '', path), '', ''))

@ -30,7 +30,6 @@ from django.views.decorators.csrf import csrf_protect
from django.views.decorators.debug import sensitive_post_parameters
from django.views.generic import edit as edit_views
from keystoneauth1 import exceptions as keystone_exceptions
import six
from openstack_auth import exceptions
from openstack_auth import forms
@ -174,7 +173,7 @@ def websso(request):
if utils.is_websso_default_redirect():
res = django_http.HttpResponseRedirect(settings.LOGIN_ERROR)
else:
msg = 'Login failed: %s' % six.text_type(exc)
msg = 'Login failed: %s' % exc
res = django_http.HttpResponseRedirect(settings.LOGIN_URL)
res.set_cookie('logout_reason', msg, max_age=10)
return res
@ -337,7 +336,7 @@ def switch_keystone_provider(request, keystone_provider=None,
unscoped_auth_ref = current_plugin.get_access_info(unscoped_auth)
except exceptions.KeystoneAuthException as exc:
msg = 'Switching to Keystone Provider %s has failed. %s' \
% (keystone_provider, (six.text_type(exc)))
% (keystone_provider, exc)
messages.error(request, msg)
if unscoped_auth_ref:
@ -346,7 +345,7 @@ def switch_keystone_provider(request, keystone_provider=None,
request, auth_url=unscoped_auth.auth_url,
token=unscoped_auth_ref.auth_token)
except exceptions.KeystoneAuthException as exc:
msg = 'Keystone provider switch failed: %s' % six.text_type(exc)
msg = 'Keystone provider switch failed: %s' % exc
res = django_http.HttpResponseRedirect(settings.LOGIN_URL)
res.set_cookie('logout_reason', msg, max_age=10)
return res