a
    RýIhM  ã                   @   s.   d dl mZmZ d dlmZ G dd„ dƒZdS )é    )ÚDictÚUnion)Úcommand_builderc                   @   s@   e Zd ZdZdd„ Zdedœdd„Zeeef ddœd	d
„Z	dS )ÚWebExtensionz9
    BiDi implementation of the webExtension module.
    c                 C   s
   || _ d S ©N)Úconn)Úselfr   © r	   úe/var/www/html/venv_bot_3.9/lib/python3.9/site-packages/selenium/webdriver/common/bidi/webextension.pyÚ__init__   s    zWebExtension.__init__N)Úreturnc                 C   s|   t dd„ |||fD ƒƒdkr$tdƒ‚|dur8d|dœ}n&|durLd|dœ}n|dur^d	|d
œ}d|i}| j td|ƒ¡}|S )aª  Installs a web extension in the remote end.

        You must provide exactly one of the parameters.

        Parameters:
        -----------
            path: Path to an extension directory
            archive_path: Path to an extension archive file
            base64_value: Base64 encoded string of the extension archive

        Returns:
        -------
            Dict: A dictionary containing the extension ID.
        c                 s   s   | ]}|d uV  qd S r   r	   )Ú.0Úxr	   r	   r
   Ú	<genexpr>.   ó    z'WebExtension.install.<locals>.<genexpr>é   zCExactly one of path, archive_path, or base64_value must be providedNÚpath)Útyper   ZarchivePathÚbase64)r   ÚvalueZextensionDatazwebExtension.install)ÚsumÚ
ValueErrorr   Úexecuter   )r   r   Úarchive_pathZbase64_valueZextension_dataÚparamsÚresultr	   r	   r
   Úinstall   s    
zWebExtension.install)Úextension_id_or_resultr   c                 C   s8   t |tƒr| d¡}n|}d|i}| j td|ƒ¡ dS )a!  Uninstalls a web extension from the remote end.

        Parameters:
        -----------
            extension_id_or_result: Either the extension ID as a string or the result dictionary
                                   from a previous install() call containing the extension ID.
        Ú	extensionzwebExtension.uninstallN)Ú
isinstanceÚdictÚgetr   r   r   )r   r   Zextension_idr   r	   r	   r
   Ú	uninstall<   s
    
zWebExtension.uninstall)NNN)
Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r   Ústrr"   r	   r	   r	   r
   r      s   r   N)Útypingr   r   Z%selenium.webdriver.common.bidi.commonr   r   r	   r	   r	   r
   Ú<module>   s   