Format: application/x-python-code
1 o
2
3 ��hK � @ sH d Z ddlZddlmZ ddlmZ G dd� de�ZG dd� de�Z dS ) a This module contains classes - NamedFileInTemporaryDirectory, TemporaryWorkingDirectory.
4
5 These classes add extra features such as creating a named file in temporary directory and
6 creating a context manager for the working directory which is also temporary.
7 � N)�Path)�TemporaryDirectoryc @ s2 e Zd Zd
8 dd�Zdd� ZeZdd � Zd
9 d� ZdS )�NamedFileInTemporaryDirectory�w+b�����Fc K sF t di |��| _t| jj�| }d|v rdnd}t||||d�| _dS )aN
10 Open a file named `filename` in a temporary directory.
11
12 This context manager is preferred over `NamedTemporaryFile` in
13 stdlib `tempfile` when one needs to reopen the file.
14
15 Arguments `mode` and `bufsize` are passed to `open`.
16 Rest of the arguments are passed to `TemporaryDirectory`.
17
18 �bNzutf-8)�encoding� )r �_tmpdirr �name�open�file)�self�filename�mode�bufsizeZadd_to_syspath�kwds�pathr r r �Kc:\Users\shubh\Videos\agent\nova\Lib\site-packages\IPython/utils/tempdir.py�__init__
19 s z&NamedFileInTemporaryDirectory.__init__c C s | j �� | j�� d S �N)r
20 �closer
21 �cleanup�r r r r r s
22 z%NamedFileInTemporaryDirectory.cleanupc C s | j S r )r
23 r r r r � __enter__# s z'NamedFileInTemporaryDirectory.__enter__c C s | � � d S r )r )r �type�value� tracebackr r r �__exit__&