o
    MK&h                     @   s\   d Z ddlmZ ddlmZ ddlmZ G dd dZG dd deZG d	d
 d
eeZ	dS )zVarious base classes.    )	Awaitable)AbstractAsyncContextManager)get_running_loopc                       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 N)_file	_executor	_ref_loop)selffileloopexecutor r   @/var/www/html/venv/lib/python3.10/site-packages/aiofiles/base.py__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   '   s   zAsyncIndirectBase._filec                 C   s   d S r   r   )r
   vr   r   r   r   +   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   r+   )r
   coror   r   r   r   5   s   
zAiofilesContextManager.__init__c                 c   s$    | j d u r| j E d H | _ | j S r   )r-   r,   	__await__r   r   r   r   r/   9   s   
z AiofilesContextManager.__await__c                    s   | I d H S r   r   r   r   r   r   
__aenter__>   s   
z!AiofilesContextManager.__aenter__c                    s,   t  d | jjj|||I d H  d | _d S r   )r   run_in_executorr-   r   __exit__)r
   exc_typeexc_valexc_tbr   r   r   	__aexit__A   s
   

z AiofilesContextManager.__aexit__N)	r   r   r    __doc__	__slots__r   r/   r0   r6   r   r   r   r   r*   0   s    r*   N)
r7   collections.abcr   
contextlibr   asyncior   r   r#   r*   r   r   r   r   <module>   s    