
    2'h
                     J    d dl Z d dlZd dlZd dlmZmZ ddZ G d de      Zy)    N)AsyncFileSystemrunning_asyncc                 B     t        j                          fd       }|S )aF  
    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.

    Returns
    -------
    coroutine
        An awaitable version of the function.
    c                  R   K   t        j                  g| i | d {   S 7 wN)asyncio	to_thread)argskwargsfuncs     j/home/kushmeetdev/Regenta/Chatbot/venv/lib/python3.12/site-packages/fsspec/implementations/asyn_wrapper.pywrapperzasync_wrapper.<locals>.wrapper   s(     &&t=d=f====s   '%')	functoolswraps)r   objr   s   `  r   async_wrapperr      s'    " __T> > N    c                   V     e Zd ZdZdZdZd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.
    r   FN)asynchronousc                    |
t               }t        |   |d|i| || _        | j                  j                  | _        | j                          y )Nr   )r   super__init__sync_fsprotocol_wrap_all_sync_methods)selffsr   r
   r   	__class__s        r   r   zAsyncFileSystemWrapper.__init__0   sK    (?L$D\DVD--##%r   c                 4    d| j                   j                   S )Nasync_)r   fsid)r   s    r   r"   zAsyncFileSystemWrapper.fsid8   s    ))*++r   c                 v   dh}t        | j                        D ]  }|j                  d      s||v rt        j                  | j                  |      }t        |t              rJt        | j                  |      }t        |      slt        j                  |      rt        ||       }t        | d| |        y)zg
        Wrap all synchronous methods of the underlying filesystem with asynchronous versions.
        open_)r   N)dirr   
startswithinspectgetattr_static
isinstancepropertygetattrcallabler   iscoroutinefunctionr   setattr)r   excluded_methodsmethod_nameattrmethodasync_methods         r   r   z-AsyncFileSystemWrapper._wrap_all_sync_methods<   s     #8t||, 	?K%%c*k=M.M))$,,DD$)T\\;7F(C(CF(K,V>+/>	?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   r9   s   @r   GeneratedAsyncFileSystemWrapperr7   _   s    * *r   r>   AsyncWrapper)r:   )clsr9   r>   s    ` r   
wrap_classz!AsyncFileSystemWrapper.wrap_classN   s4    "	*c 	* M**+73 	(0 /.r   )r:   r;   r<   __doc__r   cachabler   r+   r"   r   classmethodrB   r=   )r   s   @r   r   r       sI    
 HH/3 & , ,?$ / /r   r   r   )r   r   r(   fsspec.asynr   r   r   r    r   r   <module>rH      s$       60G/_ G/r   