HEX
Server: Apache
System: Linux scp1.abinfocom.com 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User: confeduphaar (1010)
PHP: 8.1.33
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //proc/self/root/lib/python3/dist-packages/pexpect/__pycache__/replwrap.cpython-38.pyc
U

��~Z2�@sjdZddlZddlZddlZddlZejddkZer:eZ	dZ
dZGdd�de�Z
dd	d�Zd
dd
�ZdS)zEGeneric wrapper for read-eval-print-loops, a.k.a. interactive shells
�N�z[PEXPECT_PROMPT>z[PEXPECT_PROMPT+c@s<eZdZdZeedfdd�Zdd�Zddd	�Zd
d
d�Z	dS)�REPLWrappera�Wrapper for a REPL.

    :param cmd_or_spawn: This can either be an instance of :class:`pexpect.spawn`
      in which a REPL has already been started, or a str command to start a new
      REPL process.
    :param str orig_prompt: The prompt to expect at first.
    :param str prompt_change: A command to change the prompt to something more
      unique. If this is ``None``, the prompt will not be changed. This will
      be formatted with the new and continuation prompts as positional
      parameters, so you can use ``{}`` style formatting to insert them into
      the command.
    :param str new_prompt: The more unique prompt to expect after the change.
    :param str extra_init_cmd: Commands to do extra initialisation, such as
      disabling pagers.
    NcCs�t|t�rtj|ddd�|_n||_|jjrB|j�d�|j��|dkrR||_n|�	||�
||��||_||_|��|dk	r�|�
|�dS)NF�utf-8��echo�encoding)�
isinstance�
basestring�pexpect�spawn�childrZsetechoZ
waitnoecho�prompt�
set_prompt�format�continuation_prompt�_expect_prompt�run_command)�selfZcmd_or_spawn�orig_prompt�
prompt_changeZ
new_promptr�extra_init_cmd�r�2/usr/lib/python3/dist-packages/pexpect/replwrap.py�__init__!s 


�zREPLWrapper.__init__cCs|j�|�|j�|�dS)N)rZexpect�sendline)rrrrrrr<szREPLWrapper.set_prompt���cCs|jj|j|jg|d�S)N��timeout)rZexpect_exactr
r)rrrrrr@s�zREPLWrapper._expect_promptcCs�|��}|�d�r|�d�|s(td��g}|j�|d�|dd�D]*}|j|d�|�|jj�|j�|�qH|j|d�dkr�|j�t	j
�|jdd�td|��d�||jjg�S)	aSend a command to the REPL, wait for and return output.

        :param str command: The command to send. Trailing newlines are not needed.
          This should be a complete block of input that will trigger execution;
          if a continuation prompt is found after sending input, :exc:`ValueError`
          will be raised.
        :param int timeout: How long to wait for the next prompt. -1 means the
          default from the :class:`pexpect.spawn` object (default 30 seconds).
          None means to wait indefinitely.
        �
�zNo command was givenr�Nrz2Continuation prompt found - input was incomplete:
)�
splitlines�endswith�append�
ValueErrorrrrZbefore�kill�signal�SIGINT�join)r�commandrZcmdlines�res�linerrrrDs$

�zREPLWrapper.run_command)r)r)
�__name__�
__module__�__qualname__�__doc__�PEXPECT_PROMPT�PEXPECT_CONTINUATION_PROMPTrrrrrrrrrs�

r�pythoncCst|dd�S)z>Start a Python shell and return a :class:`REPLWrapper` object.z>>> z(import sys; sys.ps1={0!r}; sys.ps2={1!r})r)r)rrrr2gs�bashcCs�tj�tj�t�d�}tj|d|gddd�}tdd�dtdd�}tdd�dtdd�}d	�	||�}t
|d
|dd�S)
z<Start a bash shell and return a :class:`REPLWrapper` object.z	bashrc.shz--rcfileFrrN�z\[\]z%PS1='{0}' PS2='{1}' PROMPT_COMMAND=''z\$zexport PAGER=cat)r)�os�pathr(�dirname�__file__r
rr0r1rr)r)ZbashrcrZps1Zps2rrrrr3ks��)r2)r3)r/�os.pathr5r&�sysr
�version_infoZPY3�strr	r0r1�objectrr2r3rrrr�<module>sV