Ë
    ÞXËh<  ã                   óR   — d Z ddlZddlmZ ddlmZ  G d„ d«      Z G d„ de«      Zy)	a  This module contains classes - NamedFileInTemporaryDirectory, TemporaryWorkingDirectory.

These classes add extra features such as creating a named file in temporary directory and
creating a context manager for the working directory which is also temporary.
é    N)ÚPath)ÚTemporaryDirectoryc                   ó*   — e Zd Zdd„Zd„ ZeZd„ Zd„ Zy)ÚNamedFileInTemporaryDirectoryc                 ó    — t        di |¤Ž| _        t        | j                  j                  «      |z  }d|v rdnd}t	        ||||¬«      | _        y)aN  
        Open a file named `filename` in a temporary directory.

        This context manager is preferred over `NamedTemporaryFile` in
        stdlib `tempfile` when one needs to reopen the file.

        Arguments `mode` and `bufsize` are passed to `open`.
        Rest of the arguments are passed to `TemporaryDirectory`.

        ÚbNzutf-8)Úencoding© )r   Ú_tmpdirr   ÚnameÚopenÚfile)ÚselfÚfilenameÚmodeÚbufsizeÚadd_to_syspathÚkwdsÚpathr	   s           úI/var/www/html/myenv/lib/python3.12/site-packages/IPython/utils/tempdir.pyÚ__init__z&NamedFileInTemporaryDirectory.__init__   sK   € ô *Ñ1¨DÑ1ˆŒÜD—L‘L×%Ñ%Ó&¨Ñ1ˆØ $™;‘4¨GˆÜ˜˜t W°xÔ@ˆ	ó    c                 ól   — | j                   j                  «        | j                  j                  «        y ©N)r   Úcloser   Úcleanup©r   s    r   r   z%NamedFileInTemporaryDirectory.cleanup   s    € Ø	‰	‰ÔØ‰×ÑÕr   c                 ó   — | j                   S r   )r   r   s    r   Ú	__enter__z'NamedFileInTemporaryDirectory.__enter__#   s   € Øy‰yÐr   c                 ó$   — | j                  «        y r   )r   )r   ÚtypeÚvalueÚ	tracebacks       r   Ú__exit__z&NamedFileInTemporaryDirectory.__exit__&   s   € Ø‰r   N)éÿÿÿÿF)Ú__name__Ú
__module__Ú__qualname__r   r   Ú__del__r   r$   r
   r   r   r   r      s   „ óAò ð €Gòór   r   c                   ó,   ‡ — e Zd ZdZˆ fd„Zˆ fd„Zˆ xZS )ÚTemporaryWorkingDirectoryzÛ
    Creates a temporary directory and sets the cwd to that directory.
    Automatically reverts to previous cwd upon cleanup.
    Usage example:

        with TemporaryWorkingDirectory() as tmpdir:
            ...
    c                 ó˜   •— t        j                  «       | _        t        j                  | j
                  «       t        t        | #  «       S r   )	r   ÚcwdÚold_wdÚ_osÚchdirr   Úsuperr+   r   )r   Ú	__class__s    €r   r   z#TemporaryWorkingDirectory.__enter__4   s1   ø€ Ü—h‘h“jˆŒÜ	‰	$—)‘)ÔÜÔ.°Ñ?ÓAÐAr   c                 ól   •— t        j                  | j                  «       t        t        |   |||«      S r   )r/   r0   r.   r1   r+   r$   )r   Úexcr"   Útbr2   s       €r   r$   z"TemporaryWorkingDirectory.__exit__9   s*   ø€ Ü	‰	$—+‘+ÔÜÔ.°Ñ>¸sÀEÈ2ÓNÐNr   )r&   r'   r(   Ú__doc__r   r$   Ú__classcell__)r2   s   @r   r+   r+   *   s   ø„ ñôB÷
Oð Or   r+   )	r6   Úosr/   Úpathlibr   Útempfiler   r   r+   r
   r   r   ú<module>r;      s.   ðñó Ý Ý '÷ñ ô<OÐ 2õ Or   