U
    g                      @  s   d dl mZ ddlmZmZ d dlmZ d dlZd dlZG dd dej	Z
dd	d
ddZddddddddZdddddddZddddddZdddddddZdS )    )annotations   )event_classT_JSON_DICT)	dataclassNc                   @  s4   e Zd ZdZdZdZdZdZdd Ze	dd	 Z
d
S )StorageAreaz
    Storage areas.
    sessionlocalsyncZmanagedc                 C  s   | j S N)value)self r   V/tmp/pip-unpacked-wheel-3ysq0mf8/selenium/webdriver/common/devtools/v131/extensions.pyto_json   s    zStorageArea.to_jsonc                 C  s   | |S r   r   )clsjsonr   r   r   	from_json   s    zStorageArea.from_jsonN)__name__
__module____qualname____doc__ZSESSIONZLOCALZSYNCZMANAGEDr   classmethodr   r   r   r   r   r      s   r   strz/typing.Generator[T_JSON_DICT, T_JSON_DICT, str])pathreturnc                 c  s*   t  }| |d< d|d}|V }t|d S )av  
    Installs an unpacked extension from the filesystem similar to
    --load-extension CLI flags. Returns extension ID once the extension
    has been installed. Available if the client is connected using the
    --remote-debugging-pipe flag and the --enable-unsafe-extension-debugging
    flag is set.

    :param path: Absolute file path.
    :returns: Extension id.
    r   zExtensions.loadUnpackedmethodparamsid)dictr   )r   r   cmd_dictr   r   r   r   load_unpacked   s    r"   z!typing.Optional[typing.List[str]]z0typing.Generator[T_JSON_DICT, T_JSON_DICT, dict])id_storage_areakeysr   c                 c  sP   t  }| |d< | |d< |dk	r4dd |D |d< d|d}|V }t |d	 S )
a(  
    Gets data from extension storage in the given ``storageArea``. If ``keys`` is
    specified, these are used to filter the result.

    :param id_: ID of extension.
    :param storage_area: StorageArea to retrieve data from.
    :param keys: *(Optional)* Keys to retrieve.
    :returns: 
    r   storageAreaNc                 S  s   g | ]}|qS r   r   .0ir   r   r   
<listcomp>G   s     z%get_storage_items.<locals>.<listcomp>r%   zExtensions.getStorageItemsr   datar    r   r#   r$   r%   r   r!   r   r   r   r   get_storage_items5   s    r.   ztyping.List[str]z0typing.Generator[T_JSON_DICT, T_JSON_DICT, None]c                 c  s@   t  }| |d< | |d< dd |D |d< d|d}|V }dS )	z
    Removes ``keys`` from extension storage in the given ``storageArea``.

    :param id_: ID of extension.
    :param storage_area: StorageArea to remove data from.
    :param keys: Keys to remove.
    r   r&   c                 S  s   g | ]}|qS r   r   r'   r   r   r   r*   _   s     z(remove_storage_items.<locals>.<listcomp>r%   zExtensions.removeStorageItemsr   Nr,   r-   r   r   r   remove_storage_itemsP   s    r/   )r#   r$   r   c                 c  s.   t  }| |d< | |d< d|d}|V }dS )z
    Clears extension storage in the given ``storageArea``.

    :param id_: ID of extension.
    :param storage_area: StorageArea to remove data from.
    r   r&   zExtensions.clearStorageItemsr   Nr,   )r#   r$   r   r!   r   r   r   r   clear_storage_itemsg   s    
r0   r    )r#   r$   valuesr   c                 c  s6   t  }| |d< | |d< ||d< d|d}|V }dS )a  
    Sets ``values`` in extension storage in the given ``storageArea``. The provided ``values``
    will be merged with existing values in the storage area.

    :param id_: ID of extension.
    :param storage_area: StorageArea to set data in.
    :param values: Values to set.
    r   r&   r1   zExtensions.setStorageItemsr   Nr,   )r#   r$   r1   r   r!   r   r   r   r   set_storage_items{   s    r2   )N)
__future__r   utilr   r   Zdataclassesr   enumtypingEnumr   r"   r.   r/   r0   r2   r   r   r   r   <module>   s    