a ÿé!^ã@sjdZddlZddlZddlZddlZejddkZer:eZ dZ dZ Gdd„de ƒZ d d d„Zd d d „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 d d „Zdd 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. NcCst|tƒrtj|ddd|_n||_|jjrB|j d¡|j ¡|durR||_n|  ||  ||¡¡||_||_ |  ¡|durŒ|  |¡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ú4/usr/lib/python3.9/site-packages/pexpect/replwrap.pyÚ__init__!s     ÿzREPLWrapper.__init__cCs|j |¡|j |¡dS)N)r ÚexpectÚsendline)rrrrrrr<s zREPLWrapper.set_promptéÿÿÿÿFcCs|jj|j|jg||dS)N)ÚtimeoutÚasync_)r Z expect_exactr r)rrrrrrr@sÿzREPLWrapper._expect_promptcCsÚ| ¡}| d¡r| d¡|s(tdƒ‚|rDddlm}||||ƒSg}|j |d¡|dd…D]*}|j|d| |jj ¡|j |¡qd|j|ddkrÆ|j  t j ¡|jddtd |ƒ‚d  ||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 givené)Úrepl_run_command_asyncrN)rz2Continuation prompt found - input was incomplete: )Ú splitlinesÚendswithÚappendÚ ValueErrorZ_asyncr"r rrÚbeforeÚkillÚsignalÚSIGINTÚjoin)rÚcommandrrZcmdlinesr"ÚresÚlinerrrrDs*      ÿzREPLWrapper.run_command)rF)rF) Ú__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,rrrr5osÚbashcCs€tj tj t¡d¡}tj|d|gddd}tdd…dtdd…}tdd…dtdd…}d   ||¡}t |d |d d S) zs^