a
    Ò�éix  ã                   @   s†   d dl Z d dlmZ d dlmZmZmZmZmZ d dl	m
Z
 d dlmZ d dlmZ d dlmZmZ G dd	„ d	ƒZG d
d„ de
ƒZdS )é    N)ÚPath)ÚAnyÚDictÚListÚSetÚUnion)ÚChannelOwner)ÚError)Úasync_readfile)Úset_test_id_attribute_nameÚtest_id_attribute_namec                   @   sp   e Zd Zejeddœdd„Zdeeeee	f e
ddœdd„Zeddœd	d
„Zdddœdd„Zdddœdd„ZdS )Ú	SelectorsN)ÚloopÚdispatcher_fiberÚreturnc                 C   s   || _ tƒ | _g | _|| _d S ©N)Z_loopÚsetÚ	_channelsÚ_registrationsZ_dispatcher_fiber)Úselfr   r   © r   úK/home/Claro/venv/lib/python3.9/site-packages/playwright/_impl/_selectors.pyÚ__init__   s    zSelectors.__init__)ÚnameÚscriptÚpathÚcontentScriptr   c                 Ã   sn   |s|st dƒ‚|r&t|ƒI d H  ¡ }t||d�}|r>d|d< | jD ]}|j d|¡I d H  qD| j |¡ d S )Nz)Either source or path should be specified)r   ÚsourceTr   Úregister)	r	   r
   ÚdecodeÚdictr   Ú_channelÚsendr   Úappend)r   r   r   r   r   ÚparamsÚchannelr   r   r   r       s    
zSelectors.register)Úattribute_namer   c                 C   s*   t |ƒ | jD ]}|j dd|i¡ qd S )NÚsetTestIdAttributeNameÚtestIdAttributeName)r   r   r!   Úsend_no_reply)r   r&   r%   r   r   r   Úset_test_id_attribute2   s
    
ÿzSelectors.set_test_id_attributeÚSelectorsOwner)r%   r   c                 C   s>   | j  |¡ | jD ]&}|j d|¡ |j ddtƒ i¡ qd S )Nr   r'   r(   )r   Úaddr   r!   r)   r   )r   r%   r$   r   r   r   Ú_add_channel9   s    
þzSelectors._add_channelc                 C   s   || j v r| j  |¡ d S r   )r   Úremove)r   r%   r   r   r   Ú_remove_channelC   s    
zSelectors._remove_channel)NNN)Ú__name__Ú
__module__Ú__qualname__ÚasyncioZAbstractEventLoopr   r   Ústrr   r   Úboolr   r*   r-   r/   r   r   r   r   r      s   	   û
ú
r   c                       s*   e Zd Zeeeeddœ‡ fdd„Z‡  ZS )r+   N)ÚparentÚtypeÚguidÚinitializerr   c                    s   t ƒ  ||||¡ d S r   )Úsuperr   )r   r6   r7   r8   r9   ©Ú	__class__r   r   r   I   s    zSelectorsOwner.__init__)r0   r1   r2   r   r4   r   r   Ú__classcell__r   r   r;   r   r+   H   s   þr+   )r3   Úpathlibr   Útypingr   r   r   r   r   Zplaywright._impl._connectionr   Zplaywright._impl._errorsr	   Zplaywright._impl._helperr
   Zplaywright._impl._locatorr   r   r   r+   r   r   r   r   Ú<module>   s   /