Файловый менеджер - Редактировать - /opt/imh-python/lib/python3.9/site-packages/IPython/core/__pycache__/historyapp.cpython-39.pyc
Ðазад
a o�h � @ s� d Z ddlZddlmZ ddlmZ ddlmZ ddlm Z m Z mZ dd lm Z d ZdZG dd � d e�ZG dd� de�ZG dd� de�ZdS )zb An application for managing IPython history. To be invoked as the `ipython history` subcommand. � N)�Path)�Application� )�BaseIPythonApplication)�Bool�Int�Dict� )� ask_yes_noz�Trim the IPython history database to the last 1000 entries. This actually copies the last 1000 entries to a new database, and then replaces the old file with the new. Use the `--keep=` argument to specify a number other than 1000. a Clear the IPython history database, deleting all entries. Because this is a destructive operation, IPython will prompt the user if they really want to do this. Passing a `-f` flag will force clearing without a prompt. This is an handy alias to `ipython history trim --keep=0` c @ sj e Zd ZeZeddd�jdd�Zeddd�jdd�Z e ed ddiiejfd ��Z e ed d��Zdd � ZdS )�HistoryTrimFz/Keep the old history file as history.sqlite.<N>��helpT��configi� �/Number of recent lines to keep in the database.�backup)r zHistoryTrim.keep)�keepc C s� t | jj�}|d }t�|�}t|�d| jd f��}t|�| jkr^t d| j � t d� d S t d| j � |� � |�� |r�|d d }t|�d|f��}t|�d |f��}|�� |d }d} |� � r�| d7 } |d t| � }q�t�|�} | �d� | �d� | �d � | �� |�rf| �4 | �d|� | �d|� | �d|� W d � n1 �s\0 Y | �� | j�r�d} |d| }|� � �r�| d7 } |d| }�q�|�|� t d|� n|�� |�|� d S )Nzhistory.sqlitez^SELECT session, line, source, source_raw FROM history ORDER BY session DESC, line DESC LIMIT ?r z=There are already at most %d entries in the history database.z>Not doing anything. Use --keep= argument to keep fewer entriesz/Trimming history to the most recent %d entries.r zCSELECT session, line, output FROM output_history WHERE session >= ?zMSELECT session, start, end, num_cmds, remark FROM sessions WHERE session >= ?zhistory.sqlite.newz�CREATE TABLE IF NOT EXISTS sessions (session integer primary key autoincrement, start timestamp, end timestamp, num_cmds integer, remark text)z�CREATE TABLE IF NOT EXISTS history (session integer, line integer, source text, source_raw text, PRIMARY KEY (session, line))z�CREATE TABLE IF NOT EXISTS output_history (session integer, line integer, output text, PRIMARY KEY (session, line))z'insert into sessions values (?,?,?,?,?)z$insert into history values (?,?,?,?)z)insert into output_history values (?,?,?)zhistory.sqlite.old.%dz Backed up longer history file to)r �profile_dir�location�sqlite3�connect�list�executer �len�print�pop�reverse�close�exists�str�commitZexecutemanyr �rename�unlink)�selfr Z hist_file�con�inputsZ first_session�outputs�sessionsZ new_hist_file�iZnew_dbZbackup_hist_file� r) ��/root/rpmbuild/BUILDROOT/imh-python39-modules-3.9.7-92.el8.x86_64/opt/imh-python/lib/python3.9/site-packages/IPython/core/historyapp.py�start6 s` ��� , zHistoryTrim.startN)�__name__� __module__�__qualname__�trim_hist_help�descriptionr �tagr r r r �dictr �flags�aliasesr+ r) r) r) r* r ! s( ���� ���r c @ sj e Zd ZeZeddd�Zeddd�jdd�Z e ed ddiie jfd ddiie jfd ��Z e � Zdd� Zd S )�HistoryClearr r r Fz"Don't prompt user for confirmationTr �forcer )r6 �fc C s"