File: //lib/python3.10/__pycache__/tempfile.cpython-310.pyc
o
    E�h�  �                   @   s�  d Z g d�ZddlZddlZddlZddlZ	z	ddl
ZejZ
W n7 eyV   ddlZddlZdd� Zdd� Ze	je	je	je	jhe	jkoNe	je	jv oNe	je	jv ZdId	d
�Z
Y nw ddlZddlm Z! ddlZddl"Z#ddl$Z%ddl&Z&e&j'Z(e	j)e	j*B e	j+B Z,e-e	d�r�e,e	j.O Z,e,Z/e-e	d
�r�e/e	j0O Z/e-e	d�r�e	j1Z1ndZ1dZ2e(� Z3dd� Z4dd� Z5dd� Z6G dd� d�Z7dd� Z8dd� Z9da:dd� Z;dd � Z<d!d"� Z=d#d$� Z>d%d&� Z?d'd(� Z@daAd)d*� ZBd+d,� ZCd-d.� ZDdJd/d0�ZEdKd1d2�ZFd3e2dfd4d5�ZGG d6d7� d7�ZHG d8d9� d9�ZI			<dLdd=�d>d?�ZJe	jKd@k�sejLdAk�r eJZMne-e	dB�aN			dMdd=�dCdD�ZMG dEdF� dF�ZOG dGdH� dH�ZPdS )Na�  Temporary files.
This module provides generic, low- and high-level interfaces for
creating temporary files and directories.  All of the interfaces
provided by this module can be used without fear of race conditions
except for 'mktemp'.  'mktemp' is subject to race conditions and
should not be used; it is provided for backward compatibility only.
The default path names are returned as str.  If you supply bytes as
input, all return values will be in bytes.  Ex:
    >>> tempfile.mkstemp()
    (4, '/tmp/tmptpu9nin8')
    >>> tempfile.mkdtemp(suffix=b'')
    b'/tmp/tmppbi8f0hy'
This module also provides some data items to the user:
  TMP_MAX  - maximum number of names that will be tried before
             giving up.
  tempdir  - If this is set to a string before the first use of
             any routine from this module, it will be considered as
             another candidate location to store temporary files.
)
�NamedTemporaryFile�
TemporaryFile�SpooledTemporaryFile�TemporaryDirectory�mkstemp�mkdtemp�mktemp�TMP_MAX�
gettempprefix�tempdir�
gettempdir�gettempprefixb�gettempdirb�    Nc              	   C   s:  zt j�| �rtd��W n ty    |t jj| t�� � Y d S w g }zt �| �}W n ty<   |t j| t�� � Y nw |D ]A}t j�| |�}zt �|�j	}W n ty[   d}Y nw t
�|�rgt||� q?zt �
|� W q? ty�   |t j
|t�� � Y q?w zt �| � W d S  ty�   |t j| t�� � Y d S w )N�%Cannot call rmtree on a symbolic linkr   )�_os�path�islink�OSError�_sys�exc_info�listdir�join�lstat�st_mode�_stat�S_ISDIR�_rmtree_unsafe�unlink�rmdir)r   �onerror�names�name�fullname�mode� r$   �/usr/lib/python3.10/tempfile.pyr   2   sB   ����
��r   c           
   
   C   s�  g }zt �| �}W n ty' } z||_|t j|t�� � W Y d }~nd }~ww |D ]�}t j�||�}z
t j|| dd�}|j	}W n tyK   d}Y nw t
�|�r�zt j|t j
| d�}	W n tyn   |t j|t�� � Y q*w zKt j�|t �|	��r�t|	||� z	t j|| d� W n* ty�   |t j|t�� � Y nw ztd�� ty�   |t jj|t�� � Y nw W t �|	� q*t �|	� w z	t j|| d� W q* ty�   |t j|t�� � Y q*w d S )NF)�dir_fd�follow_symlinksr   )r&