← back to Atmos Game

assets/gen/.venv/lib/python3.12/site-packages/anyio/_core/__pycache__/_tempfile.cpython-312.pyc

211 lines

�

c�bj�L���ddlmZddlZddlZddlZddlmZddlmZm	Z	ddl
mZddlm
Z
mZmZmZmZddlmZdd	lmZdd
lmZe
rddlmZmZmZmZGd�d
ee�ZGd�dee�ZGd�dee�ZGd�dee�Z e				d									dd��Z!e				d									dd��Z!				d									dd�Z!e			d 							d!d��Z"e			d 							d"d��Z"			d 							d#d�Z"d$d�Z#d%d�Z$y)&�)�annotationsN)�Iterable)�BytesIO�
TextIOWrapper)�
TracebackType)�
TYPE_CHECKING�Any�AnyStr�Generic�overload�)�	to_thread)�	AsyncFile)�checkpoint_if_cancelled)�OpenBinaryMode�OpenTextMode�ReadableBuffer�WriteableBufferc��eZdZUdZded<e							ddd�																	d
d��Ze						ddd�																	dd��Z							ddd�																	dd	�Zdd
�Z								dd�Zy)�
TemporaryFilea�
    An asynchronous temporary file that is automatically created and cleaned up.

    This class provides an asynchronous context manager interface to a temporary file.
    The file is created using Python's standard `tempfile.TemporaryFile` function in a
    background thread, and is wrapped as an asynchronous file using `AsyncFile`.

    :param mode: The mode in which the file is opened. Defaults to "w+b".
    :param buffering: The buffering policy (-1 means the default buffering).
    :param encoding: The encoding used to decode or encode the file. Only applicable in
        text mode.
    :param newline: Controls how universal newlines mode works (only applicable in text
        mode).
    :param suffix: The suffix for the temporary file name.
    :param prefix: The prefix for the temporary file name.
    :param dir: The directory in which the temporary file is created.
    :param errors: The error handling scheme used for encoding/decoding errors.
    �AsyncFile[AnyStr]�_async_file.��errorsc��y�N��	�self�mode�	buffering�encoding�newline�suffix�prefix�dirrs	         �l/Users/macstudio3/Projects/atmos-game/assets/gen/.venv/lib/python3.12/site-packages/anyio/_core/_tempfile.py�__init__zTemporaryFile.__init__/����c��yrrrs	         r'r(zTemporaryFile.__init__<r)r*Nc�t�||_||_||_||_||_||_||_||_yr�r r!r"r#r$r%r&rrs	         r'r(zTemporaryFile.__init__Js<����	�"��� ��
����"(���"(���"�����r*c���K�tj�fd���d{���}t|��_�jS7� �w)Nc
����tj�j�j�j�j
�j�j�j�j��S)Nr)
�tempfilerr r!r"r#r$r%r&r�rs�r'�<lambda>z*TemporaryFile.__aenter__.<locals>.<lambda>asH���H�*�*��	�	�����
�
��������������{�{�	r*�r�run_syncrr�r�fps` r'�
__aenter__zTemporaryFile.__aenter___s@������%�%�	
�
�
��%�R�=�������
���A�A�!Ac��TK�|jj��d{���y7��wr�r�aclose�r�exc_type�	exc_value�	tracebacks    r'�	__aexit__zTemporaryFile.__aexit__o� �������%�%�'�'�'���(�&�(�.......)rzTemporaryFile[bytes]r rr!�intr"�
str | Noner#rEr$rEr%rEr&rErrE)......)rzTemporaryFile[str]r rr!rDr"rEr#rEr$rEr%rEr&rErrE)�w+b�����NNNNN)r zOpenTextMode | OpenBinaryModer!rDr"rEr#rEr$rEr%rEr&rErrE�return�None�rHr�r=ztype[BaseException] | Noner>zBaseException | Noner?zTracebackType | NonerHrI�	�__name__�
__module__�__qualname__�__doc__�__annotations__rr(r7r@rr*r'rrs����&#�"�
� #��"�!� � ���!��"�������	�
���
�����������"�!� � ���!�� �������	�
���
���������/4��#�"�!�!���"��+�����	�
���
�������
��* � (�,�(�(�(�(�	(�

�(r*rc�2�eZdZUdZded<e								d
ddd�																					dd��Ze							dddd�																					dd��Z								ddd	d�																					dd
�Zdd�Z								dd�Zy)�NamedTemporaryFilea|
    An asynchronous named temporary file that is automatically created and cleaned up.

    This class provides an asynchronous context manager for a temporary file with a
    visible name in the file system. It uses Python's standard
    :func:`~tempfile.NamedTemporaryFile` function and wraps the file object with
    :class:`AsyncFile` for asynchronous operations.

    :param mode: The mode in which the file is opened. Defaults to "w+b".
    :param buffering: The buffering policy (-1 means the default buffering).
    :param encoding: The encoding used to decode or encode the file. Only applicable in
        text mode.
    :param newline: Controls how universal newlines mode works (only applicable in text
        mode).
    :param suffix: The suffix for the temporary file name.
    :param prefix: The prefix for the temporary file name.
    :param dir: The directory in which the temporary file is created.
    :param delete: Whether to delete the file when it is closed.
    :param errors: The error handling scheme used for encoding/decoding errors.
    :param delete_on_close: (Python 3.12+) Whether to delete the file on close.
    rr.)r�delete_on_closec	��yrr�rr r!r"r#r$r%r&�deleterrTs           r'r(zNamedTemporaryFile.__init__����r*c	��yrrrVs           r'r(zNamedTemporaryFile.__init__�rXr*NTc	
�l�|||||||||	d�	|_tjdk\r|
|jd<yy)N)	r r!r"r#r$r%r&rWr���rT)�_params�sys�version_inforVs           r'r(zNamedTemporaryFile.__init__�sL���"� �������
(
������w�&�.=�D�L�L�*�+�'r*c���K�tj�fd���d{���}t|��_�jS7� �w)Nc�B��tjdi�j��S�Nr)r0rSr^r1s�r'r2z/NamedTemporaryFile.__aenter__.<locals>.<lambda>�s���H�/�/�?�$�,�,�?r*r3r5s` r'r7zNamedTemporaryFile.__aenter__�s>������%�%�?�
�
��%�R�=�������	
�r8c��TK�|jj��d{���y7��wrr:r<s    r'r@zNamedTemporaryFile.__aexit__�rArB�........)rzNamedTemporaryFile[bytes]r rr!rDr"rEr#rEr$rEr%rEr&rErW�boolrrErTrfrC)rzNamedTemporaryFile[str]r rr!rDr"rEr#rEr$rEr%rEr&rErWrfrrErTrf)rFrGNNNNNT)r �OpenBinaryMode | OpenTextModer!rDr"rEr#rEr$rEr%rEr&rErWrfrrErTrfrHrIrJrKrLrr*r'rSrSxs���,#�"�
� #��"�!� � ���
�!� #�
�'�
��
��
��	
�
�
��

��
��
��
��
��
��
���"�!� � ���
�!� #�
�%�
��
��
��	
�
�
��

��
��
��
��
��
��
�"/4��#�"�!�!���>�"� $�>�+�>��>��	>�
�>��
>��>��>��>��>��>�
�>�8 �(�,�(�(�(�(�	(�

�(r*rSc�B��eZdZUdZdZded<e								ddd�																			dd��Ze								ddd�																			d d��Z								d!d	d�																			d"�fd
�Zd#�fd�Zd#d�Z	d#d
�Z
ed$d��Zd%d&�fd�
Z
d%d'�fd�
Zd(�fd�Zd)�fd�Zd*�fd�Zd*�fd�Zej(fd+�fd�
Zd,�fd�Zd-d.�fd�
Zed/d��Zed0d��Zd1�fd�Ze						d2d��Ze						d3d��Zd4�fd�Z�xZS)5�SpooledTemporaryFilea�
    An asynchronous spooled temporary file that starts in memory and is spooled to disk.

    This class provides an asynchronous interface to a spooled temporary file, much like
    Python's standard :class:`~tempfile.SpooledTemporaryFile`. It supports asynchronous
    write operations and provides a method to force a rollover to disk.

    :param max_size: Maximum size in bytes before the file is rolled over to disk.
    :param mode: The mode in which the file is opened. Defaults to "w+b".
    :param buffering: The buffering policy (-1 means the default buffering).
    :param encoding: The encoding used to decode or encode the file (text mode only).
    :param newline: Controls how universal newlines mode works (text mode only).
    :param suffix: The suffix for the temporary file name.
    :param prefix: The prefix for the temporary file name.
    :param dir: The directory in which the temporary file is created.
    :param errors: The error handling scheme used for encoding/decoding errors.
    Frf�_rolled.rc	��yrr�
r�max_sizer r!r"r#r$r%r&rs
          r'r(zSpooledTemporaryFile.__init__����r*c	��yrrrls
          r'r(zSpooledTemporaryFile.__init__�rnr*Nc		���||||||||	d�|_||_d|vrt�
|�
t	��yt�
|�
tt	�||	|d���y)Nr-�bT)r"rr#�
write_through)�_tempfile_params�	_max_size�superr(rr)rrmr r!r"r#r$r%r&r�	__class__s          �r'r(zSpooledTemporaryFile.__init__sl����"� ������	1
���"����$�;��G��W�Y�'��G����I�%�!�#�"&��
r*c���K�|js|jj�yt�|���d{���y7��wr)rj�_fp�closerur;�rrvs �r'r;zSpooledTemporaryFile.aclose3s/������|�|��H�H�N�N����g�n����s�9A�A�Ac��K�|js'|jj�|jkry|j	��d{���y7��wr)rjrx�tellrt�rolloverr1s r'�_checkzSpooledTemporaryFile._check:s4�����<�<�4�8�8�=�=�?�d�n�n�<���m�m�o���s�AA�
A�Ac��0�K��jryd�_�j}|jd�tj�fd���d{����_�j|j
���d{���|j�y7�A7��w)NTrc�B��tjdi�j��Src)r0rrsr1s�r'r2z/SpooledTemporaryFile.rollover.<locals>.<lambda>Hs���H�*�*�C�T�-B�-B�Cr*)rjrx�seekrr4�write�readry)r�buffers` r'r}zSpooledTemporaryFile.rollover@st������<�<������������A��"�+�+�C�
�
����j�j�����'�'�'�����	
��	(�s$�A
B�B�+B�<B�=B�Bc�.�|jjSr)rx�closedr1s r'r�zSpooledTemporaryFile.closedMs���x�x���r*c���K�|js-t��d{���|jj|�St�|�
|��d{���S7�67��wr)rjrrxr�ru�r�sizervs  �r'r�zSpooledTemporaryFile.readQsJ������|�|�)�+�+�+��8�8�=�=��&�&��W�\�$�'�'�'�
,��(��!�A�A�1A�A�A�Ac���K�|js-t��d{���|jj|�St�|�
|��d{���S7�67��wr)rjrrx�read1rur�s  �r'r�zSpooledTemporaryFile.read1XsJ������|�|�)�+�+�+��8�8�>�>�$�'�'��W�]�4�(�(�(�
,��)�r�c���K�|js,t��d{���|jj�St�|�
��d{���S7�47��wr)rjrrx�readlinerurzs �r'r�zSpooledTemporaryFile.readline_sI������|�|�)�+�+�+��8�8�$�$�&�&��W�%�'�'�'�
,��(��!�A�A�/A�
A�A�Ac���K�|js,t��d{���|jj�St�|�
��d{���S7�47��wr)rjrrx�	readlinesrurzs �r'r�zSpooledTemporaryFile.readlinesfsI������|�|�)�+�+�+��8�8�%�%�'�'��W�&�(�(�(�
,��)�r�c���K�|js-t��d{���|jj|�t�|�
|��d{���S7�67��wr)rjrrx�readintoru�rrqrvs  �r'r�zSpooledTemporaryFile.readintomsJ������|�|�)�+�+�+��H�H���a� ��W�%�a�(�(�(�
,��)�r�c���K�|js-t��d{���|jj|�t�|�|��d{���S7�67��wr)rjrrxr�ru�	readinto1r�s  �r'r�zSpooledTemporaryFile.readinto1tsJ������|�|�)�+�+�+��H�H���a� ��W�&�q�)�)�)�
,��*�r�c���K�|js.t��d{���|jj||�St�|�
||��d{���S7�87��wr)rjrrxr�ru)r�offset�whencervs   �r'r�zSpooledTemporaryFile.seek{sN������|�|�)�+�+�+��8�8�=�=���0�0��W�\�&�&�1�1�1�
,��2�s!�A�A�3A�A�A�Ac���K�|js,t��d{���|jj�St�|�
��d{���S7�47��wr)rjrrxr|rurzs �r'r|zSpooledTemporaryFile.tell�sD������|�|�)�+�+�+��8�8�=�=�?�"��W�\�^�#�#�
,��$�r�c���K�|js-t��d{���|jj|�St�|�
|��d{���S7�67��wr)rjrrx�truncaterur�s  �r'r�zSpooledTemporaryFile.truncate�sM������|�|�)�+�+�+��8�8�$�$�T�*�*��W�%�d�+�+�+�
,��,�r�c��K�y�wrr�rrqs  r'r�zSpooledTemporaryFile.write�s	����RU���c��K�y�wrrr�s  r'r�zSpooledTemporaryFile.write�s	����EH�r�c����K�|jsGt��d{���|jj|�}|j	��d{���|St
�|�
|��d{���S7�P7�7��w)a�
        Asynchronously write data to the spooled temporary file.

        If the file has not yet been rolled over, the data is written synchronously,
        and a rollover is triggered if the size exceeds the maximum size.

        :param s: The data to write.
        :return: The number of bytes written.
        :raises RuntimeError: If the underlying file is not initialized.

        N)rjrrxr�r~ru)rrq�resultrvs   �r'r�zSpooledTemporaryFile.write�sc������|�|�)�+�+�+��X�X�^�^�A�&�F��+�+�-����M��W�]�1�%�%�%�
,����&��3�A4�A.�2A4�A0�A4�)A2�*A4�0A4�2A4c��K�y�wrr�r�liness  r'�
writelineszSpooledTemporaryFile.writelines�������r�c��K�y�wrrr�s  r'r�zSpooledTemporaryFile.writelines�r�r�c����K�|jsGt��d{���|jj|�}|j	��d{���|St
�|�
|��d{���S7�P7�7��w)aw
        Asynchronously write a list of lines to the spooled temporary file.

        If the file has not yet been rolled over, the lines are written synchronously,
        and a rollover is triggered if the size exceeds the maximum size.

        :param lines: An iterable of lines to write.
        :raises RuntimeError: If the underlying file is not initialized.

        N)rjrrxr�r~ru)rr�r�rvs   �r'r�zSpooledTemporaryFile.writelines�sf������|�|�)�+�+�+��X�X�(�(��/�F��+�+�-����M��W�'��.�.�.�
,����/�r�re)r�SpooledTemporaryFile[bytes]rmrDr rr!rDr"rEr#rEr$rEr%rEr&rErrE)r�SpooledTemporaryFile[str]rmrDr rr!rDr"rEr#rEr$rEr%rEr&rErrE)rrFrGNNNNN)rmrDr rgr!rDr"rEr#rEr$rEr%rEr&rErrErHrI�rHrI)rHrf)rG)r�rDrHr
)rr�r�rDrH�bytes)rHr
)rHzlist[AnyStr])rr�rqrrHrD)r�rDr��
int | NonerHrD)rHrDr)r�r�rHrD)rr�rqrrHrD)rr�rq�strrHrD)rqzReadableBuffer | strrHrD)rr�r�zIterable[ReadableBuffer]rHrI)rr�r�z
Iterable[str]rHrI)r�z(Iterable[str] | Iterable[ReadableBuffer]rHrI)rMrNrOrPrjrQrr(r;r~r}�propertyr�r�r�r�r�r�r��os�SEEK_SETr�r|r�r�r��
__classcell__)rvs@r'riri�s�����$�G�T��
��"��"�!� � ���!��)�������	�
���
������������� ��"�!� � ���!��'�������	�
���
����������� �.3��#�"�!�!��#�"�#��#�,�#��	#�
�#��
#��#��#��#��#�
�#�J�������(�)�(�)�)�*�<>�;�;�2�$�,��U��U�
�H��H�&�(��)��2J��	
������'��0=��	
����/�/r*ric�f�eZdZdZ			d
ddd�											dd�Zdd�Z								d
d�Zdd	�Zy)�TemporaryDirectorya�
    An asynchronous temporary directory that is created and cleaned up automatically.

    This class provides an asynchronous context manager for creating a temporary
    directory. It wraps Python's standard :class:`~tempfile.TemporaryDirectory` to
    perform directory creation and cleanup operations in a background thread.

    :param suffix: Suffix to be added to the temporary directory name.
    :param prefix: Prefix to be added to the temporary directory name.
    :param dir: The parent directory where the temporary directory is created.
    :param ignore_cleanup_errors: Whether to ignore errors during cleanup
    :param delete: Whether to delete the directory upon closing (Python 3.12+).
    NFT)�ignore_cleanup_errorsrWc�X�||_||_||_||_||_d|_yr)r$r%r&r�rW�_tempdir)rr$r%r&r�rWs      r'r(zTemporaryDirectory.__init__�s/��&,���%+���"%���%:��"����<@��
r*c��b�K�|j|j|j|jd��tj
dk\r|j�d<tj�fd���d{���|_	tj|jj��d{���S7�:7��w)N)r$r%r&r�r[rWc�.��tjdi���Src)r0r�)�paramss�r'r2z/TemporaryDirectory.__aenter__.<locals>.<lambda>�s���H�/�/�9�&�9r*)r$r%r&r�r_r`rWrr4r��	__enter__)rr�s @r'r7zTemporaryDirectory.__aenter__�s�������k�k��k�k��8�8�%)�%?�%?�	"
�����w�&�#�{�{�F�8��'�0�0�9�
�
��
��'�'��
�
�(?�(?�@�@�@�
��A�s$�A-B/�0B+�15B/�&B-�'B/�-B/c��K�|j�5tj|jj|||��d{���yy7��wr)r�rr4�__exit__r<s    r'r@zTemporaryDirectory.__aexit__�sG�����=�=�$��$�$��
�
�&�&��)�Y��
�
�%�
�s�<A�A�Ac��K�|j�2tj|jj��d{���yy7��wr)r�rr4�cleanupr1s r'r�zTemporaryDirectory.cleanups6�����=�=�$��$�$�T�]�]�%:�%:�;�;�;�%�;�s�9A�A�A�NNN)r$�
AnyStr | Noner%r�r&r�r�rfrWrfrHrI�rHr�rKr�)rMrNrOrPr(r7r@r�rr*r'r�r��s���� !%� $�!�	A�',��A��A��A��	A� $�
A��A�
�A�"
A�	�,�	�(�	�(�		�

�	�<r*r�c��K�y�wrr�r$r%r&�texts    r'�mkstempr�s�����r�c��K�y�wrrr�s    r'r�r�s�����r�c��lK�tjtj||||��d{���S7��w)a�
    Asynchronously create a temporary file and return an OS-level handle and the file
    name.

    This function wraps `tempfile.mkstemp` and executes it in a background thread.

    :param suffix: Suffix to be added to the file name.
    :param prefix: Prefix to be added to the file name.
    :param dir: Directory in which the temporary file is created.
    :param text: Whether the file is opened in text mode.
    :return: A tuple containing the file descriptor and the file name.

    N)rr4r0r�r�s    r'r�r�s-����&�#�#�H�$4�$4�f�f�c�4�P�P�P�P�s�+4�2�4c��K�y�wrr�r$r%r&s   r'�mkdtempr�-s����
�r�c��K�y�wrrr�s   r'r�r�5s����

�r�c��jK�tjtj|||��d{���S7��w)a�
    Asynchronously create a temporary directory and return its path.

    This function wraps `tempfile.mkdtemp` and executes it in a background thread.

    :param suffix: Suffix to be added to the directory name.
    :param prefix: Prefix to be added to the directory name.
    :param dir: Parent directory where the temporary directory is created.
    :return: The path of the created temporary directory.

    N)rr4r0r�r�s   r'r�r�=s+���� �#�#�H�$4�$4�f�f�c�J�J�J�J�s�*3�1�3c��dK�tjtj��d{���S7��w)z�
    Asynchronously return the name of the directory used for temporary files.

    This function wraps `tempfile.gettempdir` and executes it in a background thread.

    :return: The path of the temporary directory as a string.

    N)rr4r0�
gettempdirrr*r'r�r�Ps%�����#�#�H�$7�$7�8�8�8�8���'0�.�0c��dK�tjtj��d{���S7��w)z�
    Asynchronously return the name of the directory used for temporary files in bytes.

    This function wraps `tempfile.gettempdirb` and executes it in a background thread.

    :return: The path of the temporary directory as bytes.

    N)rr4r0�gettempdirbrr*r'r�r�\s%�����#�#�H�$8�$8�9�9�9�9�r�)NNNF)
r$rEr%rEr&rEr�rfrHztuple[int, str])
r$�bytes | Noner%r�r&r�r�rfrHztuple[int, bytes])
r$r�r%r�r&r�r�rfrHztuple[int, str | bytes]r�)r$rEr%rEr&rErHr�)r$r�r%r�r&r�rHr�)r$r�r%r�r&r�rHzstr | bytesr�)rHr�)%�
__future__rr�r_r0�collections.abcr�iorr�typesr�typingrr	r
rr�r�
_core._fileior�lowlevelr�	_typeshedrrrrrrSrir�r�r�r�r�rr*r'�<module>r�s+��"�	�
��$�%�����%�.��W�W�\(�G�F�O�\(�~a(����a(�Hg/�9�V�,�g/�T<<����<<�~
�����	�����
���	�
��
��
�����	�����
���	�
��
��!� ���	Q��Q��Q�
�Q��	Q�
�Q�,
���������
��	�	�
��
���������
���	�
��!� ��K��K��K�
�K��	K�&	9�	:r*