Файловый менеджер - Редактировать - /opt/imh-python/lib/python3.9/site-packages/IPython/core/magics/__pycache__/logging.cpython-39.pyc
Ðазад
a o�h� � @ sX d Z ddlZddlZddlmZmZmZ ddlmZ ddl m Z eG dd� de��ZdS )z=Implementation of magic functions for IPython's own logging. � N)�Magics�magics_class� line_magic)�warn)�Boolc @ sj e Zd ZdZeddd�jdd�Zeddd ��Zedd d��Z eddd ��Z eddd��Zeddd��ZdS )� LoggingMagicsz(Magics related to all logging machinery.FzF Suppress output of log state when logging is enabled )�helpT)�config� c C s� | � |d�\}}d|v }d|v }d|v }d|v }| jj}|rdz|�� \} } W qp |} d} Y qp0 n|j} |j} | jj}| r�tj� | �} | | j_d}z|� | || |||� W n( || j_tdt� � d � Y n�0 |r�d |_|r�| jjj} n | jjj} |�r\|j}| jjj}td t| �d �D ]6}|| | �� d � ||v �r"|t|| �d� �q"n"|�d�| d d � �� |�d� |�r�d|_| j�s�|�s�td� |�� d S )a� Start logging anywhere in a session. %logstart [-o|-r|-t|-q] [log_name [log_mode]] If no name is given, it defaults to a file named 'ipython_log.py' in your current directory, in 'rotate' mode (see below). '%logstart name' saves to file 'name' in 'backup' mode. It saves your history up to that point and then continues logging. %logstart takes a second optional parameter: logging mode. This can be one of (note that the modes are given unquoted): append Keep logging at the end of any existing file. backup Rename any existing file to name~ and start name. global Append to a single logfile in your home directory. over Overwrite any existing log. rotate Create rotating logs: name.1~, name.2~, etc. Options: -o log also IPython's output. In this mode, all commands which generate an Out[NN] prompt are recorded to the logfile, right after their corresponding input line. The output lines are always prepended with a '#[Out]# ' marker, so that the log remains valid Python code. Since this marker is always the same, filtering only the output from a log is very easy, using for example a simple awk call:: awk -F'#\[Out\]# ' '{if($2) {print $2}}' ipython_log.py -r log 'raw' input. Normally, IPython's logs contain the processed input, so that user lines are logged in their final form, converted into valid Python. For example, %Exit is logged as _ip.magic("Exit"). If the -r flag is given, all input is logged exactly as typed, with no transformations applied. -t put timestamps before each input line logged (these are put in comments). -q suppress output of logstate message when logging is invoked Zortq�o�r�t�q�backupz# IPython log file zCouldn't start log: %s� F� �outputNTzGActivating auto-logging. Current session state plus future input saved.)Z parse_options�shell�logger�split�logfname�logmodeZlogfile�os�path� expanduser�logstartr �sys�exc_info� timestampZhistory_managerZinput_hist_rawZinput_hist_parsed� log_write�output_hist�range�len�rstrip�repr�join�quiet�print�logstate)�self�parameter_s�optsZparZ log_outputZ log_raw_inputr r&