JFIF$        dd7 

Viewing File: /usr/lib/python3.9/site-packages/pip/_internal/utils/__pycache__/temp_dir.cpython-39.opt-1.pyc

a

[��f��@sUddlZddlZddlZddlZddlZddlmZmZddl	m
Z
mZmZm
Z
mZmZddlmZmZe�e�Zeddd�Zedd	d
d�Zdae
eed<eedd
�dd��ZGdd�d�Zdae
eed<eeed
�dd��ZGdd�d�Ze�ZGdd�d�Z Gdd�de �Z!dS)�N)�	ExitStack�contextmanager)�Any�Dict�Iterator�Optional�TypeVar�Union)�enum�rmtree�_T�
TempDirectory)�boundz	build-envzephem-wheel-cachez	req-build)Z	BUILD_ENVZEPHEM_WHEEL_CACHEZ	REQ_BUILD�_tempdir_manager��returnccsJt��0}t|}azdVW|an|a0Wd�n1s<0YdS�N)rr)�stackZold_tempdir_manager�r�@/usr/lib/python3.9/site-packages/pip/_internal/utils/temp_dir.py�global_tempdir_managers

rc@s@eZdZdZdd�dd�Zeedd�dd�Zeed	�d
d�ZdS)�TempDirectoryTypeRegistryzManages temp directory behaviorNrcCs
i|_dSr��_should_delete��selfrrr�__init__*sz"TempDirectoryTypeRegistry.__init__)�kind�valuercCs||j|<dS)z[Indicate whether a TempDirectory of the given kind should be
        auto-deleted.
        Nr)rrrrrr�
set_delete-sz$TempDirectoryTypeRegistry.set_delete�rrcCs|j�|d�S)z^Get configured auto-delete flag for a given TempDirectory type,
        default True.
        T)r�get)rrrrr�
get_delete3sz$TempDirectoryTypeRegistry.get_delete)	�__name__�
__module__�__qualname__�__doc__r�str�boolrr"rrrrr'sr�_tempdir_registryccs$t}t�aztVW|an|a0dS)zuProvides a scoped global tempdir registry that can be used to dictate
    whether directories should be deleted.
    N)r)r)Zold_tempdir_registryrrr�tempdir_registry=s
r*c@seZdZdS)�_DefaultN)r#r$r%rrrrr+Ksr+cs�eZdZdZdeddfeeeede	feed��fdd�
Z
eed�d	d
��Zed�dd�Z
eed
�dd�Zeeedd�dd�Zeed�dd�Zdd�dd�Z�ZS)r
aMHelper class that owns and cleans up a temporary directory.

    This class can be used as a context manager or as an OO representation of a
    temporary directory.

    Attributes:
        path
            Location to the created temporary directory
        delete
            Whether the directory should be deleted when exiting
            (when used as a contextmanager)

    Methods:
        cleanup()
            Deletes the temporary directory

    When used as a context manager, if the delete attribute is True, on
    exiting the context the temporary directory is deleted.
    NZtempF)�path�deleter�globally_managedcs`t���|tur$|dur d}nd}|dur6|�|�}||_d|_||_||_|r\t�	|�dS)NF)
�superr�_default�_create�_path�_deletedr-rr�
enter_context)rr,r-rr.��	__class__rrrgs

zTempDirectory.__init__rcCs|jSr)r2rrrrr,�szTempDirectory.pathcCsd|jj�d|j�d�S)N�<� �>)r6r#r,rrrr�__repr__�szTempDirectory.__repr__)rrcCs|Srrrrrr�	__enter__�szTempDirectory.__enter__)�excr�tbrcCs8|jdur|j}ntr$t�|j�}nd}|r4|��dS)NT)r-r)r"r�cleanup)rr<rr=r-rrr�__exit__�s
zTempDirectory.__exit__r cCs,tj�tjd|�d�d��}t�d|�|S)z<Create a temporary directory and store its path in self.path�pip-�-��prefix�Created temporary directory: %s)�osr,�realpath�tempfile�mkdtemp�logger�debug)rrr,rrrr1�szTempDirectory._createcCs&d|_tj�|j�sdSt|j�dS)z6Remove the temporary directory created and reset stateTN)r3rEr,�existsr2rrrrrr>�szTempDirectory.cleanup)r#r$r%r&r0rr'r	r(r+r�propertyr,r:rr;rr?r1r>�
__classcell__rrr5rr
Rs$��!
cs\eZdZdZdZd
eeedd��fdd�
Ze	ee
ed�dd	��Zeed
�dd�Z�Z
S)�AdjacentTempDirectorya�Helper class that creates a temporary directory adjacent to a real one.

    Attributes:
        original
            The original directory to create a temp directory for.
        path
            After calling create() or entering, contains the full
            path to the temporary directory.
        delete
            Whether the directory should be deleted when exiting
            (when used as a contextmanager)

    z-~.=%0123456789N)�originalr-rcs|�d�|_t�j|d�dS)Nz/\)r-)�rstriprOr/r)rrOr-r5rrr�szAdjacentTempDirectory.__init__)�namerccs�tdt|��D]D}t�|j|d�D],}dd�|�||d�}||kr$|Vq$qtt|j��D]8}t�|j|�D]$}dd�|�|}||krt|VqtqbdS)aGenerates a series of temporary names.

        The algorithm replaces the leading characters in the name
        with ones that are valid filesystem characters, but are not
        valid package names (for both Python and pip definitions of
        package).
        ��~�N)�range�len�	itertools�combinations_with_replacement�
LEADING_CHARS�join)�clsrQ�i�	candidate�new_namerrr�_generate_names�s	
�
�z%AdjacentTempDirectory._generate_namesr cCs�tj�|j�\}}|�|�D]d}tj�||�}zt�|�Wn2tyn}z|jtj	krZ�WYd}~qd}~00tj�
|�}q�qtj�
tjd|�d�d��}t
�d|�|S)Nr@rArBrD)rEr,�splitrOr_rZ�mkdir�OSError�errnoZEEXISTrFrGrHrIrJ)rr�rootrQr]r,�exrrrr1�szAdjacentTempDirectory._create)N)r#r$r%r&rYr'rr(r�classmethodrr_r1rMrrr5rrN�srN)"rcrWZloggingZos.pathrErG�
contextlibrr�typingrrrrrr	Zpip._internal.utils.miscr
rZ	getLoggerr#rIrZ
tempdir_kindsr�__annotations__rrr)r*r+r0r
rNrrrr�<module>s2
 
�

^
Back to Directory  nL+D550H?Mx ,D"v]qv;6*Zqn)ZP0!1 A "#a$2Qr D8 a Ri[f\mIykIw0cuFcRı?lO7к_f˓[C$殷WF<_W ԣsKcëIzyQy/_LKℂ;C",pFA:/]=H  ~,ls/9ć:[=/#f;)x{ٛEQ )~ =𘙲r*2~ a _V=' kumFD}KYYC)({ *g&f`툪ry`=^cJ.I](*`wq1dđ#̩͑0;H]u搂@:~וKL Nsh}OIR*8:2 !lDJVo(3=M(zȰ+i*NAr6KnSl)!JJӁ* %݉?|D}d5:eP0R;{$X'xF@.ÊB {,WJuQɲRI;9QE琯62fT.DUJ;*cP A\ILNj!J۱+O\͔]ޒS߼Jȧc%ANolՎprULZԛerE2=XDXgVQeӓk yP7U*omQIs,K`)6\G3t?pgjrmۛجwluGtfh9uyP0D;Uڽ"OXlif$)&|ML0Zrm1[HXPlPR0'G=i2N+0e2]]9VTPO׮7h(F*癈'=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