← Back
Editing: tempdir.cpython-311.pyc
� �@�cK � �b � d Z ddlZddlmZ ddlmZ G d� de� � Z G d� de� � Z dS ) 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 Zd Zd d�Zd� ZeZd� Zd� ZdS ) �NamedFileInTemporaryDirectory�w+b���Fc � � t di |��| _ t | j j � � |z }d|v rdnd}t ||||�� � | _ dS )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`. �bNzutf-8)�encoding� )r �_tmpdirr �name�open�file)�self�filename�mode�bufsize�add_to_syspath�kwds�pathr s �7/usr/lib/python3/dist-packages/IPython/utils/tempdir.py�__init__z&NamedFileInTemporaryDirectory.__init__ s] � � *�1�1�D�1�1����D�L�%�&�&��1���$�;�;�4�4�G����t�W�x�@�@�@�� � � � c �j � | j � � � | j � � � d S �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�r c �. � | � � � d S r )r )r �type�value� tracebacks r �__exit__z&NamedFileInTemporaryDirectory.__exit__&