Commit da71a8ed authored by Thomas Gambier's avatar Thomas Gambier 🚴🏼 Committed by Julien Muchembled

download: don't use splitport and splituser

They are deprecated since Python 3.8

Rebase instructions:
- split and fixup commits
    171c2459
    c9e9b267
parent 2789ebd1
......@@ -21,13 +21,13 @@ except ImportError:
try:
# Python 3
from urllib.error import HTTPError
from urllib.request import Request, splitport, splituser, urlopen
from urllib.request import Request, urlopen
from urllib.parse import urlparse, urlunparse
except ImportError:
# Python 2
from urlparse import urlparse
from urlparse import urlunparse
from urllib2 import HTTPError, Request, splitport, splituser, urlopen
from urllib2 import HTTPError, Request, urlopen
from zc.buildout.easy_install import realpath
from base64 import b64encode
......@@ -271,14 +271,15 @@ class Download(object):
return '%s:%s' % (url_host, url_port)
def urlretrieve(self, url, tmp_path):
scheme, netloc, path, params, query, frag = urlparse(url)
parsed_url = urlparse(url)
req = url
while scheme in ('http', 'https'): # not a loop
auth, host = splituser(netloc)
if auth:
url = urlunparse((scheme, host, path, params, query, frag))
while parsed_url.scheme in ('http', 'https'): # not a loop
auth_host = parsed_url.netloc.rsplit('@', 1)
if len(auth_host) > 1:
auth = auth_host[0]
url = parsed_url._replace(netloc=auth_host[1]).geturl()
else:
auth = netrc.authenticators(splitport(host)[0])
auth = netrc.authenticators(parsed_url.hostname)
if not auth:
break
auth = '{0}:{2}'.format(*auth)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment