Ë
    °ëjÐ  ã                   ó`   — 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
y)	é    N)ÚAsyncFileSystemÚrunning_asyncé   )ÚChainedFileSystemc                 óF   ‡ ‡— 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  — ‰r=‰4 ƒd {  –—†  t        j                  ‰g| ¢­i |¤Žƒ d {  –—† cd d d «      ƒd {  –—†  S t        j                  ‰g| ¢­i |¤Žƒ d {  –—† S 7 ŒW7 Œ87 Œ*# 1 ƒd {  –—†7  sw Y   Œ9xY w7 Œ­w©N)ÚasyncioÚ	to_thread)ÚargsÚkwargsÚfuncÚ	semaphores     €€úp/home/oem/CyberBrain26-unified/dev-env/.venv/lib/python3.12/site-packages/fsspec/implementations/asyn_wrapper.pyÚwrapperzasync_wrapper.<locals>.wrapper   sŒ   øè ø€ áØ ÷ Fñ FÜ$×.Ñ.¨tÐE°dÒE¸fÑE×E÷F÷ Fñ Fä×&Ñ& tÐ=¨dÒ=°fÑ=×=Ð=ðFøØEøðFø÷ F÷ Fñ Fúà=ús]   ƒ	BŒA$�B�A*­A&®A*±B½A(¾!BÁA?Á BÁ&A*Á(BÁ*A<Á0A3Á1A<Á8B)Ú	functoolsÚwraps)r   Úobjr   r   s   ` ` r   Úasync_wrapperr      s'   ù€ ô& ‡_�_�TÓô>ó ð>ð €Nó    c                   ó^   ‡ — 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   Fc                 ó�  •— |€
t        «       }t        ‰| �  dd|i|¤Ž |�|| _        nt	        j
                  |fi |¤Ž| _        | j                  j                  | _        | j                  j                  | _        | j                  j                  | _        | j                  j                  | _	        || _
        | j                  «        y )NÚasynchronous© )r   ÚsuperÚ__init__Úsync_fsÚfsspecÚ
filesystemÚprotocolÚroot_markerÚ_strip_protocolÚ_parentr   Ú_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ä!×,Ñ,¨_ÑOÀÑOˆDŒLØŸ™×-Ñ-ˆŒàŸ<™<×3Ñ3ˆÔØ#Ÿ|™|×;Ñ;ˆÔØ—|‘|×+Ñ+ˆŒØ"ˆŒØ×#Ñ#Õ%r   c                 ó4   — d| j                   j                  › �S )NÚasync_)r   Úfsid)r'   s    r   r/   zAsyncFileSystemWrapper.fsidQ   s   € à˜Ÿ™×)Ñ)Ð*Ð+Ð+r   c                 ó¸  — dh}t        | j                  «      D ]¿  }|j                  d«      s||v rŒt        j                  | j                  |«      }t        |t        «      rŒJt        | j                  |«      }t        |«      sŒlt        j                  |«      rŒ‚t        j                  |«      rŒ˜t        || | j                  ¬«      }t        | d|› �|«       ŒÁ y)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ÚiscoroutinefunctionÚisgeneratorfunctionr   r   Úsetattr)r'   Úexcluded_methodsÚmethod_nameÚattrÚmethodÚasync_methods         r   r&   z-AsyncFileSystemWrapper._wrap_all_sync_methodsU   s»   € ð #˜8ÐÜ˜tŸ|™|Ó,ò 	?ˆKØ×%Ñ% cÔ*¨kÐ=MÑ.MØä×)Ñ)¨$¯,©,¸ÓDˆDÜ˜$¤Ô)Øä˜TŸ\™\¨;Ó7ˆFô
 ˜Õ Ü×3Ñ3°FÕ;Ü×3Ñ3°FÕ;ä,¨V¸ÈÏÉÔX�Ü˜  + Ð/°Õ>ñ%	?r   c                 óL   ‡—  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                 ó4   •—  ‰|i |¤Ž}t         ‰| �  |«       y r	   )r   r   )r'   r   r   r   r,   Úsync_fs_classs       €€r   r   zSAsyncFileSystemWrapper.wrap_class.<locals>.GeneratedAsyncFileSystemWrapper.__init__€   s   ø€ Ù'¨Ð8°Ñ8�Ü‘Ñ  Õ)r   )Ú__name__Ú
__module__Ú__qualname__r   Ú__classcell__)r,   rG   s   @€r   ÚGeneratedAsyncFileSystemWrapperrE      s   ù„ ÷*ñ *r   rL   ÚAsyncÚWrapper)rH   )ÚclsrG   rL   s    ` r   Ú
wrap_classz!AsyncFileSystemWrapper.wrap_classn   s4   ø€ ö"	*¨cô 	*ð �M×*Ñ*Ð+¨7Ð3ð 	(Ô0ð /Ð.r   )NNNNNN)rH   rI   rJ   Ú__doc__r"   Úcachabler   r8   r/   r&   ÚclassmethodrP   rK   )r,   s   @r   r   r   (   sZ   ø„ ñ
ð /€HØ€Hð ØØØØØ!õ&ð2 ñ,ó ð,ò?ð2 ñ/ó ô/r   r   )NN)r
   r   r5   r    Úfsspec.asynr   r   Úchainedr   r   r   r   r   r   ú<module>rV      s-   ðÛ Û Û ã ß 6å &óô:_/˜_Ð.?õ _/r   