o
    衡iU                     @   s@   d Z G dd 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ff_valuestring r   r   r   p/var/www/html/asbeauty/laura_geller_scraping/env/lib/python3.10/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   	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   load,   s   
zProxyType.loadN)r   r	   r
   r   r   r   r   r   r   
RESERVED_1r   r   r   classmethodr'   r   r   r   r   r      s    r   c                   @   s$   e Zd Zdd Zdd Zdd ZdS )_ProxyTypeDescriptorc                 C   s   || _ || _d S N)namep_type)selfr,   r-   r   r   r   __init__9   s   
z_ProxyTypeDescriptor.__init__c                 C   s   t || jS r+   )r!   r,   )r.   objr#   r   r   r   __get__=   s   z_ProxyTypeDescriptor.__get__c                 C   sL   | j dkrt|tstdt|d| j t|d| j t|| j | d S )N
autodetectz,Autodetect proxy value needs to be a boolean _verify_proxy_type_compatibility	proxyType)r,   r   bool
ValueErrorr!   r-   setattr)r.   r0   r$   r   r   r   __set__@   s
   z_ProxyTypeDescriptor.__set__N)r   r	   r
   r/   r1   r8   r   r   r   r   r*   8   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edejZ	 edejZ	 edejZ	 edejZ	 ed	ejZ	 ed
ejZ	 edejZ	 edejZ	 edejZ	 ddedB fddZedd Z e j!dddZ dd Z"dd Z#defddZ$dS )ProxyzGProxy configuration containing proxy type and necessary proxy settings.F Nr2   	httpProxynoProxyproxyAutoconfigUrlsslProxy
socksProxysocksUsernamesocksPasswordsocksVersionrawc                 C   s   |du rdS t |tstdt| |dr!t|d | _|dr+|d | _|dr5|d | _	|dr?|d | _
|drI|d | _|drS|d | _|d	r]|d	 | _|d
rg|d
 | _|drq|d | _|dr}|d | _dS dS )zuCreates a new Proxy.

        Args:
            raw: Raw proxy data. If None, default class values are used.
        Nz`raw` must be a dict, got r4   r;   r<   r=   r>   r2   r?   r@   rA   rB   )r   r   	TypeErrortypegetr   r'   
proxy_type
http_proxyno_proxyproxy_autoconfig_urlr>   auto_detectsocks_proxysocks_usernamesocks_passwordsocks_version)r.   rC   r   r   r   r/   r   s2   


















zProxy.__init__c                 C   s   | j S )z"Returns proxy type as `ProxyType`.)r4   )r.   r   r   r   rG      s   zProxy.proxy_typereturnc                 C   s   |  | || _dS )zKSets proxy type.

        Args:
            value: The proxy type.
        N)r3   r4   )r.   r$   r   r   r   rG      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 ())r4   r   r   r6   )r.   compatible_proxyr   r   r   r3      s
   z&Proxy._verify_proxy_type_compatibilityc                 C   s>   d| j d  i}g d}|D ]}t| |}|r|||< q|S )Nr4   r   )	r2   r;   r=   r>   r<   r?   r@   rA   rB   )r4   lowerr!   )r.   
proxy_capsproxiesproxyr&   r   r   r   to_capabilities   s   
zProxy.to_capabilitiesc                 C   s   | j d  }d|i}|dkrj| jr| j|d< | jr| j|d< | jr'| j|d< | jdur1| j|d< | jrht| jtrId	d
 | j	dD |d< |S t| jt
rdtdd | jD s]td| j|d< |S td|S |dkrv| jrv| j|d< |S )zqConvert proxy settings to BiDi format.

        Returns:
            Proxy configuration in BiDi format.
        r   r4   manualr;   r>   r?   NrB   c                 S   s   g | ]
}|  r|  qS r   )strip).0hostr   r   r   
<listcomp>   s    z&Proxy.to_bidi_dict.<locals>.<listcomp>,r<   c                 s   s    | ]}t |tV  qd S r+   )r   r   )rZ   hr   r   r   	<genexpr>   s    z%Proxy.to_bidi_dict.<locals>.<genexpr>z'no_proxy list must contain only stringsz>no_proxy must be a comma-separated string or a list of stringspacr=   )r4   rS   r;   r>   r?   rB   r<   r   r   splitlistallrD   r=   )r.   rG   resultr   r   r   to_bidi_dict   s4   






zProxy.to_bidi_dictr+   )rP   N)%r   r	   r
   r   r   r   r4   r2   r;   r<   r=   r>   r?   r@   rA   rB   r*   r   rK   r   rH   rI   r   rJ   	ssl_proxyrL   rM   rN   rO   r   r/   propertyrG   setterr3   rW   re   r   r   r   r   r9   H   sL    
	r9   N)r   r   r   r*   r9   r   r   r   r   <module>   s
   