
    g(                        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 jD                  dk\  r	 	 	 	 	 	 	 	 	 	 	 d"dZn	 	 	 	 	 	 	 	 	 	 d#dZ	 	 	 	 	 	 	 	 	 d$dZ	 	 	 	 	 	 	 	 	 	 d%dZd&dZe jD                  dk\  r	 	 	 	 	 	 	 	 	 	 	 	 	 d'dZ#n	 	 	 	 	 	 	 	 	 	 	 	 d(dZ#	 	 	 	 	 	 	 	 	 	 d%dZ$	 d&dZ% G d de      Z&edddd       Z'e'jQ                  e	      dddd       Z)e'jQ                  e      dddd       Z)e'jQ                  e      e'jQ                  e      dddd               Z)e'jQ                  e      dddd!       Z)y))    N)partialsingledispatch)BufferedRandomBufferedReaderBufferedWriterFileIO
TextIOBase)NamedTemporaryFile)SpooledTemporaryFile)TemporaryDirectory)TemporaryFile)_TemporaryFileWrapper   )AiofilesContextManager)AsyncBufferedIOBaseAsyncBufferedReaderAsyncFileIOAsyncTextIOWrapper   )AsyncSpooledTemporaryFileAsyncTemporaryDirectory)r
   r   r   r   )      c                 B    t        t        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(   s              O/var/www/openai/venv/lib/python3.12/site-packages/aiofiles/tempfile/__init__.pyr
   r
      s=     &#! /!
 	
    c
                 @    t        t        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(   s
             r+   r
   r
   ?   s:     &#!!
 	
r,   c	                 >    t        t        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(   s	            r+   r   r   ]   s7     "	
 r,   c
                 >    t        t        | |||||||||	
            S )z#Async open a spooled temporary file
max_sizer   r   r    r!   r"   r#   r$   r'   r(   )r   _spooled_temporary_filer0   s
             r+   r   r   y   s7     "	
 r,   c           	      4    t        t        | ||||            S )z Async open a temporary directoryr"   r#   r$   r'   r(   )AiofilesContextManagerTempDir_temporary_directoryr4   s        r+   r   r      s"    (&cx	
 r,   c                 l  K   |
t        j                         }
| rt        t        |||||||||	
      }nt        t        |||||||      }|
j                  ||       d{   }t        |      t        u r,t        |j                  ||
|      }|j                  |_
        |S t        |||
|      S 7 Pw):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(   r1   cbfresults                   r+   r*   r*      s       <++-D&#! /B !#!	B &&x44 7..!&&!$BFYYFNM 14(;; 5s   AB4!B2"AB4c                 j  K   |	t        j                         }	| rt        t        ||||||||	      }nt        t        |||||||      }|	j                  |
|       d{   }t        |      t        u r,t        |j                  ||	|
      }|j                  |_
        |S t        |||	|
      S 7 Pw)r8   N)r   r   r    r!   r"   r#   r$   r%   r9   r:   )r;   r<   r   r=   r>   r?   r@   rA   rB   rC   r%   )r   r   r   r    r!   r"   r#   r$   r%   r'   r(   r1   rE   rF   rG   s                  r+   r*   r*      s      <++-D&#!
B !#!	B &&x44 7..!&&!$BFHHFMM 14(;; 5s   AB3 B1!AB3c
                    K   |t        j                         }t        t        | |||||||	      }
|j	                  |	|
       d{   }t        |||	      S 7 w)z2Open a spooled temporary file with async interfaceN)r1   r   r   r    r!   r"   r#   r$   r:   )r;   r<   r   syncSpooledTemporaryFiler?   r   )r1   r   r   r    r!   r"   r#   r$   r'   r(   rE   rF   s               r+   r2   r2     sm      |'')	 

B ""8R00A %QTHEE 	1s   AAAAc                    K   |t        j                         }t        t        | ||      }|j	                  ||       d{   }t        |||      S 7 w)z?Async method to open a temporary directory with async interfaceNr:   )r;   r<   r   syncTemporaryDirectoryr?   r   )r"   r#   r$   r'   r(   rE   rF   s          r+   r6   r6   8  sU      |'')	'	=B""8R00A"14(CC 	1s   >A AAc                       e Zd ZdZd Zy)r5   zGWith returns the directory location, not the object (matching sync lib)c                 l   K   | j                    d {   | _        | j                  j                  S 7 w)N)_coro_objname)selfs    r+   
__aenter__z(AiofilesContextManagerTempDir.__aenter__H  s'     **$	yy~~ %s   42 4N)__name__
__module____qualname____doc__rS    r,   r+   r5   r5   E  s
    Qr,   r5   r:   c                6    t        dj                  |             )z=Wrap the object with interface based on type of underlying IOzUnsupported IO type: {})	TypeErrorformatbase_io_objrC   r'   r(   s       r+   rB   rB   M  s     -44[A
BBr,   c                    t        |||      S Nr:   r   r\   s       r+   _r`   S  s    dAAr,   c                    t        |||      S r_   )r   r\   s       r+   r`   r`   X  s    t$BBr,   c                    t        |||      S r_   )r   r\   s       r+   r`   r`   ]  s     t$BBr,   c                    t        |||      S r_   )r   r\   s       r+   r`   r`   c  s    t$::r,   )w+bNNNNNTTNN)
rd   re   NNNNNTNN)	rd   re   NNNNNNN)
r   rd   re   NNNNNNN)NNNNN)Trd   re   NNNNNTTNNr   )Trd   re   NNNNNTNNr   )*r;   	functoolsr   r   ior   r   r   r   r	   tempfiler
   r=   r   rJ   r   rL   r   r>   r   rA   baser   threadpool.binaryr   r   r   threadpool.textr   	temptypesr   r   sys__all__version_infor*   r2   r6   r5   rB   registerr`   rX   r,   r+   <module>rq      sH    - Q Q A E A 7 F ) U U 0 I 
 w 
D 
> 
	: 		: w 6<v 5<r 		FF =A
D$:  $(4 C C
 z!% B B ~!% C C ~~!% C  C v!% ; ;r,   