662
663
return urlparse.urlunparse(('sftp', netloc, path, '', '', ''))
664
665
def _split_url(self, url):
665
if isinstance(url, unicode):
666
# TODO: Disallow unicode urls
667
#raise InvalidURL(url, 'urls must not be unicode.')
668
url = url.encode('ascii')
669
(scheme, netloc, path, params,
670
query, fragment) = urlparse.urlparse(url, allow_fragments=False)
666
(scheme, username, password, host, port, path) = split_url(url)
671
667
assert scheme == 'sftp'
672
username = password = host = port = None
674
username, host = netloc.split('@', 1)
676
username, password = username.split(':', 1)
677
password = urllib.unquote(password)
678
username = urllib.unquote(username)
683
host, port = host.rsplit(':', 1)
687
# TODO: Should this be ConnectionError?
688
raise TransportError('%s: invalid port number' % port)
689
host = urllib.unquote(host)
691
path = urlutils.unescape(path)
693
669
# the initial slash should be removed from the path, and treated
694
670
# as a homedir relative path (the path begins with a double slash
1022
998
def get_hexdump(self):
1025
1003
server = paramiko.SFTPServer(FakeChannel(), 'sftp', StubServer(self), StubSFTPServer,
1026
1004
root=self._root, home=self._server_homedir)