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   /