def get_proxy_info(hostname, is_secure, proxy_host=None, proxy_port=0, proxy_auth=None, no_proxy=None):
 if _is_no_proxy_host(hostname, no_proxy):
  return (None, 0, None)
 if proxy_host:
  port = proxy_port
  auth = proxy_auth
  return (proxy_host, port, auth)
 env_keys = ['http_proxy']
 if is_secure:
  env_keys.insert(0, 'https_proxy')
 for key in env_keys:
  value = os.environ.get(key, None)
  if value:
   proxy = urlparse(value)
   auth = ((proxy.username, proxy.password) if proxy.username else None)
   return (proxy.hostname, proxy.port, auth)
 return (None, 0, None)

def get_proxy_info ( hostname , is_secure , proxy_host = None , proxy_port = 0 , proxy_auth = None , no_proxy = None ) : if _is_no_proxy_host ( hostname , no_proxy ) : return ( None , 0 , None ) if proxy_host : port = proxy_port auth = proxy_auth return ( proxy_host , port , auth ) env_keys = [ 'http_proxy' ] if is_secure : env_keys . insert ( 0 , 'https_proxy' ) for key in env_keys : value = os . environ . get ( key , None ) if value : proxy = urlparse ( value ) auth = ( ( proxy . username , proxy . password ) if proxy . username else None ) return ( proxy . hostname , proxy . port , auth ) return ( None , 0 , None )
try to retrieve proxy host and port from environment if not provided in options .