HEX
Server: LiteSpeed
System: Linux srv146.niagahoster.com 4.18.0-553.30.1.lve.el8.x86_64 #1 SMP Tue Dec 3 01:21:19 UTC 2024 x86_64
User: kodi1989 (1633)
PHP: 8.1.34
Disabled: symlink,shell_exec,exec,popen,system,dl,passthru,escapeshellarg,escapeshellcmd,show_source,pcntl_exec
Upload Files
File: //opt/alt/python37/lib/python3.7/site-packages/pyroute2/cli/__pycache__/console.cpython-37.pyc
B

��f��@s`ddlZddlZddlZddlZddlmZddlmZGdd�dej�Z	e
dkr\e	���dS)�N)�Session)�NDBc@sZeZdZddd�Zdd�Zdd�Zddd	�Zd
d�Zddd
�Zdd�Z	dd�Z
dd�ZdS)�ConsoleNcCsrt||d�|_|jj�ddd��|p*tj|_t|j|j|j�|_g|_	tj
��|_d|_|��t
j�|�dS)N)�log�sources�json�true)Zshow_formatZrecordset_pipe�)r�db�config�update�sys�stdoutr�
set_prompt�session�matches�stdin�isatty�prompt�code�InteractiveConsole�__init__)�selfrrr�r�E/opt/alt/python37/lib/python3.7/site-packages/pyroute2/cli/console.pyrszConsole.__init__cCs|j��dS)N)r
�close)rrrrrsz
Console.closecCs|j�d�dS)Nz}Built-in commands: 
exit	-- exit cli
ls	-- list current namespace
.	-- print the current object
.. or Ctrl-D	-- one level up
)r�lprint)rrrr�helpszConsole.helpcCsT|jrP|dk	rd||_nd|jjjj|_dt��t�	��
d�d|jf|_dS)Nz%s > z
%s@%s : %s�.r)rrr�ptr�	__class__�__name__�getpass�getuser�socket�gethostname�split)rrrrrr$szConsole.set_promptc	Cs*t|d��}|j�|���WdQRXdS)N�r)�openr�handle�read)r�fname�frrr�loadrc0szConsole.loadrccCs�|jr|dkr|j�d�|dkr(|j}d}x�y||j�}WnPtk
rp|jjrb|j��w.n
|��PYnt	k
r�|��PYnXy|j�
||�}Wq.tk
r�|��dS|��w.Yq.Xq.WdS)Nzpyroute2 cli prototyper)
rrr�	raw_inputr�EOFError�stackZ	stack_popr�	Exceptionr)�
SystemExitZ
showtraceback)rZreadfunc�indent�textrrr�interact4s2
zConsole.interactcCs&|�d�|�|j�|�|j�dS)Nz
tab: complete)�parse_and_bind�
set_completer�	completerZ#set_completion_display_matches_hook�display)r�readlinerrrr7Ss
zConsole.set_completercs�|dkrd�fdd�t|jj�D�}t|jjt�r^dd�|jj��D�}|��fdd�|D��||_y
|j|SYnXdS)Nrcsg|]}|���r|�qSr)�
startswith)�.0�x)r4rr�
<listcomp>Zsz%Console.completer.<locals>.<listcomp>cSsg|]}t|��qSr)�str)r<�yrrrr>\scsg|]}|���r|�qSr)r;)r<r=)r4rrr>]s)�dirrr�
isinstance�dict�keys�extendr)rr4�state�drDr)r4rr8Xs
zConsole.completercCs4|j��|j�|�|jjd|j|fdd�dS)Nz%s%sr	)�end)rrr)r�liner�lengthrrrr9ds
zConsole.display)NNN)N)N)r!�
__module__�__qualname__rrrrr-r5r7r8r9rrrrr
s

	

r�__main__)rr"r$r
Zpyroute2.cli.sessionrZpyroute2.ndb.mainrrrr!r5rrrr�<module>s`