(url, proxies)
return proxy
Select a proxy for the url, if applicable.

    :param url: The url being for the request
    :param proxies: A dictionary of schemes or schemes and hosts to proxy URLs
Select a proxy for the url, if applicable.
Select a proxy for the url if applicable .
def select_proxy(url, proxies):
    """Select a proxy for the url, if applicable.

    :param url: The url being for the request
    :param proxies: A dictionary of schemes or schemes and hosts to proxy URLs
    """
    proxies = proxies or {}
    urlparts = urlparse(url)
    if urlparts.hostname is None:
        return proxies.get(urlparts.scheme, proxies.get('all'))

    proxy_keys = [
        urlparts.scheme + '://' + urlparts.hostname,
        urlparts.scheme,
        'all://' + urlparts.hostname,
        'all',
    ]
    proxy = None
    for proxy_key in proxy_keys:
        if proxy_key in proxies:
            proxy = proxies[proxy_key]
            break

    return proxy
def select_proxy ( url , proxies ) : proxies = proxies or { } urlparts = urlparse ( url ) if urlparts . hostname is None : return proxies . get ( urlparts . scheme , proxies . get ( 'all' ) ) proxy_keys = [ urlparts . scheme + '://' + urlparts . hostname , urlparts . scheme , 'all://' + urlparts . hostname , 'all' , ] proxy = None for proxy_key in proxy_keys : if proxy_key in proxies : proxy = proxies [ proxy_key ] break return proxy