diff options
author | William Boughton <bill@boughton.eu> | 2015-09-19 17:33:12 +0200 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2015-09-23 21:46:10 +0300 |
commit | 5e9e6069e55f82b8ac60c7b03b86cc8576b473dc (patch) | |
tree | 48b7d29e0246a1228a6844dfce8e018eb21a6c51 | |
parent | 97fba9ad17a505aac1a48f679a89f1ea9e54b491 (diff) | |
download | obnam-5e9e6069e55f82b8ac60c7b03b86cc8576b473dc.tar.gz |
use urlparse for hostname, port and username
-rw-r--r-- | obnamlib/plugins/sftp_plugin.py | 29 |
1 files changed, 4 insertions, 25 deletions
diff --git a/obnamlib/plugins/sftp_plugin.py b/obnamlib/plugins/sftp_plugin.py index 5136058d..ccb13816 100644 --- a/obnamlib/plugins/sftp_plugin.py +++ b/obnamlib/plugins/sftp_plugin.py @@ -334,38 +334,17 @@ class SftpFS(obnamlib.VirtualFileSystem): @ioerror_to_oserror def reinit(self, baseurl, create=False): - scheme, netloc, path, _, _ = urlparse.urlsplit(baseurl) + p = scheme, _, path, _, _ = urlparse.urlsplit(baseurl) if scheme != 'sftp': raise WrongURLSchemeError(url=baseurl) - if '@' in netloc: - user, netloc = netloc.split('@', 1) - else: - user = None - - if ':' in netloc: - host, port = netloc.split(':', 1) - if port == '': - port = None - else: - try: - port = int(port) - except ValueError, e: - exc = InvalidPortError( - port=port, url=baseurl, error=str(e)) - logging.error(str(exc)) - raise exc - else: - host = netloc - port = None - if path.startswith('/~/'): path = path[3:] - self.host = host - self.port = port - self.user = user + self.host = p.hostname + self.port = p.port + self.user = p.username self.path = path self.create_path_if_missing = create |