summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbst-marge-bot <marge-bot@buildstream.build>2020-08-29 09:45:21 +0000
committerbst-marge-bot <marge-bot@buildstream.build>2020-08-29 09:45:21 +0000
commit718e60f771a406936ad8004a7422161241ef6eec (patch)
treeeaf867e01181af27c616c2565f853fcd3c9e8f99
parent94ee11c0b50c20918a7000afccded4227c0ffd63 (diff)
parent274002cf9433881df6d478d29dd0d028f25bfb46 (diff)
downloadbuildstream-718e60f771a406936ad8004a7422161241ef6eec.tar.gz
Merge branch 'bschubert/remove-urllib-warnings' into 'master'
downloadablefilesource: Remove deprecated methods in python3.8 See merge request BuildStream/buildstream!2046
-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)