Py3: Replace six.text_type with str

On Python 3, six.text_type (singular) is an alias for str.

See: https://pagure.io/freeipa/issue/7715
Signed-off-by: Christian Heimes <cheimes@redhat.com>
Reviewed-By: Florence Blanc-Renaud <frenaud@redhat.com>
This commit is contained in:
Christian Heimes
2018-09-27 16:11:18 +02:00
parent ea396528b7
commit 61156b0a50
15 changed files with 25 additions and 31 deletions
+1 -1
View File
@@ -1,7 +1,7 @@
import six
from ipalib import _
if six.PY3:
unicode = six.text_type
unicode = str
# Both constants can be used as masks against trust direction
# because bi-directional has two lower bits set.
+2 -2
View File
@@ -84,7 +84,7 @@ def lookup_ca_subject(api, subject_base):
# installutils.default_ca_subject_dn is NOT used here in
# case the default changes in the future.
ca_subject = DN(('CN', 'Certificate Authority'), subject_base)
return six.text_type(ca_subject)
return str(ca_subject)
def set_subject_base_in_config(subject_base):
@@ -130,7 +130,7 @@ def install_check(standalone, replica_config, options):
_api = api if standalone else options._remote_api
# for replica-install the knobs cannot be written, hence leading '_'
options._subject_base = six.text_type(replica_config.subject_base)
options._subject_base = str(replica_config.subject_base)
options._ca_subject = lookup_ca_subject(_api, options._subject_base)
if replica_config is not None and not replica_config.setup_ca:
+2 -3
View File
@@ -38,7 +38,6 @@ import syslog
import time
import tempfile
import six
# pylint: disable=import-error
from six.moves.configparser import RawConfigParser
# pylint: enable=import-error
@@ -548,7 +547,7 @@ class CAInstance(DogtagInstance):
# Directory server
config.set("CA", "pki_ds_ldap_port", "389")
config.set("CA", "pki_ds_password", self.dm_password)
config.set("CA", "pki_ds_base_dn", six.text_type(self.basedn))
config.set("CA", "pki_ds_base_dn", str(self.basedn))
config.set("CA", "pki_ds_database", "ipaca")
if self.use_ldaps:
@@ -2038,7 +2037,7 @@ class MSCSTemplateV1(MSCSTemplate):
if len(parts) > 1:
raise ValueError(
"Cannot specify certificate template version when using name.")
self.asn1obj = char.BMPString(six.text_type(parts[0]))
self.asn1obj = char.BMPString(str(parts[0]))
class MSCSTemplateV2(MSCSTemplate):
+1 -1
View File
@@ -143,7 +143,7 @@ def install_check(standalone, api, replica, options, hostname):
dnsutil.check_zone_overlap(reverse_zone)
except ValueError as e:
if options.force or options.allow_zone_overlap:
logger.warning('%s', six.text_type(e))
logger.warning('%s', str(e))
else:
raise e
+1 -2
View File
@@ -26,7 +26,6 @@ import shutil
import tempfile
import base64
import six
# pylint: disable=import-error
from six.moves.configparser import RawConfigParser
# pylint: enable=import-error
@@ -203,7 +202,7 @@ class KRAInstance(DogtagInstance):
# Directory server
config.set("KRA", "pki_ds_ldap_port", "389")
config.set("KRA", "pki_ds_password", self.dm_password)
config.set("KRA", "pki_ds_base_dn", six.text_type(self.basedn))
config.set("KRA", "pki_ds_base_dn", str(self.basedn))
config.set("KRA", "pki_ds_database", "ipaca")
config.set("KRA", "pki_ds_create_new_db", "False")
+3 -3
View File
@@ -173,12 +173,12 @@ def _acl_make_request(principal_type, principal, ca_id, profile_id):
groups = []
if principal_type == 'user':
user_obj = api.Command.user_show(
six.text_type(principal.username))['result']
str(principal.username))['result']
groups = user_obj.get('memberof_group', [])
groups += user_obj.get('memberofindirect_group', [])
elif principal_type == 'host':
host_obj = api.Command.host_show(
six.text_type(principal.hostname))['result']
str(principal.hostname))['result']
groups = host_obj.get('memberof_hostgroup', [])
groups += host_obj.get('memberofindirect_hostgroup', [])
req.user.groups = sorted(set(groups))
@@ -957,7 +957,7 @@ class cert_request(Create, BaseCertMethod, VirtualCommand):
if add:
if principal.is_service and not principal.is_host:
self.api.Command.service_add(
six.text_type(principal), all=True, force=True)
str(principal), all=True, force=True)
return self.lookup_principal(principal) # we want an LDAPEntry
else:
if principal.is_user:
+1 -1
View File
@@ -2165,7 +2165,7 @@ class DNSZoneBase_add(LDAPCreate):
try:
check_zone_overlap(keys[-1], raise_on_error=False)
except ValueError as e:
raise errors.InvocationError(six.text_type(e))
raise errors.InvocationError(str(e))
return dn
+1 -1
View File
@@ -546,7 +546,7 @@ class service(LDAPObject):
def get_dn(self, *keys, **kwargs):
key = keys[0]
if isinstance(key, six.text_type):
if isinstance(key, str):
key = kerberos.Principal(key)
key = unicode(normalize_principal(key))