
    ¦i                     J    d dl mZmZ  G d d          Z G d d          ZdS )    )	async_apisync_apic                   F    e Zd Zdddej        fdZdej        fdZd	dZdS )
AsyncWrappingContextManagerstealthStealthmanagerc                 t    t          |t          j                  rt          d          || _        || _        d S )NzPYou need to call 'use_sync' instead of 'use_async' for a sync Playwright context)
isinstancer   PlaywrightContextManager	TypeErrorr   r	   selfr   r	   s      ^/root/projects/butler/venv/lib/python3.11/site-packages/playwright_stealth/context_managers.py__init__z$AsyncWrappingContextManager.__init__   s9    gx@AA 	pnooo    returnc                 |   K   | j                                          d {V }| j                            |           |S N)r	   
__aenter__r   hook_playwright_contextr   contexts     r   r   z&AsyncWrappingContextManager.__aenter__   sH       //11111111,,W555r   Nc                 N   K   | j                             |||           d {V  d S r   )r	   	__aexit__r   exc_typeexc_valexc_tbs       r   r   z%AsyncWrappingContextManager.__aexit__   s8      l$$Xw???????????r   r   N)	__name__
__module____qualname__r   r   r   
Playwrightr   r    r   r   r   r      sr        	 I4V    		   @ @ @ @ @ @r   r   c                   F    e Zd Zdddej        fdZdej        fdZd	dZdS )
SyncWrappingContextManagerr   r   r	   c                 t    t          |t          j                  rt          d          || _        || _        d S )NzRYou need to call 'use_async' instead of 'use_sync' for an async Playwright context)r   r   r   r   r   r	   r   s      r   r   z#SyncWrappingContextManager.__init__   s9    gyABB 	rpqqqr   r   c                 l    | j                                         }| j                            |           |S r   )r	   	__enter__r   r   r   s     r   r*   z$SyncWrappingContextManager.__enter__   s2     ,((**,,W555r   Nc                 >    | j                             |||           d S r   )r	   __exit__r   s       r   r,   z#SyncWrappingContextManager.__exit__$   s"    h88888r   r    )	r!   r"   r#   r   r   r   r$   r*   r,   r%   r   r   r'   r'      sl        	 H4U    		   9 9 9 9 9 9r   r'   N)
playwrightr   r   r   r'   r%   r   r   <module>r.      s    * * * * * * * *@ @ @ @ @ @ @ @$9 9 9 9 9 9 9 9 9 9r   