2 Utilities to help handle urls
6 def normalize_url(url, scheme='http'):
8 Make sure there is a http at the head of what should be a url
10 # not much to do with None except avoid an exception
15 if url.find(scheme_sep) != -1:
18 return scheme + scheme_sep + url
20 SSHURL = collections.namedtuple("SSHURL", "user host path")
22 def parse_ssh_url(url):
23 """Parse scp-style username, host and path.
25 # simple initialization
32 raise ValueError("Invalid SSH URL: need <host>:<path>")
36 user_host = url[:colon]
37 atsign = user_host.find('@')
39 user = user_host[:atsign]
40 host = user_host[atsign+1:]
44 return SSHURL(user, host, path)