o a @sTdZddlZddlZddlmZdZejdkr"GdddeZeZnejZej Z dS)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 gettempdirntc@s@eZdZdZdddZejZdd Zd d Zd d Z ddZ dS) 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+bNcCs4tj|||d\}}||_t||||_d|_dS)N)suffixprefixdirF)tempfilemkstempnameosfdopenfile close_called)selfmodebufsizer r r fdrr8/usr/lib/python3/dist-packages/django/core/files/temp.py__init__%s zTemporaryFile.__init__cCsZ|js+d|_z|jWn tyYnwz ||jWdSty*YdSwdS)NT)rrcloseOSErrorunlinkrrrrrr0s  zTemporaryFile.closecCs |dSN)rrrrr__del__<s zTemporaryFile.__del__cCs|j|Sr)r __enter__rrrrr!?s zTemporaryFile.__enter__cCs|j|||dSr)r__exit__)rexcvaluetbrrrr"CszTemporaryFile.__exit__)rrr r N) __name__ __module__ __qualname____doc__rrrrr r!r"rrrrrs    r) r)rr django.core.files.utilsr__all__rrrrrrrrs  *