diff options
author | Jason R. Coombs <jaraco@jaraco.com> | 2014-07-05 15:06:51 -0400 |
---|---|---|
committer | Jason R. Coombs <jaraco@jaraco.com> | 2014-07-05 15:06:51 -0400 |
commit | b49435397a5094f94678adf3549cc8941aa469b7 (patch) | |
tree | b123bdd63482393ba1e2859364920f40a3d9f71d /setuptools/svn_utils.py | |
parent | 5b865b1b6e23379d23aa80e74adb38db8b14b6ca (diff) | |
download | external_python_setuptools-b49435397a5094f94678adf3549cc8941aa469b7.tar.gz external_python_setuptools-b49435397a5094f94678adf3549cc8941aa469b7.tar.bz2 external_python_setuptools-b49435397a5094f94678adf3549cc8941aa469b7.zip |
Use six for Python 2 compatibility
--HG--
branch : feature/issue-229
extra : source : 7b1997ececc5772798ce33a0f8e77387cb55a977
Diffstat (limited to 'setuptools/svn_utils.py')
-rw-r--r-- | setuptools/svn_utils.py | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/setuptools/svn_utils.py b/setuptools/svn_utils.py index 2dcfd899..65e4b815 100644 --- a/setuptools/svn_utils.py +++ b/setuptools/svn_utils.py @@ -8,14 +8,11 @@ import locale import codecs
import unicodedata
import warnings
-from setuptools.compat import unicode, PY2
from setuptools.py31compat import TemporaryDirectory
from xml.sax.saxutils import unescape
-try:
- import urlparse
-except ImportError:
- import urllib.parse as urlparse
+import six
+from six.moves import urllib
from subprocess import Popen as _Popen, PIPE as _PIPE
@@ -60,7 +57,7 @@ def _get_target_property(target): def _get_xml_data(decoded_str):
- if PY2:
+ if six.PY2:
#old versions want an encoded string
data = decoded_str.encode('utf-8')
else:
@@ -118,7 +115,7 @@ def decode_as_string(text, encoding=None): if encoding is None:
encoding = _console_encoding
- if not isinstance(text, unicode):
+ if not isinstance(text, six.text_type):
text = text.decode(encoding)
text = unicodedata.normalize('NFC', text)
@@ -180,17 +177,17 @@ def parse_external_prop(lines): if not line:
continue
- if PY2:
+ if six.PY2:
#shlex handles NULLs just fine and shlex in 2.7 tries to encode
#as ascii automatiically
line = line.encode('utf-8')
line = shlex.split(line)
- if PY2:
+ if six.PY2:
line = [x.decode('utf-8') for x in line]
#EXT_FOLDERNAME is either the first or last depending on where
#the URL falls
- if urlparse.urlsplit(line[-1])[0]:
+ if urllib.parse.urlsplit(line[-1])[0]:
external = line[0]
else:
external = line[-1]
|