
    Evg	                     ~    d Z ddlZddlZddlmZ dZej        dk    r G d de          ZeZnej        Zej	        Z	dS )a6  
The temp module provides a NamedTemporaryFile that can be reopened in the same
process on any platform. Most platforms use the standard Python
tempfile.NamedTemporaryFile class, but Windows users are given a custom class.

This is needed because the Python implementation of NamedTemporaryFile uses the
O_TEMPORARY flag under Windows, which prevents the file from being reopened
if the same flag is not provided [1][2]. Note that this does not address the
more general issue of opening a file for writing and reading in multiple
processes in a manner that works across platforms.

The custom version of NamedTemporaryFile doesn't support the same keyword
arguments available in tempfile.NamedTemporaryFile.

1: https://mail.python.org/pipermail/python-list/2005-December/336957.html
2: https://bugs.python.org/issue14243
    N)FileProxyMixin)NamedTemporaryFile
gettempdirntc                   @    e Zd ZdZddZej        Zd Zd Zd	 Z	d
 Z
dS )TemporaryFilea.  
        Temporary file object constructor that supports reopening of the
        temporary file in Windows.

        Unlike tempfile.NamedTemporaryFile from the standard library,
        __init__() doesn't support the 'delete', 'buffering', 'encoding', or
        'newline' keyword arguments.
        w+b Nc                     t          j        |||          \  }}|| _        t          j        |||          | _        d| _        d S )N)suffixprefixdirF)tempfilemkstempnameosfdopenfileclose_called)selfmodebufsizer   r   r   fdr   s           S/var/www/pixelcanvas.ch/venv/lib/python3.11/site-packages/django/core/files/temp.py__init__zTemporaryFile.__init__*   sG    'vf#NNNHBDI	"dG44DI %D    c                     | j         s`d| _         	 | j                                         n# t          $ r Y nw xY w	 |                     | j                   d S # t          $ r Y d S w xY wd S )NT)r   r   closeOSErrorunlinkr   r   s    r   r   zTemporaryFile.close5   s    $ 	$(!IOO%%%%   DKK	*****   DD	 	s   * 
77A 
A%$A%c                 .    |                                   d S N)r   r"   s    r   __del__zTemporaryFile.__del__A   s    JJLLLLLr   c                 8    | j                                          | S r$   )r   	__enter__r"   s    r   r'   zTemporaryFile.__enter__D   s    I!!!Kr   c                 >    | j                             |||           d S r$   )r   __exit__)r   excvaluetbs       r   r)   zTemporaryFile.__exit__H   s"    IsE2.....r   )r	   r
   r   r   N)__name__
__module____qualname____doc__r   r   r!   r   r%   r'   r)    r   r   r   r       sw        	 		& 	& 	& 	& 
	 
	 
		 	 		 	 		/ 	/ 	/ 	/ 	/r   r   )
r0   r   r   django.core.files.utilsr   __all__r   r   r   r   r1   r   r   <module>r4      s    $ 
			  2 2 2 2 2 2 7d??)/ )/ )/ )/ )/ )/ )/ )/V '!4 


r   