From 23507e6124041ed17f39db211e802495e37520e7 Mon Sep 17 00:00:00 2001 From: Jan Cholasta Date: Fri, 11 Sep 2015 13:43:28 +0200 Subject: Alias "unicode" to "str" under Python 3 The six way of doing this is to replace all occurences of "unicode" with "six.text_type". However, "unicode" is non-ambiguous and (arguably) easier to read. Also, using it makes the patches smaller, which should help with backporting. Reviewed-By: Petr Viktorin --- ipapython/dn.py | 3 +++ ipapython/dnsutil.py | 3 +++ ipapython/dogtag.py | 4 ++++ ipapython/ipaldap.py | 3 +++ ipapython/ssh.py | 5 +++++ ipapython/sysrestore.py | 5 +++++ 6 files changed, 23 insertions(+) (limited to 'ipapython') diff --git a/ipapython/dn.py b/ipapython/dn.py index a3b20121a..5a42ab37e 100644 --- a/ipapython/dn.py +++ b/ipapython/dn.py @@ -425,6 +425,9 @@ from ldap.dn import str2dn, dn2str from ldap import DECODING_ERROR import six +if six.PY3: + unicode = str + __all__ = 'AVA', 'RDN', 'DN' def _adjust_indices(start, end, length): diff --git a/ipapython/dnsutil.py b/ipapython/dnsutil.py index d190f23c7..7844d7bec 100644 --- a/ipapython/dnsutil.py +++ b/ipapython/dnsutil.py @@ -23,6 +23,9 @@ import copy import six +if six.PY3: + unicode = str + @six.python_2_unicode_compatible class DNSName(dns.name.Name): diff --git a/ipapython/dogtag.py b/ipapython/dogtag.py index fe951cf5b..305e10a71 100644 --- a/ipapython/dogtag.py +++ b/ipapython/dogtag.py @@ -25,6 +25,7 @@ import ConfigParser from urllib import urlencode import nss.nss as nss +import six from ipalib import api, errors from ipalib.errors import NetworkError @@ -33,6 +34,9 @@ from ipapython import nsslib, ipautil from ipaplatform.paths import paths from ipapython.ipa_log_manager import * +if six.PY3: + unicode = str + # IPA can use either Dogtag version 9 or 10. # # Install tools should use the constants from install_constants, so that they diff --git a/ipapython/ipaldap.py b/ipapython/ipaldap.py index 837d57c3b..9c78dbf69 100644 --- a/ipapython/ipaldap.py +++ b/ipapython/ipaldap.py @@ -47,6 +47,9 @@ from ipapython.ipa_log_manager import log_mgr from ipapython.dn import DN, RDN from ipapython.dnsutil import DNSName +if six.PY3: + unicode = str + # Global variable to define SASL auth SASL_GSSAPI = ldap.sasl.sasl({}, 'GSSAPI') diff --git a/ipapython/ssh.py b/ipapython/ssh.py index c95488928..c8d8306f2 100644 --- a/ipapython/ssh.py +++ b/ipapython/ssh.py @@ -28,6 +28,11 @@ import struct from hashlib import md5, sha1 from hashlib import sha256 #pylint: disable=E0611 +import six + +if six.PY3: + unicode = str + __all__ = ['SSHPublicKey'] OPENSSH_BASE_REGEX = re.compile(r'^[\t ]*(?P[^\x00\n\r]+?) [\t ]*(?P[^\x00\n\r]+?)(?:[\t ]+(?P[^\x00\n\r]*?)[\t ]*)?$') diff --git a/ipapython/sysrestore.py b/ipapython/sysrestore.py index 24ddc9a47..8ce8e4b7a 100644 --- a/ipapython/sysrestore.py +++ b/ipapython/sysrestore.py @@ -31,10 +31,15 @@ import ConfigParser import random import string +import six + from ipapython import ipautil from ipaplatform.tasks import tasks from ipaplatform.paths import paths +if six.PY3: + unicode = str + SYSRESTORE_PATH = paths.TMP SYSRESTORE_INDEXFILE = "sysrestore.index" SYSRESTORE_STATEFILE = "sysrestore.state" -- cgit