관리-도구
편집 파일: replwrap.cpython-39.opt-1.pyc
a ������!^����������������������@���sj���d�Z�ddlZddlZddlZddlZejd�dkZer:eZ dZ dZG�dd��de�Z dd 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<���e�Zd�ZdZeedfdd�Zdd��Zd d 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. Nc�����������������C���s����t�|t�rtj|ddd�|�_n||�_|�jjrB|�j�d��|�j����|d�u�rR||�_n|�� ||� ||���||�_||�_|�����|d�ur�|�� |��d�S�)NF�utf-8��echo�encoding)� isinstance� basestring�pexpect�spawn�childr���ZsetechoZ waitnoecho�prompt� set_prompt�format�continuation_prompt�_expect_prompt�run_command)�selfZcmd_or_spawn�orig_prompt� prompt_changeZ new_promptr����extra_init_cmd��r����4/usr/lib/python3.9/site-packages/pexpect/replwrap.py�__init__!���s ���� �zREPLWrapper.__init__c�����������������C���s���|�j��|��|�j��|��d�S�)N)r����expect�sendline)r���r���r���r���r���r���r���<���s����zREPLWrapper.set_prompt���Fc�����������������C���s���|�j�j|�j|�jg||d�S�)N)�timeout�async_)r���Zexpect_exactr ���r���)r���r���r���r���r���r���r���@���s�����zREPLWrapper._expect_promptc�����������������C���s����|����}|�d�r|�d��|s(td��|rDddlm}�||�||�S�g�}|�j�|d���|dd��D�]*}|�j|d��|�|�jj ��|�j�|��qd|�j|d�dkr�|�j� tj��|�jdd��td |���d� ||�jj g��S�) a0��Send 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 given����)�repl_run_command_asyncr���N)r���z2Continuation prompt found - input was incomplete: )� splitlines�endswith�append� ValueErrorZ_asyncr"���r���r���r����before�kill�signal�SIGINT�join)r����commandr���r���Zcmdlinesr"����res�liner���r���r���r���D���s*���� �zREPLWrapper.run_command)r���F)r���F) �__name__� __module__�__qualname__�__doc__�PEXPECT_PROMPT�PEXPECT_CONTINUATION_PROMPTr���r���r���r���r���r���r���r���r������s���� r����pythonc�����������������C���s���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,���r���r���r���r5���o���s�����bashc�����������������C���s����t�j�t�j�t�d�}tj|�d|gddd�}tdd��d�tdd���}tdd��d�tdd���}d � ||�}t |d |dd�S�) z<Start a bash shell and return a :class:`REPLWrapper` object.z bashrc.shz--rcfileFr���r���N����z\[\]z%PS1='{0}' PS2='{1}' PROMPT_COMMAND=''z\$zexport PAGER=cat)r���)�os�pathr+����dirname�__file__r ���r���r3���r4���r���r���)r,���Zbashrcr���Zps1Zps2r���r���r���r���r6���s���s������)r5���)r6���)r2���Zos.pathr8���r)����sysr ����version_infoZPY3�strr ���r3���r4����objectr���r5���r6���r���r���r���r����<module>���s���^