o
    h_                     @   s    d dl mZ G dd deZdS )   )format_environmentc                   @   sd   e Zd ZdZedd Zedd Zedd Zedd	 Ze	d
d Z
dd Zdd Zdd ZdS )ProxyConfigz/
    Hold the client's proxy configuration
    c                 C   
   |  dS )Nhttpgetself r
   4/usr/lib/python3/dist-packages/docker/utils/proxy.pyr         
zProxyConfig.httpc                 C   r   )Nhttpsr   r   r
   r
   r   r      r   zProxyConfig.httpsc                 C   r   )Nftpr   r   r
   r
   r   r      r   zProxyConfig.ftpc                 C   r   )Nno_proxyr   r   r
   r
   r   r      r   zProxyConfig.no_proxyc                 C   s(   t | d| d| d| ddS )a  
        Instantiate a new ProxyConfig from a dictionary that represents a
        client configuration, as described in `the documentation`_.

        .. _the documentation:
            https://docs.docker.com/network/proxy/#configure-the-docker-client
        Z	httpProxyZ
httpsProxyZftpProxyZnoProxyr   r   r   r   )r   r   )Zconfigr
   r
   r   	from_dict   s   	zProxyConfig.from_dictc                 C   sh   i }| j r| j  |d< |d< | jr| j |d< |d< | jr&| j |d< |d< | jr2| j |d< |d< |S )	zt
        Return a dictionary representing the environment variables used to
        set the proxy settings.
        Z
http_proxyZ
HTTP_PROXYZhttps_proxyZHTTPS_PROXYZ	ftp_proxyZ	FTP_PROXYr   ZNO_PROXYr   )r	   envr
   r
   r   get_environment(   s   zProxyConfig.get_environmentc                 C   s$   | s|S t |  }|s|S || S )z
        Given a list of strings representing environment variables, prepend the
        environment variables corresponding to the proxy settings.
        )r   r   )r	   ZenvironmentZ	proxy_envr
   r
   r   inject_proxy_environment8   s   z$ProxyConfig.inject_proxy_environmentc                 C   s   d | j| j| j| jS )Nz3ProxyConfig(http={}, https={}, ftp={}, no_proxy={}))formatr   r   r   r   r   r
   r
   r   __str__G   s   zProxyConfig.__str__N)__name__
__module____qualname____doc__propertyr   r   r   r   staticmethodr   r   r   r   r
   r
   r
   r   r      s    




r   N)Zutilsr   dictr   r
   r
   r
   r   <module>   s    