summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Schubert <contact@benschubert.me>2020-08-28 13:13:10 +0000
committerBenjamin Schubert <contact@benschubert.me>2020-08-28 13:13:10 +0000
commit274002cf9433881df6d478d29dd0d028f25bfb46 (patch)
treeeaf867e01181af27c616c2565f853fcd3c9e8f99
parent94ee11c0b50c20918a7000afccded4227c0ffd63 (diff)
downloadbuildstream-bschubert/remove-urllib-warnings.tar.gz
downloadablefilesource: Remove deprecated methods in python3.8bschubert/remove-urllib-warnings
splituser and such are deprecated since python3.8 We should stop using them
-rw-r--r--src/buildstream/downloadablefilesource.py23
1 files changed, 8 insertions, 15 deletions
diff --git a/src/buildstream/downloadablefilesource.py b/src/buildstream/downloadablefilesource.py
index 7c2da1c02..2c438b033 100644
--- a/src/buildstream/downloadablefilesource.py
+++ b/src/buildstream/downloadablefilesource.py
@@ -47,16 +47,6 @@ class _NetrcFTPOpener(urllib.request.FTPHandler):
def __init__(self, netrc_config):
self.netrc = netrc_config
- def _split(self, netloc):
- userpass, hostport = urllib.parse.splituser(netloc)
- host, port = urllib.parse.splitport(hostport)
- if userpass:
- user, passwd = urllib.parse.splitpasswd(userpass)
- else:
- user = None
- passwd = None
- return host, port, user, passwd
-
def _unsplit(self, host, port, user, passwd):
if port:
host = "{}:{}".format(host, port)
@@ -68,14 +58,17 @@ class _NetrcFTPOpener(urllib.request.FTPHandler):
return host
def ftp_open(self, req):
- host, port, user, passwd = self._split(req.host)
+ uri = urllib.parse.urlparse(req.full_url)
+
+ username = uri.username
+ password = uri.password
- if user is None and self.netrc:
- entry = self.netrc.authenticators(host)
+ if uri.username is None and self.netrc:
+ entry = self.netrc.authenticators(uri.hostname)
if entry:
- user, _, passwd = entry
+ username, _, password = entry
- req.host = self._unsplit(host, port, user, passwd)
+ req.host = self._unsplit(uri.hostname, uri.port, username, password)
return super().ftp_open(req)