Format: application/x-python-code
1 o
2
3 ��hB � @ s� d Z ddlZddlZddlZddlZddlmZ ddlmZ ddl m
4 Z
5 ddlmZm
6 Z
7 G dd � d e�Zdd
8 d�Zdd
9 d�Ze
10 dd� �Ze
11 dd� �ZdS )z
12 IO related utilities.
13 � N)�Path)�warn)�undoc� )�
14 CapturedIO�capture_outputc @ sB e Zd ZdZddd�Zdd� Zdd � Zd
15 d� Zdd
16 � Zdd� Z dS )�Teez�A class to duplicate an output stream to stdout/err.
17
18 This works in a manner very similar to the Unix 'tee' command.
19
20 When the object is closed or deleted, it closes the original file given to
21 it for duplication.
22 �w�stdoutc C sx |dvr
23 t d| ��t|d�rt|d�r|| _nd|v rdnd}t|||d�| _|| _tt|�| _tt|| � d | _ dS )
24 aN Construct a new Tee object.
25
26 Parameters
27 ----------
28 file_or_name : filename or open filehandle (writable)
29 File that will be duplicated
30 mode : optional, valid mode for open().
31 If a filename was give, open with this mode.
32 channel : str, one of ['stdout', 'stderr']
33 )r
34 �stderrzInvalid channel spec %s�write�seek�bN�utf-8��encodingF)
35 �
36 ValueError�hasattr�file�open�channel�getattr�sys�ostream�setattr�_closed)�selfZfile_or_name�moder r � r �Fc:\Users\shubh\Videos\agent\nova\Lib\site-packages\IPython/utils/io.py�__init__ s
37 zTee.__init__c C s, | � � tt| j| j� | j�� d| _dS )z'Close the file and restore the channel.TN)�flushr r r r r �closer �r r r r r"