662
663
return urlparse.urlunparse(('sftp', netloc, path, '', '', ''))
664
665
def _split_url(self, url):
665
if isinstance(url, unicode):
666
url = url.encode('utf-8')
667
(scheme, netloc, path, params,
668
query, fragment) = urlparse.urlparse(url, allow_fragments=False)
666
(scheme, username, password, host, port, path) = split_url(url)
669
667
assert scheme == 'sftp'
670
username = password = host = port = None
672
username, host = netloc.split('@', 1)
674
username, password = username.split(':', 1)
675
password = urllib.unquote(password)
676
username = urllib.unquote(username)
681
host, port = host.rsplit(':', 1)
685
# TODO: Should this be ConnectionError?
686
raise TransportError('%s: invalid port number' % port)
687
host = urllib.unquote(host)
689
path = urllib.unquote(path)
691
669
# the initial slash should be removed from the path, and treated
692
670
# as a homedir relative path (the path begins with a double slash