← Back
Editing: io.cpython-311.pyc
� �@�c� � � � d Z ddlZddlZddlZddlZddlZddlmZ ddlmZ ddl m Z ddlmZm Z eej dd � � � Z ej ej � � G d� de� � Zdd �Zdd�Ze d� � � Ze d� � � ZdS )z IO related utilities. � N)�Path)�warn)�undoc� )� CapturedIO�capture_output�w�utf-8��encodingc �2 � e Zd ZdZd d�Zd� Zd� Zd� Zd� Zd S )�Teez�A class to duplicate an output stream to stdout/err. This works in a manner very similar to the Unix 'tee' command. When the object is closed or deleted, it closes the original file given to it for duplication. r �stdoutc �< � |dvrt d|z � � �t |d� � rt |d� � r|| _ nd|v rdnd}t |||�� � | _ || _ t t |� � | _ t t || � � d | _ dS ) aN Construct a new Tee object. Parameters ---------- file_or_name : filename or open filehandle (writable) File that will be duplicated mode : optional, valid mode for open(). If a filename was give, open with this mode. channel : str, one of ['stdout', 'stderr'] )r �stderrzInvalid channel spec %s�write�seek�bNr r F) � ValueError�hasattr�file�open�channel�getattr�sys�ostream�setattr�_closed)�self�file_or_name�moder r s �2/usr/lib/python3/dist-packages/IPython/utils/io.py�__init__zTee.__init__&