a
    xd)                     @   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   W/var/www/html/Ranjet/env/lib/python3.9/site-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 )	ProxyTypezSet 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   sv   t |trd|v r|d }t| }t| D ]4}t| |}t |tr.d|v r.|d |kr.|  S q.td| d S )Nr   zNo proxy type is found for )
isinstancedictstrupperdirgetattr	Exception)clsvalueattr
attr_valuer   r   r   load,   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
dZedd Zejdd	ddZedd Zejdd	ddZedd Zejdd	ddZedd Zejdd	ddZedd Zejdd	ddZedd Zejdd	ddZedd Zejdd	ddZed d! Zejdd	d"d!Zed#d$ Zejdd	d%d$Zed&d' Zejdd	d(d'Zd)d* Zd+d, Z dS ).ProxyzMProxy contains information about proxy type and necessary proxy
    settings.F Nc                 C   s6  |r2d|v r&|d r&t |d | _d|v r@|d r@|d | _d|v rZ|d rZ|d | _d|v rt|d rt|d | _d|v r|d r|d | _d|v r|d r|d | _d|v r|d r|d | _d|v r|d r|d | _	d	|v r|d	 r|d	 | _
d
|v r|d
 r|d
 | _d|v r2|d r2|d | _dS )zuCreates 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__H   s.    








zProxy.__init__c                 C   s   | j S )z"Returns proxy type as `ProxyType`.)r)   r>   r   r   r   r4   f   s    zProxy.proxy_type)returnc                 C   s   |  | || _dS )zKSets proxy type.

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

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

        :Args:
         - value: The ftp proxy value.
        N)rC   r   r   r)   r*   rD   r   r   r   r5      s    c                 C   s   | j S )zReturns http proxy setting.)r+   rA   r   r   r   r6      s    zProxy.http_proxyc                 C   s   |  tj tj| _|| _dS )zYSets http proxy setting.

        :Args:
         - value: The http proxy value.
        N)rC   r   r   r)   r+   rD   r   r   r   r6      s    c                 C   s   | j S )zReturns noproxy setting.)r,   rA   r   r   r   r7      s    zProxy.no_proxyc                 C   s   |  tj tj| _|| _dS )zSSets noproxy setting.

        :Args:
         - value: The noproxy value.
        N)rC   r   r   r)   r,   rD   r   r   r   r7      s    c                 C   s   | j S )z%Returns proxy autoconfig url setting.)r-   rA   r   r   r   r8      s    zProxy.proxy_autoconfig_urlc                 C   s   |  tj tj| _|| _dS )zmSets proxy autoconfig url setting.

        :Args:
         - value: The proxy autoconfig url value.
        N)rC   r   r   r)   r-   rD   r   r   r   r8      s    c                 C   s   | j S )zReturns https proxy setting.)r.   rA   r   r   r   	ssl_proxy   s    zProxy.ssl_proxyc                 C   s   |  tj tj| _|| _dS )z[Sets https proxy setting.

        :Args:
         - value: The https proxy value.
        N)rC   r   r   r)   r.   rD   r   r   r   rG      s    c                 C   s   | j S )zReturns socks proxy setting.)r0   rA   r   r   r   r:      s    zProxy.socks_proxyc                 C   s   |  tj tj| _|| _dS )z[Sets socks proxy setting.

        :Args:
         - value: The socks proxy value.
        N)rC   r   r   r)   r0   rD   r   r   r   r:      s    c                 C   s   | j S )z%Returns socks proxy username setting.)r1   rA   r   r   r   r;      s    zProxy.socks_usernamec                 C   s   |  tj tj| _|| _dS )zmSets socks proxy username setting.

        :Args:
         - value: The socks proxy username value.
        N)rC   r   r   r)   r1   rD   r   r   r   r;      s    c                 C   s   | j S )z%Returns socks proxy password setting.)r2   rA   r   r   r   r<      s    zProxy.socks_passwordc                 C   s   |  tj tj| _|| _dS )zmSets socks proxy password setting.

        :Args:
         - value: The socks proxy password value.
        N)rC   r   r   r)   r2   rD   r   r   r   r<      s    c                 C   s   | j S )z$Returns socks proxy version setting.)r3   rA   r   r   r   r=   	  s    zProxy.socks_versionc                 C   s   |  tj tj| _|| _dS )zkSets socks proxy version setting.

        :Args:
         - value: The socks proxy version value.
        N)rC   r   r   r)   r3   rD   r   r   r   r=     s    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   rC     s    z&Proxy._verify_proxy_type_compatibilityc                 C   s   d| j d i}| jr| j|d< | jr.| j|d< | jr>| j|d< | jrN| j|d< | jr^| j|d< | jrn| j|d< | jr~| j|d	< | jr| j|d
< | j	r| j	|d< | j
r| j
|d< ||d< dS )zAdds 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_capabilities  s,    









zProxy.add_to_capabilities)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   rG   r:   r;   r<   r=   rC   rJ   r   r   r   r   r'   8   sv   

	


















r'   N)r
   r   r   r'   r   r   r   r   <module>   s   