Файловый менеджер - Редактировать - /opt/imh-python/lib/python3.9/site-packages/IPython/core/magics/__pycache__/history.cpython-39.pyc
Ðазад
a o�hT1 � @ s� d Z ddlZddlZddlmZ ddlZddlmZ ddl m Z mZmZ ddl mZmZmZ ddlmZ ddlmZ e� ZeG d d � d e ��ZdS )z6Implementation of magic functions related to History. � N)�open)�StdinNotImplementedError)�Magics�magics_class� line_magic)�argument�magic_arguments�parse_argstring)�skip_doctest)�ioc @ s� e Zd Ze� edddddd�eddddd d�ed ddddd�ed ddddd�edddd�edddddd�eddededd �ed!d"dd#d$�ed%dd&�eed.d(d)�������������Z ed*d+� �Z ed/d,d-��ZdS )0� HistoryMagicsz-n� print_nums� store_trueFz{ print line numbers for each input. This feature is only available if numbered prompts are in use. )�dest�action�default�helpz-o� get_outputz"also print outputs for each input.z-p� pypromptsz� print classic '>>>' python prompts before each input. This is useful for making documentation, and in conjunction with -o, for producing doctest-ready output. z-t�raw�store_falseTa� print the 'translated' history, as IPython understands it. IPython filters your input and converts it all into valid Python source before executing it (things like magics or aliases are turned into function calls, for example). With this option, you'll see the native history instead of the user-entered version: '%%cd /' will be seen as 'get_ipython().run_line_magic("cd", "/")' instead of '%%cd /'. z-f�filenamea� FILENAME: instead of printing the output to the screen, redirect it to the given file. The file is always overwritten, though *when it can*, IPython asks for confirmation first. In particular, running the command 'history -f FILENAME' from the IPython Notebook interface will replace FILENAME even if it already exists *without* confirmation. )r r z-g�pattern�*Nac treat the arg as a glob pattern to search for in (full) history. This includes the saved history (almost all commands ever written). The pattern may contain '?' to match one unknown character and '*' to match any number of unknown characters. Use '%%hist -g' to show full saved history (may be very long). )r �nargsr r z-l�limit�?z� get the last n lines from all sessions. Specify n as a single arg, or the default is the last 10 lines. )r �typer r r z-u�uniquezN when searching history using `-g`, show only unique history. )r r r �range)r � c sx t | j|�}| jj� � fdd�}|j}|s6tj}d}nltj� |�}tj� |�r�zt�d| �}W n t yv d}Y n0 |s�td� dS td� t|d d d�}d}|j}|j} |j} |j}d}|jtu r�dn|j} d}|jdu�r(|j�s(|j�rdd �|j� d }nd}� j||| | |jd�}d}nf|jtu�rX| du �rBdn| }� j||| d�}n6|j�rxdd �|j� d }d}� �d �|j�|| �}d}|D ]�\}}}| �r�|\}}|�r�t�||��sƐq�|�d��� }d|v }|�r�dnd }|�rtd|||�� |�|f |dd� | �r>tdd|d� |�r>d�|�!� �d }t||d� | �r�|�r�t||d� �q�|�rt|�"� dS )a� Print input history (_i<n> variables), with most recent last. By default, input history is printed without line numbers so it can be directly pasted into an editor. Use -n to show them. By default, all input history from the current session is displayed. Ranges of history can be indicated using the syntax: ``4`` Line 4, current session ``4-6`` Lines 4-6, current session ``243/1-5`` Lines 1-5, session 243 ``~2/7`` Line 7, session 2 before current ``~8/1-~6/5`` From the first line of 8 sessions ago, to the fifth line of 6 sessions ago. Multiple ranges can be entered, separated by spaces The same syntax is used by %macro, %save, %edit, %rerun Examples -------- :: In [6]: %history -n 4-6 4:a = 12 5:print a**2 6:%history -n 4-6 c s"