[Python-modules-commits] [dulwich] 03/14: Improve python3 portability; support python3 urlparse.

Jelmer Vernooij jelmer at moszumanska.debian.org
Tue Jul 5 23:27:28 UTC 2016


This is an automated email from the git hooks/post-receive script.

jelmer pushed a commit to branch master
in repository dulwich.

commit d12ec19e3b3d8312fb63ae78043f8fb6938017dd
Author: Jelmer Vernooij <jelmer at jelmer.uk>
Date:   Tue Jul 5 22:07:10 2016 +0000

    Improve python3 portability; support python3 urlparse.
---
 dulwich/contrib/swift.py | 19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)

diff --git a/dulwich/contrib/swift.py b/dulwich/contrib/swift.py
index 8094718..0fb15e9 100644
--- a/dulwich/contrib/swift.py
+++ b/dulwich/contrib/swift.py
@@ -31,9 +31,16 @@ import zlib
 import tempfile
 import posixpath
 
-from urlparse import urlparse
+try:
+    import urlparse
+except ImportError:
+    import urllib.parse as urlparse
+
 from io import BytesIO
-from ConfigParser import ConfigParser
+try:
+    from ConfigParser import ConfigParser
+except ImportError:
+    from configparser import ConfigParser
 from geventhttpclient import HTTPClient
 
 from dulwich.greenthreads import (
@@ -274,8 +281,8 @@ class SwiftConnector(object):
                                 connection_timeout=self.http_timeout,
                                 network_timeout=self.http_timeout,
                                 headers=token_header)
-        self.base_path = str(posixpath.join(urlparse(self.storage_url).path,
-                             self.root))
+        self.base_path = str(
+            posixpath.join(urlparse.urlparse(self.storage_url).path, self.root))
 
     def swift_auth_v1(self):
         self.user = self.user.replace(";", ":")
@@ -286,7 +293,7 @@ class SwiftConnector(object):
             )
         headers = {'X-Auth-User': self.user,
                    'X-Auth-Key': self.password}
-        path = urlparse(self.auth_url).path
+        path = urlparse.urlparse(self.auth_url).path
 
         ret = auth_httpclient.request('GET', path, headers=headers)
 
@@ -318,7 +325,7 @@ class SwiftConnector(object):
             connection_timeout=self.http_timeout,
             network_timeout=self.http_timeout,
             )
-        path = urlparse(self.auth_url).path
+        path = urlparse.urlparse(self.auth_url).path
         if not path.endswith('tokens'):
             path = posixpath.join(path, 'tokens')
         ret = auth_httpclient.request('POST', path,

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/dulwich.git



More information about the Python-modules-commits mailing list