HEX
Server: LiteSpeed
System: Linux s787.bom1.mysecurecloudhost.com 4.18.0-477.13.1.lve.el8.x86_64 #1 SMP Thu Jun 1 16:40:47 EDT 2023 x86_64
User: mobilech (5348)
PHP: 8.1.34
Disabled: NONE
Upload Files
File: //usr/local/lib/python3.6/site-packages/pexpect/__pycache__/replwrap.cpython-36.pyc
3

���d�@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�Zdd	d
�Zddd�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|jjd�|jj�|dkrR||_n|j	||j
||��||_||_|j�|dk	r�|j
|�dS)NFzutf-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�3/tmp/pip-build-v2sjurge/pexpect/pexpect/replwrap.py�__init__!s

zREPLWrapper.__init__cCs|jj|�|jj|�dS)N)r
�expect�sendline)rrrrrrr<szREPLWrapper.set_prompt�FcCs|jj|j|jg||d�S)N)�timeout�async_)r
Zexpect_exactrr)rrrrrrr@szREPLWrapper._expect_promptcCs�|j�}|jd�r|jd�|s(td��|rDddlm}||||�Sg}|jj|d�x:|dd�D]*}|j|d�|j|jj	�|jj|�qfW|j|d�dkr�|jj
tj�|jdd�td	|��dj
||jj	g�S)
a0Send 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.
        :param bool async_: On Python 3.4, or Python 3.3 with asyncio
          installed, passing ``async_=True`` will make this return an
          :mod:`asyncio` Future, which you can yield from to get the same
          result that this method would normally give directly.
        �
�zNo command was givenr)�repl_run_command_asyncrN)rz2Continuation prompt found - input was incomplete:
)�
splitlines�endswith�append�
ValueErrorZ_asyncrr
rrZbefore�kill�signal�SIGINT�join)r�commandrrZcmdlinesr�res�linerrrrDs(

zREPLWrapper.run_command���)r+Fr+)r+F)
�__name__�
__module__�__qualname__�__doc__�PEXPECT_PROMPT�PEXPECT_CONTINUATION_PROMPTrrrrrrrrrs
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(rrrr2os�bashcCs�tjjtjjt�d�}tj|d|gddd�}tdd�dtdd�}tdd�dtdd�}d	j	||�}t
|d
|dd�S)
z<Start a bash shell and return a :class:`REPLWrapper` object.z	bashrc.shz--rcfileFzutf-8)rrN�z\[\]z%PS1='{0}' PS2='{1}' PROMPT_COMMAND=''z\$zexport PAGER=cat)r)�os�pathr'�dirname�__file__rr	r0r1r
r)r(Zbashrcr
Zps1Zps2rrrrr3ss)r2)r3)r/�os.pathr5r%�sysr�version_info�PY3�strrr0r1�objectrr2r3rrrr�<module>s^