Файловый менеджер - Редактировать - /opt/imh-python/lib/python3.9/site-packages/IPython/terminal/__pycache__/ptutils.cpython-39.pyc
Ðазад
a o�h9 � @ s� d Z ddlZddlmZ ddlmZmZmZ ddlmZm Z ddl mZ ddl mZ ddl mZ ddlmZ ddlZddlZddlZe� Zd d �eed�dd �Zd d �eeeed�dd�Zdeeed�dd�Zdd� ZG dd� de�ZG dd� de�ZdS )zfprompt-toolkit utilities Everything in this module is a private API, not to be used outside IPython. � N)�wcwidth)�provisionalcompleter�cursor_to_position�_deduplicate_completions)� Completer� Completion)�Lexer)� PygmentsLexer)�patch_stdout� �� min_elide)�string�returnc C s� | � dd�} | � dd�} t| �|k r(| S | �d�}| �tj�}|d dkrR|�� t|�dkr�d �|d |d dd� |d dd� |d �S t|�dkr�dtj d tj d �|d |d dd� |d dd� |d �S | S )a� If a string is long enough, and has at least 3 dots, replace the middle part with ellipses. If a string naming a file is long enough, and has at least 3 slashes, replace the middle part with ellipses. If three consecutive dots, or two consecutive dots are encountered these are replaced by the equivalents HORIZONTAL ELLIPSIS or TWO DOT LEADER unicode equivalents z...� …z..u ‥�.���� � u {}.{}…{}.{}r � N���z{}u {}…{})�replace�len�split�os�sep�pop�format)r r Zobject_partsZ file_parts� r ��/root/rpmbuild/BUILDROOT/imh-python39-modules-3.9.7-92.el8.x86_64/opt/imh-python/lib/python3.9/site-packages/IPython/terminal/ptutils.py�_elide_point s( �(�r )r �typedr r c C sd t | �|k r| S t |�d }|dk r(| S | �|�r`t | �t |�kr`| dd� � d| |d� � �S | S )zT Elide the middle of a long string if the beginning has already been typed. r � Nr )r � startswith)r r! r Zcut_how_muchr r r �_elide_typedA s r$ )r r! r c C s t t| |d�||d�S )Nr )r$ r )r r! r r r r �_elideO s �r% c C s6 | � d�r.t|�|kr.|| dkr.| d d� S | S d S )N�=r )�endswithr )�text�body�offsetr r r �(_adjust_completion_text_based_on_contextV s "r+ c @ s: e Zd ZdZddd�Zedd� �Zdd� Zed d � �Z dS )�IPythonPTCompleterz8Adaptor to provide IPython completions to prompt_toolkitNc C s( |d u r|d u rt d��|| _|| _d S )Nz/Please pass shell=an InteractiveShell instance.)� TypeError�_ipy_completer�shell)�self� ipy_completerr/ r r r �__init___ s zIPythonPTCompleter.__init__c C s | j r| j S | jjS d S )N)r. r/ r )r0 r r r r1 e s z IPythonPTCompleter.ipy_completerc c s |j �� sd S t� �� t� �� |j}|j}|j}|j}t|||�}z| � |||| j �E d H W n` ty� } zHz t� � \} } }t�| | |� W n ty� td� Y n0 W Y d }~n d }~0 0 W d � n1 s�0 Y W d � n1 s�0 Y d S )Nz"Unrecoverable Error in completions)�current_line�stripr r r( Zcursor_position_rowZcursor_position_col�cursor_positionr �_get_completionsr1 � Exception�sys�exc_info� traceback�print_exception�AttributeError�print)r0 �documentZcomplete_eventr) Z cursor_rowZ cursor_colr5 r* �e�exc_type� exc_value�exc_tbr r r �get_completionsl s z"IPythonPTCompleter.get_completionsc c s0 t |dd�}t| |�| |��}|D �]}|js0q"t�d|j�}t|d �dkr�||j dkr�| |jd }t�d|| �} t|dd� �dkr�t| |j| d d�V q"|j} t |j| |�}|j dkr�t||j| t| d | |j|j� �|j |j d �V q"t||j| t| | |j|j� �|j d �V q"d S )zT Private equivalent of get_completions() use only for unit_testing. �debugF�NFCr r )�start_position�functionz())rF �displayZdisplay_metaN)�getattrr �completionsr( �unicodedata� normalizer �startr r+ �typer% �end� signature)r) r* r5 ZipycrD rJ �cr( Zchar_beforeZ fixed_textZdisplay_textZ adjusted_textr r r r6 � s, � � 8z#IPythonPTCompleter._get_completions)NN) �__name__� __module__�__qualname__�__doc__r2 �propertyr1 rC �staticmethodr6 r r r r r, ] s r, c @ s e Zd ZdZdd� Zdd� ZdS )�IPythonPTLexerz3 Wrapper around PythonLexer and BashLexer. c C s` t }t|j�| _t|j�| _t|j�t|j�t|j�t|j�t|j�t|j �t|j �d�| _d S )N)�HTML�html� javascript�js�perl�ruby�latex)�pygments_lexersr �Python3Lexer�python_lexer� BashLexer�shell_lexer� HtmlLexer�JavascriptLexer� PerlLexer� RubyLexer�TexLexer�magic_lexers)r0 �lr r r r2 � s �zIPythonPTLexer.__init__c C sj |j �� }| j}|�d�s$|�d�r,| j}n4|�d�r`| j�� D ]\}}|�d| �r@|} q`q@|�|�S )N�!z%%bashz%%)r( �lstriprb r# rd rj �items�lex_document)r0 r>