From 50b8688e7e073a89a01dd06cb93e1df498c38d48 Mon Sep 17 00:00:00 2001
From: Tim Burke <tim.burke@gmail.com>
Date: Mon, 8 Apr 2019 15:02:31 -0700
Subject: [PATCH] Use stdlib urlparse

The wrapper swift wrote for IPv6 support hasn't been necessary since
dropping support for Python 2.6 back in 2015. See

- https://github.com/openstack/swift/commit/67de0c8
- https://github.com/python/cpython/commit/8c6d9d7
- https://bugs.python.org/issue2987

Drive-by: use range() since xrange() doesn't exist on py3 and we're only
going to 16; clean up an invalid escape sequence.

Change-Id: Ib124cb27edd4c3defdb4a9e2404dcdcb71e6dd99
---
 bin/swauth-add-account         | 2 +-
 bin/swauth-add-user            | 2 +-
 bin/swauth-cleanup-tokens      | 4 ++--
 bin/swauth-delete-account      | 2 +-
 bin/swauth-delete-user         | 2 +-
 bin/swauth-list                | 2 +-
 bin/swauth-prep                | 2 +-
 bin/swauth-set-account-service | 2 +-
 swauth/middleware.py           | 2 +-
 9 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/bin/swauth-add-account b/bin/swauth-add-account
index 012ab20..f33e491 100755
--- a/bin/swauth-add-account
+++ b/bin/swauth-add-account
@@ -20,8 +20,8 @@ from optparse import OptionParser
 from sys import argv
 from sys import exit
 
+from six.moves.urllib.parse import urlparse
 from swift.common.bufferedhttp import http_connect_raw as http_connect
-from swift.common.utils import urlparse
 
 
 if __name__ == '__main__':
diff --git a/bin/swauth-add-user b/bin/swauth-add-user
index 4b51f7f..f0c79be 100755
--- a/bin/swauth-add-user
+++ b/bin/swauth-add-user
@@ -20,8 +20,8 @@ from optparse import OptionParser
 from sys import argv
 from sys import exit
 
+from six.moves.urllib.parse import urlparse
 from swift.common.bufferedhttp import http_connect_raw as http_connect
-from swift.common.utils import urlparse
 
 
 if __name__ == '__main__':
diff --git a/bin/swauth-cleanup-tokens b/bin/swauth-cleanup-tokens
index 5247134..60e6bd8 100755
--- a/bin/swauth-cleanup-tokens
+++ b/bin/swauth-cleanup-tokens
@@ -99,7 +99,7 @@ if __name__ == '__main__':
         if options.verbose:
             print('Done.')
         exit(0)
-    for x in xrange(16):
+    for x in range(16):
         container = '.token_%x' % x
         marker = None
         while True:
@@ -132,7 +132,7 @@ if __name__ == '__main__':
                         if err.http_status != 404:
                             raise
                     continue
-                last_modified = datetime(*map(int, re.split('[^\d]',
+                last_modified = datetime(*map(int, re.split(r'[^\d]',
                                               obj['last_modified'])[:-1]))
                 ago = datetime.utcnow() - last_modified
                 if ago > options.token_life:
diff --git a/bin/swauth-delete-account b/bin/swauth-delete-account
index 380f315..724597d 100755
--- a/bin/swauth-delete-account
+++ b/bin/swauth-delete-account
@@ -20,8 +20,8 @@ from optparse import OptionParser
 from sys import argv
 from sys import exit
 
+from six.moves.urllib.parse import urlparse
 from swift.common.bufferedhttp import http_connect_raw as http_connect
-from swift.common.utils import urlparse
 
 
 if __name__ == '__main__':
diff --git a/bin/swauth-delete-user b/bin/swauth-delete-user
index eb585af..c1cb209 100755
--- a/bin/swauth-delete-user
+++ b/bin/swauth-delete-user
@@ -20,8 +20,8 @@ from optparse import OptionParser
 from sys import argv
 from sys import exit
 
+from six.moves.urllib.parse import urlparse
 from swift.common.bufferedhttp import http_connect_raw as http_connect
-from swift.common.utils import urlparse
 
 
 if __name__ == '__main__':
diff --git a/bin/swauth-list b/bin/swauth-list
index edeb2ca..53916e2 100755
--- a/bin/swauth-list
+++ b/bin/swauth-list
@@ -21,8 +21,8 @@ from optparse import OptionParser
 from sys import argv
 from sys import exit
 
+from six.moves.urllib.parse import urlparse
 from swift.common.bufferedhttp import http_connect_raw as http_connect
-from swift.common.utils import urlparse
 
 
 if __name__ == '__main__':
diff --git a/bin/swauth-prep b/bin/swauth-prep
index 6801b5e..70fc1f0 100755
--- a/bin/swauth-prep
+++ b/bin/swauth-prep
@@ -20,8 +20,8 @@ from optparse import OptionParser
 from sys import argv
 from sys import exit
 
+from six.moves.urllib.parse import urlparse
 from swift.common.bufferedhttp import http_connect_raw as http_connect
-from swift.common.utils import urlparse
 
 
 if __name__ == '__main__':
diff --git a/bin/swauth-set-account-service b/bin/swauth-set-account-service
index a8f8089..ff45e6f 100755
--- a/bin/swauth-set-account-service
+++ b/bin/swauth-set-account-service
@@ -21,8 +21,8 @@ from optparse import OptionParser
 from sys import argv
 from sys import exit
 
+from six.moves.urllib.parse import urlparse
 from swift.common.bufferedhttp import http_connect_raw as http_connect
-from swift.common.utils import urlparse
 
 
 if __name__ == '__main__':
diff --git a/swauth/middleware.py b/swauth/middleware.py
index 92d4a48..d0f97ac 100644
--- a/swauth/middleware.py
+++ b/swauth/middleware.py
@@ -21,6 +21,7 @@ from httplib import HTTPConnection
 from httplib import HTTPSConnection
 import json
 import six
+from six.moves.urllib.parse import urlparse
 import swift
 from time import gmtime
 from time import strftime
@@ -56,7 +57,6 @@ from swift.common.utils import HASH_PATH_PREFIX
 from swift.common.utils import HASH_PATH_SUFFIX
 from swift.common.utils import split_path
 from swift.common.utils import TRUE_VALUES
-from swift.common.utils import urlparse
 import swift.common.wsgi
 
 import swauth.authtypes