o
    US`c]*                     @   s2   d Z G dd dZG dd dZG dd dZdS )z
The Proxy implementation.
c                   @   s   e Zd ZdZedd ZdS )ProxyTypeFactoryz"
    Factory for proxy types.
    c                 C   s
   | |dS )NZff_valuestring r   r   r   J/usr/local/lib/python3.10/dist-packages/selenium/webdriver/common/proxy.pymake   s   
zProxyTypeFactory.makeN)__name__
__module____qualname____doc__staticmethodr   r   r   r   r   r      s    r   c                   @   sp   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
eddZeddZedd ZdS )	ProxyTypez
    Set of possible types of proxy.

    Each proxy type has 2 properties:
       'ff_value' is value of Firefox profile preference,
       'string' is id of proxy type.
        DIRECT   MANUAL   PAC   Z	RESERVED1   
AUTODETECT   SYSTEM   UNSPECIFIEDc                 C   sr   t |trd|v r|d }t| }t| D ]}t| |}t |tr1d|v r1|d |kr1|  S qtd| )Nr   zNo proxy type is found for )
isinstancedictstrupperdirgetattr	Exception)clsvalueattr
attr_valuer   r   r   load2   s   
zProxyType.loadN)r   r   r	   r
   r   r   r   r   r   Z
RESERVED_1r   r   r   classmethodr%   r   r   r   r   r   !   s    r   c                   @   s  e Zd ZdZejZdZdZdZ	dZ
dZdZdZdZdZdZd-ddZedd Zejd.d
dZedd Zejd.ddZedd Zejd.ddZedd Zejd.ddZedd Zejd.ddZedd Zejd.ddZedd Zejd.ddZedd Zejd.ddZed d! Zejd.d"d!Zed#d$ Zejd.d%d$Zed&d' Zejd.d(d'Zd)d* Zd+d, Z dS )/ProxyzS
    Proxy contains information about proxy type and necessary proxy settings.
    F Nc                 C   s8  |rd|v r|d rt |d | _d|v r|d r|d | _d|v r,|d r,|d | _d|v r9|d r9|d | _d|v rF|d rF|d | _d|v rS|d rS|d | _d|v r`|d r`|d | _d|v rm|d rm|d | _	d	|v rz|d	 rz|d	 | _
d
|v r|d
 r|d
 | _d|v r|d r|d | _dS dS dS dS )z~
        Creates a new Proxy.

        :Args:
         - raw: raw proxy data. If None, default class values are used.
        	proxyTypeftpProxy	httpProxynoProxyproxyAutoconfigUrlsslProxy
autodetect
socksProxysocksUsernamesocksPasswordsocksVersionN)r   r%   
proxy_type	ftp_proxy
http_proxyno_proxyproxy_autoconfig_urlr.   auto_detectsocks_proxysocks_usernamesocks_passwordsocks_version)selfrawr   r   r   __init__O   s2   








zProxy.__init__c                 C      | j S )z4
        Returns proxy type as `ProxyType`.
        )r)   r>   r   r   r   r4   n      zProxy.proxy_typereturnc                 C   s   |  | || _dS )zT
        Sets proxy type.

        :Args:
         - value: The proxy type.
        N) _verify_proxy_type_compatibilityr)   r>   r"   r   r   r   r4   u   s   

c                 C   rA   )z-
        Returns autodetect setting.
        )r/   rB   r   r   r   r9      rC   zProxy.auto_detectc                 C   s>   t |tr| j|ur| tj tj| _|| _dS dS td)zb
        Sets autodetect setting.

        :Args:
         - value: The autodetect value.
        z,Autodetect proxy value needs to be a booleanN)r   boolr/   rE   r   r   r)   
ValueErrorrF   r   r   r   r9      s   


c                 C   rA   )z,
        Returns ftp proxy setting.
        )r*   rB   r   r   r   r5      rC   zProxy.ftp_proxyc                 C      |  tj tj| _|| _dS )z`
        Sets ftp proxy setting.

        :Args:
         - value: The ftp proxy value.
        N)rE   r   r   r)   r*   rF   r   r   r   r5         
c                 C   rA   )z-
        Returns http proxy setting.
        )r+   rB   r   r   r   r6      rC   zProxy.http_proxyc                 C   rI   )zb
        Sets http proxy setting.

        :Args:
         - value: The http proxy value.
        N)rE   r   r   r)   r+   rF   r   r   r   r6      rJ   c                 C   rA   )z*
        Returns noproxy setting.
        )r,   rB   r   r   r   r7      rC   zProxy.no_proxyc                 C   rI   )z\
        Sets noproxy setting.

        :Args:
         - value: The noproxy value.
        N)rE   r   r   r)   r,   rF   r   r   r   r7      rJ   c                 C   rA   )z7
        Returns proxy autoconfig url setting.
        )r-   rB   r   r   r   r8      rC   zProxy.proxy_autoconfig_urlc                 C   rI   )zv
        Sets proxy autoconfig url setting.

        :Args:
         - value: The proxy autoconfig url value.
        N)rE   r   r   r)   r-   rF   r   r   r   r8      rJ   c                 C   rA   )z.
        Returns https proxy setting.
        )r.   rB   r   r   r   	ssl_proxy   rC   zProxy.ssl_proxyc                 C   rI   )zd
        Sets https proxy setting.

        :Args:
         - value: The https proxy value.
        N)rE   r   r   r)   r.   rF   r   r   r   rK      rJ   c                 C   rA   )z.
        Returns socks proxy setting.
        )r0   rB   r   r   r   r:      rC   zProxy.socks_proxyc                 C   rI   )zd
        Sets socks proxy setting.

        :Args:
         - value: The socks proxy value.
        N)rE   r   r   r)   r0   rF   r   r   r   r:      rJ   c                 C   rA   )z7
        Returns socks proxy username setting.
        )r1   rB   r   r   r   r;   	  rC   zProxy.socks_usernamec                 C   rI   )zv
        Sets socks proxy username setting.

        :Args:
         - value: The socks proxy username value.
        N)rE   r   r   r)   r1   rF   r   r   r   r;     rJ   c                 C   rA   )z7
        Returns socks proxy password setting.
        )r2   rB   r   r   r   r<     rC   zProxy.socks_passwordc                 C   rI   )zv
        Sets socks proxy password setting.

        :Args:
         - value: The socks proxy password value.
        N)rE   r   r   r)   r2   rF   r   r   r   r<   #  rJ   c                 C   rA   )z6
        Returns socks proxy version setting.
        )r3   rB   r   r   r   r=   /  rC   zProxy.socks_versionc                 C   rI   )zt
        Sets socks proxy version setting.

        :Args:
         - value: The socks proxy version value.
        N)rE   r   r   r)   r3   rF   r   r   r   r=   6  rJ   c                 C   s,   | j tj|fvrtd| d| j  dd S )NzSpecified proxy type (z') not compatible with current setting ())r)   r   r   r    )r>   Zcompatible_proxyr   r   r   rE   B  s   z&Proxy._verify_proxy_type_compatibilityc                 C   s   i }| j d |d< | jr| j|d< | jr| j|d< | jr!| j|d< | jr)| j|d< | jr1| j|d< | jr9| j|d< | jrA| j|d	< | jrI| j|d
< | j	rQ| j	|d< | j
rY| j
|d< ||d< dS )z
        Adds proxy information as capability in specified capabilities.

        :Args:
         - capabilities: The capabilities to which proxy will be added.
        r   r)   r/   r*   r+   r-   r.   r,   r0   r1   r2   r3   proxyN)r)   r/   r*   r+   r-   r.   r,   r0   r1   r2   r3   )r>   ZcapabilitiesZ
proxy_capsr   r   r   add_to_capabilitiesF  s.   









zProxy.add_to_capabilities)N)rD   N)!r   r   r	   r
   r   r   r)   r/   r*   r+   r,   r-   r.   r0   r1   r2   r3   r@   propertyr4   setterr9   r5   r6   r7   r8   rK   r:   r;   r<   r=   rE   rN   r   r   r   r   r'   >   sx    












r'   N)r
   r   r   r'   r   r   r   r   <module>   s   
