'Construct a ProxyInfo from a URL (such as http_proxy env var)'

@classmethod
def from_url(cls, url, method='http'):

    url = urlparse.urlparse(url)
    username = None
    password = None
    port = None
    if ('@' in url[1]):
        (ident, host_port) = url[1].split('@', 1)
        if (':' in ident):
            (username, password) = ident.split(':', 1)
        else:
            password = ident
    else:
        host_port = url[1]
    if (':' in host_port):
        (host, port) = host_port.split(':', 1)
    else:
        host = host_port
    if port:
        port = int(port)
    else:
        port = dict(https=443, http=80)[method]
    proxy_type = 3
    return cls(proxy_type=proxy_type, proxy_host=host, proxy_port=port, proxy_user=(username or None), proxy_pass=(password or None))
