o
    LDi                     @   sp   d dl mZ d dlmZ d dlmZ d dlmZmZ dd Z	G dd dZ
G d	d
 d
e
ZG dd deeZdS )    )get_running_loop)	Awaitable)AbstractAsyncContextManager)partialwrapsc                    s    t  d d d fdd
}|S )N)loopexecutorc                    s8   | d u rt  } t g|R i |}| ||I d H S N)r   r   run_in_executor)r   r   argskwargspfuncfunc Y/var/www/www-root/data/www/77.83.87.30/venv/lib/python3.10/site-packages/aiofiles/base.pyrun   s
   zwrap.<locals>.run)r   )r   r   r   r   r   wrap   s   r   c                       s@   e Zd Zdd Zedd Zdd Z fddZd	d
 Z  Z	S )	AsyncBasec                 C   s   || _ || _|| _d S r	   )_file	_executor	_ref_loop)selffiler   r   r   r   r   __init__   s   
zAsyncBase.__init__c                 C   s   | j pt S r	   )r   r   r   r   r   r   _loop   s   zAsyncBase._loopc                 C   s   | S )zWe are our own iterator.r   r   r   r   r   	__aiter__      zAsyncBase.__aiter__c                    s   t   d t| j S )Nz
 wrapping )super__repr__reprr   r   	__class__r   r   r        s   zAsyncBase.__repr__c                    s   |   I dH  }r|S t)zSimulate normal file iteration.N)readlineStopAsyncIteration)r   liner   r   r   	__anext__#   s   zAsyncBase.__anext__)
__name__
__module____qualname__r   propertyr   r   r    r'   __classcell__r   r   r"   r   r      s    
r   c                       s6   e Zd Z fddZedd Zejdd Z  ZS )AsyncIndirectBasec                    s    || _ || _t d || d S r	   )	_indirect_namer   r   )r   namer   r   indirectr"   r   r   r   ,   s   zAsyncIndirectBase.__init__c                 C   s   |   S r	   )r.   r   r   r   r   r   1   s   zAsyncIndirectBase._filec                 C   s   d S r	   r   )r   vr   r   r   r   5   r   )r(   r)   r*   r   r+   r   setterr,   r   r   r"   r   r-   +   s    
r-   c                   @   s4   e Zd ZdZdZdd Zdd Zdd Zd	d
 ZdS )AiofilesContextManagerz/An adjusted async context manager for aiofiles._coro_objc                 C   s   || _ d | _d S r	   r5   )r   coror   r   r   r   ?   s   
zAiofilesContextManager.__init__c                 c   s$    | j d u r| j E d H | _ | j S r	   )r7   r6   	__await__r   r   r   r   r9   C   s   
z AiofilesContextManager.__await__c                    s   | I d H S r	   r   r   r   r   r   
__aenter__H   s   
z!AiofilesContextManager.__aenter__c                    s,   t  d | jjj|||I d H  d | _d S r	   )r   r
   r7   r   __exit__)r   exc_typeexc_valexc_tbr   r   r   	__aexit__K   s
   

z AiofilesContextManager.__aexit__N)	r(   r)   r*   __doc__	__slots__r   r9   r:   r?   r   r   r   r   r4   :   s    r4   N)asyncior   collections.abcr   
contextlibr   	functoolsr   r   r   r   r-   r4   r   r   r   r   <module>   s    