
    h_                     T    S SK r S SKrS SKrS SKrS SKJrJr  SS jr " S S\5      rg)    N)AsyncFileSystemrunning_asyncc                 J   ^ ^ [         R                  " T 5      U U4S j5       nU$ )ai  
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                    >#    T(       a>  T IS h  vN   [         R                  " T/U Q70 UD6I S h  vN sS S S 5      IS h  vN   $ [         R                  " T/U Q70 UD6I S h  vN $  NY N9 N+! , IS h  vN  (       d  f       N?= f N$7fN)asyncio	to_thread)argskwargsfunc	semaphores     ]/var/www/fran/franai/venv/lib/python3.13/site-packages/fsspec/implementations/asyn_wrapper.pywrapperasync_wrapper.<locals>.wrapper   sg      y$..tEdEfEE !yy&&t=d=f=== !E !yyy=s_   BA+BA1A-A1BA/"B&B'B-A1/B1B7A:8BB)	functoolswraps)r   objr   r   s   ` ` r   async_wrapperr   	   s'    & __T> > N    c                   j   ^  \ rS rSrSrSrSr      S
U 4S jjr\S 5       r	S r
\S 5       rS	rU =r$ )AsyncFileSystemWrapper&   a8  
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                    > Uc
  [        5       n[        TU ]  " SSU0UD6  Ub  Xl        O[        R
                  " U40 UD6U l        U R                  R                  U l        XPl        U R                  5         g )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   AsyncFileSystemWrapper.__init__6   sj     (?L=l=f=>L!,,_OODL--"##%r   c                 4    SU R                   R                   3$ )Nasync_)r   fsid)r$   s    r   r-   AsyncFileSystemWrapper.fsidK   s    ))*++r   c                    S1n[        U R                  5       H  nUR                  S5      (       d  X!;   a  M   [        R                  " U R                  U5      n[        U[        5      (       a  MX  [        U R                  U5      n[        U5      (       d  M  [        R                  " U5      (       a  M  [        X@U R                  S9n[        U SU 3U5        M     g)zW
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#   -AsyncFileSystemWrapper._wrap_all_sync_methodsO   s     #8t||,K%%c**k.M))$,,DD$))T\\;7F(C(CF(K(K,VX+/> -r   c                 N   ^  " U4S jSU 5      nSTR                    S3Ul         U$ )aM  
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                   ,   >^  \ rS rSrU U4S jrSrU =r$ )JAsyncFileSystemWrapper.wrap_class.<locals>.GeneratedAsyncFileSystemWrapperr   c                 4   > T" U0 UD6n[         TU ]  U5        g r   )r   r   )r$   r
   r   r   r)   sync_fs_classs       r   r   SAsyncFileSystemWrapper.wrap_class.<locals>.GeneratedAsyncFileSystemWrapper.__init__s   s    '88 )r   r   )__name__
__module____qualname____firstlineno__r   __static_attributes____classcell__)r)   rG   s   @r   GeneratedAsyncFileSystemWrapperrD   r   s    * *r   rO   AsyncWrapper)rI   )clsrG   rO   s    ` r   
wrap_class!AsyncFileSystemWrapper.wrap_classa   s4    "	*c 	* M**+73 	(0 /.r   )r"   r   r   )NNNNNN)rI   rJ   rK   rL   __doc__r"   cachabler   r7   r-   r#   classmethodrS   rM   rN   )r)   s   @r   r   r   &   sZ    
 /HH !&* , ,?$ / /r   r   )NN)	r   r   r4   r    fsspec.asynr   r   r   r   r   r   r   <module>rY      s'        6:T/_ T/r   