o
    -˜Žjþ  ã                   @   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© úJ/var/www/kodo/Anonymous/send/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    