o
    MK&h(                     @   s`  d dl Z d dlmZmZ d dlmZmZmZmZm	Z	 d dl
mZ d dl
mZ d dl
mZ d dl
mZ d dl
mZ d	d
lmZ d	dlmZmZmZ d	dlmZ ddlmZmZ d dl Z g dZ!e j"dkrt											d.ddZn										d/ddZ									d0ddZ	 									d1ddZd2ddZe j"dkr													 d3ddZ#n												 d4ddZ#	 									d1d d!Z$	d2d"d#Z%G d$d% d%eZ&eddd&d'd(Z'e'(e	ddd&d)d*Z)e'(eddd&d+d*Z)e'(ee'(eddd&d,d*Z)e'(eddd&d-d*Z)dS )5    N)partialsingledispatch)BufferedRandomBufferedReaderBufferedWriterFileIO
TextIOBase)NamedTemporaryFile)SpooledTemporaryFile)TemporaryDirectory)TemporaryFile)_TemporaryFileWrapper   )AiofilesContextManager)AsyncBufferedIOBaseAsyncBufferedReaderAsyncFileIOAsyncTextIOWrapper   )AsyncSpooledTemporaryFileAsyncTemporaryDirectory)r	   r   r
   r   )      w+bTc                 C   s$   t td| |||||||||	|
dS )!Async open a named temporary fileT)namedmode	bufferingencodingnewlinesuffixprefixdirdeletedelete_on_closeloopexecutorr   _temporary_file)r   r   r    r!   r"   r#   r$   r%   r&   r'   r(    r+   M/var/www/html/venv/lib/python3.10/site-packages/aiofiles/tempfile/__init__.pyr	      s    r	   c
           
      C   s"   t td| |||||||||	dS )r   T)r   r   r   r    r!   r"   r#   r$   r%   r'   r(   r)   )
r   r   r    r!   r"   r#   r$   r%   r'   r(   r+   r+   r,   r	   ?   s   c	           	      C   s    t td| ||||||||d
S )z$Async open an unnamed temporary fileF)
r   r   r   r    r!   r"   r#   r$   r'   r(   r)   )	r   r   r    r!   r"   r#   r$   r'   r(   r+   r+   r,   r   ]   s   r   c
           
      C   s    t t| |||||||||	d
S )z#Async open a spooled temporary file
max_sizer   r   r    r!   r"   r#   r$   r'   r(   )r   _spooled_temporary_filer-   r+   r+   r,   r
   y   s   r
   c                 C   s   t t| ||||dS )z Async open a temporary directoryr"   r#   r$   r'   r(   )AiofilesContextManagerTempDir_temporary_directoryr0   r+   r+   r,   r      s
   
r   c                    s   |
du r	t  }
| rtt|||||||||	d
}ntt|||||||d}|
||I dH }t|tu rDt|j	||
|d}|j
|_
|S t|||
|dS ):Async method to open a temporary file with async interfaceN)	r   r   r    r!   r"   r#   r$   r%   r&   r   r   r    r!   r"   r#   r$   r'   r(   )asyncioget_running_loopr   syncNamedTemporaryFilesyncTemporaryFilerun_in_executortypesyncTemporaryFileWrapperwrapfile_closer)r   r   r   r    r!   r"   r#   r$   r%   r&   r'   r(   r.   cbfresultr+   r+   r,   r*      s@   r*   c                    s   |	du r	t  }	| rtt||||||||d	}ntt|||||||d}|	|
|I dH }t|tu rCt|j	||	|
d}|j
|_
|S t|||	|
dS )r3   N)r   r   r    r!   r"   r#   r$   r%   r4   r5   )r6   r7   r   r8   r9   r:   r;   r<   r=   r>   r%   )r   r   r   r    r!   r"   r#   r$   r%   r'   r(   r.   r@   rA   rB   r+   r+   r,   r*      s>   c
                    sL   |du r	t  }tt| |||||||d	}
||	|
I dH }t|||	dS )z2Open a spooled temporary file with async interfaceN)r.   r   r   r    r!   r"   r#   r$   r5   )r6   r7   r   syncSpooledTemporaryFiler:   r   )r.   r   r   r    r!   r"   r#   r$   r'   r(   r@   rA   r+   r+   r,   r/     s    r/   c                    s@   |du r	t  }tt| ||}|||I dH }t|||dS )z?Async method to open a temporary directory with async interfaceNr5   )r6   r7   r   syncTemporaryDirectoryr:   r   )r"   r#   r$   r'   r(   r@   rA   r+   r+   r,   r2   8  s   r2   c                   @   s   e Zd ZdZdd ZdS )r1   zGWith returns the directory location, not the object (matching sync lib)c                    s   | j I d H | _| jjS )N)_coro_objname)selfr+   r+   r,   
__aenter__H  s   z(AiofilesContextManagerTempDir.__aenter__N)__name__
__module____qualname____doc__rI   r+   r+   r+   r,   r1   E  s    r1   r5   c                C   s   t d| )z=Wrap the object with interface based on type of underlying IOzUnsupported IO type: {})	TypeErrorformatbase_io_objr>   r'   r(   r+   r+   r,   r=   M     r=   c                C      t |||dS Nr5   r   rP   r+   r+   r,   _S     rU   c                C   rS   rT   )r   rP   r+   r+   r,   rU   X  rV   c                C   rS   rT   )r   rP   r+   r+   r,   rU   ]  rR   c                C   rS   rT   )r   rP   r+   r+   r,   rU   c  rV   )r   r   NNNNNTTNN)
r   r   NNNNNTNN)	r   r   NNNNNNN)
r   r   r   NNNNNNN)NNNNN)Tr   r   NNNNNTTNNr   )Tr   r   NNNNNTNNr   )*r6   	functoolsr   r   ior   r   r   r   r   tempfiler	   r8   r
   rC   r   rD   r   r9   r   r<   baser   threadpool.binaryr   r   r   threadpool.textr   	temptypesr   r   sys__all__version_infor*   r/   r2   r1   r=   registerrU   r+   r+   r+   r,   <module>   s    
"




;
9
#
