clean up unnecessary usage of the six library (awx only supports py3)

This commit is contained in:
Ryan Petrello
2019-01-24 17:57:08 -05:00
parent 68950d56ca
commit daeeaf413a
58 changed files with 238 additions and 311 deletions

View File

@@ -6,7 +6,6 @@ import logging
import uuid
import ldap
import six
# Django
from django.dispatch import receiver
@@ -258,7 +257,7 @@ class TowerSAMLIdentityProvider(BaseSAMLIdentityProvider):
def get_user_permanent_id(self, attributes):
uid = attributes[self.conf.get('attr_user_permanent_id', OID_USERID)]
if isinstance(uid, six.string_types):
if isinstance(uid, str):
return uid
return uid[0]
@@ -277,7 +276,7 @@ class TowerSAMLIdentityProvider(BaseSAMLIdentityProvider):
logger.warn("Could not map user detail '%s' from SAML attribute '%s'; "
"update SOCIAL_AUTH_SAML_ENABLED_IDPS['%s']['%s'] with the correct SAML attribute.",
conf_key[5:], key, self.name, conf_key)
return six.text_type(value) if value is not None else value
return str(value) if value is not None else value
class SAMLAuth(BaseSAMLAuth):
@@ -330,10 +329,10 @@ def _update_m2m_from_groups(user, ldap_user, rel, opts, remove=True):
elif opts is True:
should_add = True
else:
if isinstance(opts, six.string_types):
if isinstance(opts, str):
opts = [opts]
for group_dn in opts:
if not isinstance(group_dn, six.string_types):
if not isinstance(group_dn, str):
continue
if ldap_user._get_groups().is_member_of(group_dn):
should_add = True
@@ -366,9 +365,9 @@ def on_populate_user(sender, **kwargs):
field_len = len(getattr(user, field))
if field_len > max_len:
setattr(user, field, getattr(user, field)[:max_len])
logger.warn(six.text_type(
'LDAP user {} has {} > max {} characters'
).format(user.username, field, max_len))
logger.warn(
'LDAP user {} has {} > max {} characters'.format(user.username, field, max_len)
)
# Update organization membership based on group memberships.
org_map = getattr(backend.settings, 'ORGANIZATION_MAP', {})

View File

@@ -5,7 +5,6 @@
import urllib.parse
# Six
import six
# Django
from django.conf import settings
@@ -83,7 +82,7 @@ class SocialAuthMiddleware(SocialAuthExceptionMiddleware):
return redirect(url)
def get_message(self, request, exception):
msg = six.text_type(exception)
msg = str(exception)
if msg and msg[-1] not in '.?!':
msg = msg + '.'
return msg

View File

@@ -5,7 +5,6 @@
import re
import logging
import six
# Python Social Auth
from social_core.exceptions import AuthException
@@ -67,10 +66,10 @@ def _update_m2m_from_expression(user, rel, expr, remove=True):
elif expr is True:
should_add = True
else:
if isinstance(expr, (six.string_types, type(re.compile('')))):
if isinstance(expr, (str, type(re.compile('')))):
expr = [expr]
for ex in expr:
if isinstance(ex, six.string_types):
if isinstance(ex, str):
if user.username == ex or user.email == ex:
should_add = True
elif isinstance(ex, type(re.compile(''))):