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', {})