a
    �˜ë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                 Ÿ   s6   | d u rt ƒ } tˆ g|¢R i |¤Ž}|  ||¡I d H S ©N)r   r   Úrun_in_executor)r   r   ÚargsÚkwargsZpfunc©Úfunc© úL/mnt/bigstor/www/usecases/.venv/lib/python3.9/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	   )Ú_fileZ	_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__   s    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‚dS )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   Z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   s    )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	   r1   )r   Úcoror   r   r   r   ?   s    zAiofilesContextManager.__init__c                 c   s"   | j d u r| j ¡ E d H | _ | j S r	   )r3   r2   Ú	__await__r   r   r   r   r5   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
   r3   r   Ú__exit__)r   Úexc_typeÚexc_valÚexc_tbr   r   r   Ú	__aexit__K   s    ÿ
z AiofilesContextManager.__aexit__N)	r%   r&   r'   Ú__doc__Ú	__slots__r   r5   r6   r;   r   r   r   r   r0   :   s   r0   N)Zasyncior   Úcollections.abcr   Ú
contextlibr   Ú	functoolsr   r   r   r   r*   r0   r   r   r   r   Ú<module>   s   