Oops, sorry missed something converting from a method to a function:

Here is a function that I wrote to do that.  It doesn't do
exactly what you want, but might save you some time.

def spliturl(url):
    '''
    spliturl - method to split composite url into its component parts
               ftp://username:[EMAIL PROTECTED]/dav

    gets split into:

    scheme.............ftp
    domain.............www.domain.com
    username...........username
    password...........password
    rootfolder........./dav
    port...............None

    returns list of 6 strings/None containing above listed variables
    '''
    parts=urlparse.urlsplit(url)
    scheme=parts[0]
    usernameandpassword, domain=urllib.splituser(parts[1])
    username, password=urllib.splitpasswd(usernameandpassword)
    rootfolder, port=urllib.splitport(parts[2])
    if port is not None: port=int(port)
    return [scheme, domain, username, password, rootfolder, port]

-Larry Bates

metaperl wrote:
> The urlparse with Python 2.4.3 includes the user and pass in the site
> aspect of its parse:
> 
>>>> scheme, site, path, parms, query, fid = 
>>>> urlparse.urlparse("http://bill:[EMAIL PROTECTED]/lib/module-urlparse.html")
> 
>>>> site
> 'bill:[EMAIL PROTECTED]'
> 
> 
> I personally would prefer that it be broken down a bit further. What
> are existing opinions on this?
> 
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to