o
    ѷ6iz                     @   sx   d dl Z d dlZd dlZd dlmZ d dlmZ d dlZd dlm	Z	m
Z
 G dd deZG dd dZG d	d
 d
ZdS )    N)Enum)parse)Proxy	ProxyTypec                   @   s   e Zd ZdZdZdZdS )AuthTypeBasicBearerz	X-API-KeyN)__name__
__module____qualname__BASICBEARER	X_API_KEY r   r   l/var/www/hoanhtaovolam_webdjango/env/lib/python3.10/site-packages/selenium/webdriver/remote/client_config.pyr      s    r   c                   @   s&   e Zd Zdd Zdd Zd	ddZdS )
_ClientConfigDescriptorc                 C   s
   || _ d S N)name)selfr   r   r   r   __init__$   s   
z _ClientConfigDescriptor.__init__c                 C   s   |j | j S r   __dict__r   )r   objclsr   r   r   __get__'   s   z_ClientConfigDescriptor.__get__returnNc                 C   s   ||j | j< d S r   r   )r   r   valuer   r   r   __set__*   s   z_ClientConfigDescriptor.__set__r   N)r	   r
   r   r   r   r   r   r   r   r   r   #   s    r   c                !   @   s~  e Zd ZedZ	 edZ	 edZ	 edZ	 edZ	 edZ		 edZ
	 edZ	 ed	Z	 ed
Z	 edZ	 edZ	 edZ	 edZ	 edZ	 dedejidddddddejdddddfdededB dedB dedB dedB dedB dedB dedB dedB d edB d!edB d"edB d#edB d$edB d%edB d&df d'd(Zd/d)d*Zd&edB fd+d,Zd&edB fd-d.Z dS )0ClientConfig_remote_server_addr_keep_alive_proxy_ignore_certificates_init_args_for_pool_manager_timeout	_ca_certs	_username	_password
_auth_type_token_user_agent_extra_headers_websocket_timeout_websocket_intervalT	proxyType)rawFNg      >@g?remote_server_addr
keep_aliveproxyignore_certificatesinit_args_for_pool_managertimeoutca_certsusernamepassword	auth_typetoken
user_agentextra_headerswebsocket_timeoutwebsocket_intervalr   c                 C   s   || _ || _|| _|| _|pi | _|d u rt n|| _|| _|	| _	|
| _
|| _|| _|| _|| _|| _|d u rLdtjv rEtd| _d S t | _d S || _d S )NREQUESTS_CA_BUNDLE)r1   r2   r3   r4   r5   socketgetdefaulttimeoutr6   r8   r9   r:   r;   r<   r=   r>   r?   osenvirongetenvcertifiwherer7   )r   r1   r2   r3   r4   r5   r6   r7   r8   r9   r:   r;   r<   r=   r>   r?   r   r   r   r   N   s*   
zClientConfig.__init__c                 C   s   t  | _dS )z2Resets the timeout to the default value of socket.N)rA   rB   r%   )r   r   r   r   reset_timeoutu   s   zClientConfig.reset_timeoutc                 C   s  | j j}t| j}|tju rdS |tju rmtj	
dtj	
d}|rPttj|dD ]#}|dkr5 dS t|}|jrF|j|jkrF dS |j|jv rO dS q,tj	
| jdr[dndtj	
| jdrid	S d
S |tju r| jdr|| j jS | j jS dS )z0Returns the proxy URL to use for the connection.Nno_proxyNO_PROXY,*zhttps://https_proxy
http_proxyHTTPS_PROXY
HTTP_PROXY)r3   
proxy_typer   urlparser1   r   DIRECTSYSTEMrC   rD   getmapstrstripsplitnetlocpath
startswithMANUALsslProxyrN   )r   rQ   
remote_add	_no_proxyentryn_urlr   r   r   get_proxy_urly   s2   



zClientConfig.get_proxy_urlc                 C   s   | j tju r+| jr+| jr+| j d| j }t|dd}dtjj	 d| iS | j tj
u r@| jr@dtj
j	 d| j iS | j tju rR| jrRtjj	 | j iS dS )z8Returns the authorization to add to the request headers.:zutf-8Authorization N)r:   r   r   r8   r9   base64	b64encodeencodedecoder   r   r;   r   )r   credentialsencoded_credentialsr   r   r   get_auth_header   s   zClientConfig.get_auth_headerr   )!r	   r
   r   r   r1   r2   r3   r4   r5   r6   r7   r8   r9   r:   r;   r<   r=   r>   r?   r   r   rT   r   r   rW   booldictintfloatr   rH   rc   rm   r   r   r   r   r   .   s    	


'r   )rg   rC   rA   enumr   urllibr   rF   selenium.webdriver.common.proxyr   r   r   r   r   r   r   r   r   <module>   s   