a
    /e
                     @   s0   d dl Z d dlZd dlmZ G dd deZdS )    N)ChromiumOptionsc                   @   s`   e Zd ZdZdZedd ZejedddZe	dd Z
e	dd	 Zd
d Zedd ZdS )ChromeOptionsNc                 C   s   | j S N)_user_data_dir)self r   Z/var/www/html/efn/efnconsultor/selenium/selenium-4.34.2/undetected_chromedriver/options.pyuser_data_dir   s    zChromeOptions.user_data_dir)pathc                 C   s   t j|}t j|| _dS )a&  
        Sets the browser profile folder to use, or creates a new profile
        at given <path>.

        Parameters
        ----------
        path: str
            the path to a chrome profile folder
            if it does not exist, a new profile will be created at given location
        N)osr
   abspathnormpathr   )r   r
   Zapathr   r   r   r	      s    c                 C   s,   d| v r$|  dd\} }t||}| |iS )z4turn a (dotted key, value) into a proper nested dict.   )splitr   
_undot_key)keyvaluerestr   r   r   r   "   s    zChromeOptions._undot_keyc                 C   sT   |D ]J}|| v rBt | | trBt || trBt| | ||  q|| | |< q| S )z]
        merges b into a
        leaf values in a are overwritten with values from b
        )
isinstancedictr   _merge_nested)abr   r   r   r   r   *   s    zChromeOptions._merge_nestedc           	      C   s   | j d}|r|p| j}tj|d}tj|dd i }| D ]\}}| || 	||}qBtj|d}tj
|rt|ddd"}| t||}W d    n1 s0    Y  t|dd	d}t|| W d    n1 s0    Y  | jd= d S )
NprefsZDefaultT)exist_okZPreferenceslatin1r)encodingmodew)experimental_optionsgetr   r   r
   joinmakedirsitemsr   r   existsopenjsonloaddump_experimental_options)	r   r	   r   Zdefault_pathZundot_prefsr   r   Z
prefs_filefr   r   r   handle_prefs8   s"    
0*zChromeOptions.handle_prefsc                 C   s   |  }|j |j  |S r   )__dict__update)clsoptionsor   r   r   from_optionsQ   s    zChromeOptions.from_options)__name__
__module____qualname___sessionr   propertyr	   setterstrstaticmethodr   r   r-   classmethodr3   r   r   r   r   r      s   


r   )r(   r   #selenium.webdriver.chromium.optionsr   Z_ChromiumOptionsr   r   r   r   r   <module>   s   