§
    dŠtjš  ã                   óh   — d dl Z d dlZd dlZd dlZd dlmZmZ ddlmZ dd„Z	 G d„ dee¦  «        Z
dS )	é    N)ÚAsyncFileSystemÚrunning_asyncé   )ÚChainedFileSystemc                 óJ   ‡ ‡— t          j        ‰ ¦  «        ˆ ˆfd„¦   «         }|S )a¡  
    Wraps a synchronous function to make it awaitable.

    Parameters
    ----------
    func : callable
        The synchronous function to wrap.
    obj : object, optional
        The instance to bind the function to, if applicable.
    semaphore : asyncio.Semaphore, optional
        A semaphore to limit concurrent calls.

    Returns
    -------
    coroutine
        An awaitable version of the function.
    c               Ÿ   óÐ   •K  — ‰rG‰4 ƒd {V —† t          j        ‰g| ¢R i |¤Žƒ d {V —†cd d d ¦  «        ƒd {V —† S # 1 ƒd {V —†swxY w Y   t          j        ‰g| ¢R i |¤Žƒ d {V —†S ©N)ÚasyncioÚ	to_thread)ÚargsÚkwargsÚfuncÚ	semaphores     €€úa/var/www/html/CA-Chatbot/venv/lib/python3.11/site-packages/fsspec/implementations/asyn_wrapper.pyÚwrapperzasync_wrapper.<locals>.wrapper   sQ  øè è € àð 	FØ ð Fð Fð Fð Fð Fð Fð Fð FÝ$Ô.¨tÐE°dÐEÐEÐE¸fÐEÐEÐEÐEÐEÐEÐEÐEðFð Fð Fð Fñ Fô Fð Fð Fð Fð Fð Fð Fð Fð Fð Fð Fð Fð Fð Fð Fð Fð Fð Fð Føøøð Fð Fð Fð FåÔ& tÐ=¨dÐ=Ð=Ð=°fÐ=Ð=Ð=Ð=Ð=Ð=Ð=Ð=Ð=s   Ž<¼
AÁ	A)Ú	functoolsÚwraps)r   Úobjr   r   s   ` ` r   Úasync_wrapperr      s@   øø€ õ& „_�TÑÔð>ð >ð >ð >ð >ñ Ôð>ð €Nó    c                   ój   ‡ — e Zd ZdZdZdZ	 	 	 	 	 	 d	ˆ fd„	Zed„ ¦   «         Zd„ Z	e
d„ ¦   «         Zˆ xZS )
ÚAsyncFileSystemWrapperaX  
    A wrapper class to convert a synchronous filesystem into an asynchronous one.

    This class takes an existing synchronous filesystem implementation and wraps all
    its methods to provide an asynchronous interface.

    Parameters
    ----------
    sync_fs : AbstractFileSystem
        The synchronous filesystem instance to wrap.
    )Úasyncwrapperr   FNc                 óø   •— |€t          ¦   «         } t          ¦   «         j        dd|i|¤Ž |�|| _        nt	          j        |fi |¤Ž| _        | j        j        | _        || _        |                      ¦   «          d S )NÚasynchronous© )	r   ÚsuperÚ__init__Úsync_fsÚfsspecÚ
filesystemÚprotocolr   Ú_wrap_all_sync_methods)	ÚselfÚfsr   Útarget_protocolÚtarget_optionsr   Úmax_concurrent_tasksr   Ú	__class__s	           €r   r   zAsyncFileSystemWrapper.__init__8   s‰   ø€ ð ÐÝ(™?œ?ˆLØ�‰ŒÔÐ=Ð= lÐ=°fÐ=Ð=Ð=Øˆ>ØˆDŒLˆLå!Ô,¨_ÐOÐOÀÐOÐOˆDŒLØœÔ-ˆŒØ"ˆŒØ×#Ò#Ñ%Ô%Ð%Ð%Ð%r   c                 ó    — d| j         j        › �S )NÚasync_)r   Úfsid)r$   s    r   r,   zAsyncFileSystemWrapper.fsidM   s   € à+˜œÔ)Ð+Ð+Ð+r   c                 ó”  — dh}t          | j        ¦  «        D ]¯}|                     d¦  «        s||v rŒt          j        | j        |¦  «        }t          |t          ¦  «        rŒLt          | j        |¦  «        }t          |¦  «        r?t          j	        |¦  «        s+t          || | j        ¬¦  «        }t          | d|› �|¦  «         Œ°dS )zg
        Wrap all synchronous methods of the underlying filesystem with asynchronous versions.
        ÚopenÚ_)r   r   N)Údirr   Ú
startswithÚinspectÚgetattr_staticÚ
isinstanceÚpropertyÚgetattrÚcallableÚiscoroutinefunctionr   r   Úsetattr)r$   Úexcluded_methodsÚmethod_nameÚattrÚmethodÚasync_methods         r   r#   z-AsyncFileSystemWrapper._wrap_all_sync_methodsQ   sá   € ð #˜8ÐÝ˜tœ|Ñ,Ô,ð 	?ð 	?ˆKØ×%Ò% cÑ*Ô*ð ¨kÐ=MÐ.MÐ.MØåÔ)¨$¬,¸ÑDÔDˆDÝ˜$¥Ñ)Ô)ð Øå˜Tœ\¨;Ñ7Ô7ˆFÝ˜ÑÔð ?­Ô(CÀFÑ(KÔ(Kð ?Ý,¨V¸ÈÌÐXÑXÔX�Ý˜Ð/ +Ð/Ð/°Ñ>Ô>Ð>øð	?ð 	?r   c                 óH   ‡—  G ˆfd„d| ¦  «        }d‰j         › d�|_         |S )a¥  
        Create a new class that can be used to instantiate an AsyncFileSystemWrapper
        with lazy instantiation of the underlying synchronous filesystem.

        Parameters
        ----------
        sync_fs_class : type
            The class of the synchronous filesystem to wrap.

        Returns
        -------
        type
            A new class that wraps the provided synchronous filesystem class.
        c                   ó"   •‡ — e Zd Zˆ ˆfd„Zˆ xZS )úJAsyncFileSystemWrapper.wrap_class.<locals>.GeneratedAsyncFileSystemWrapperc                 óZ   •—  ‰|i |¤Ž}t          ¦   «                              |¦  «         d S r	   )r   r   )r$   r   r   r   r)   Úsync_fs_classs       €€r   r   zSAsyncFileSystemWrapper.wrap_class.<locals>.GeneratedAsyncFileSystemWrapper.__init__u   s5   ø€ Ø'˜-¨Ð8°Ð8Ð8�Ý‘”× Ò  Ñ)Ô)Ð)Ð)Ð)r   )Ú__name__Ú
__module__Ú__qualname__r   Ú__classcell__)r)   rC   s   @€r   ÚGeneratedAsyncFileSystemWrapperrA   t   s>   øø€ € € € € ð*ð *ð *ð *ð *ð *ð *ð *ð *ð *r   rH   ÚAsyncÚWrapper)rD   )ÚclsrC   rH   s    ` r   Ú
wrap_classz!AsyncFileSystemWrapper.wrap_classc   sZ   ø€ ð"	*ð 	*ð 	*ð 	*ð 	*ð 	*ð 	*¨cñ 	*ô 	*ð 	*ð 4�MÔ*Ð3Ð3Ð3ð 	(Ô0ð /Ð.r   )NNNNNN)rD   rE   rF   Ú__doc__r"   Úcachabler   r5   r,   r#   ÚclassmethodrL   rG   )r)   s   @r   r   r   (   s¬   ø€ € € € € ð
ð 
ð /€HØ€Hð ØØØØØ!ð&ð &ð &ð &ð &ð &ð* ð,ð ,ñ „Xð,ð?ð ?ð ?ð$ ð/ð /ñ „[ð/ð /ð /ð /ð /r   r   )NN)r
   r   r2   r    Úfsspec.asynr   r   Úchainedr   r   r   r   r   r   ú<module>rR      s«   ðØ €€€Ø Ð Ð Ð Ø €€€à €€€Ø 6Ð 6Ð 6Ð 6Ð 6Ð 6Ð 6Ð 6à &Ð &Ð &Ð &Ð &Ð &ðð ð ð ð:T/ð T/ð T/ð T/ð T/˜_Ð.?ñ T/ô T/ð T/ð T/ð T/r   