
                         n    S r SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSK	r	SSK
Jr  SS	 jrS
 rS rg)z*A module to get an http proxy information.    )absolute_import)division)unicode_literals)
properties)http_proxy_typesN)urllibc                     [         R                  R                  5       nUR                  U S5      nU(       d  g[        R
                  " X 5      n[         R                  R                  Ul        U$ )aj  Get ProxyInfo from environment.

This function is meant to mimic httplib2.proxy_info_from_environment, but get
the proxy information from urllib.getproxies instead. urllib can also get
proxy information from Windows Internet Explorer settings or MacOSX framework
SystemConfiguration.

Args:
  method: protocol string
Returns:
  httplib2 ProxyInfo object or None
N)r   request
getproxiesgethttplib2proxy_info_from_urlproxy_bypassbypass_host)method
proxy_dict	proxy_urlpis       %lib/googlecloudsdk/core/http_proxy.pyGetDefaultProxyInfor      sV     ~~((**nnVT*)	##I6" >>..". 
)    c                  <   [         R                  n [        R                  R                  R
                  R                  5       n[        R                  R                  R                  R                  5       n[        R                  R                  R                  R                  5       n[        XU4 Vs/ s H  oD(       d  M  UPM     sn5      nUS:  a  US:w  a  [        R                  " S5      eU(       d  0 $ [        R                  R                  R                  R                  5       n[        R                  R                  R                  R                  5       n[        R                  R                  R                  R                  5       nX   UUUUUS.$ s  snf )zCGet proxy information from cloud sdk properties in dictionary form.r      z\Please set all or none of the following properties: proxy/type, proxy/address and proxy/port)
proxy_typeproxy_address
proxy_port
proxy_rdns
proxy_user
proxy_pass)r   PROXY_TYPE_MAPr   VALUESproxyr   GetaddressportGetIntlenInvalidValueErrorrdnsGetBoolusernamepassword)	proxy_type_mapr   r   r   fproxy_prop_setr   r   r   s	            r   GetProxyPropertiesr0   B   sK   #22.  &&11557*##))11557-  &&++224*j9?9QQq9?A.aNa/

&
&	34 4 
I  &&++335*  &&//335*  &&//335* #.$
  @s   2
F Fc            	          [        5       n U (       a+  [        R                  " U S   U S   U S   U S   U S   U S   S9$ [        $ )aP  Get ProxyInfo object or callable to be passed to httplib2.Http.

httplib2.Http can issue requests through a proxy. That information is passed
via either ProxyInfo objects or a callback function that receives the protocol
the request is made on and returns the proxy address. If users set the gcloud
properties, we create a ProxyInfo object with those settings. If users do not
set gcloud properties, we return a function that can be called to get default
settings.

Returns:
  httplib2 ProxyInfo object or callable function that returns a Proxy Info
  object given the protocol (http, https)
r   r   r   r   r   r   )r   r   r   )r0   r   	ProxyInfor   )proxy_settingss    r   GetHttpProxyInfor4   a   sZ     &'.|$'|$!,/!,/!,/1 1 
r   )http)__doc__
__future__r   r   r   googlecloudsdk.corer   googlecloudsdk.core.utilr   r   	six.movesr   r   r0   r4    r   r   <module>r<      s1     1 '  ' * 5  !H>r   