e?dZddlZddlZddlZddlZej ddk\ZereZ dZ dZ Gdde Z ejfdZd Zd d Zd d Zy)zEGeneric wrapper for read-eval-print-loops, a.k.a. interactive shells Nz[PEXPECT_PROMPT>z[PEXPECT_PROMPT+c4eZdZdZeedfdZdZddZddZ y) REPLWrapperaWrapper 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. Nct|trtj|dd|_n||_|jj r5|jj d|jj|||_n)|j||j||||_||_ |j||j|yy)NFutf-8echoencoding) isinstance basestringpexpectspawnchildr setecho waitnoechoprompt set_promptformatcontinuation_prompt_expect_prompt run_command)self cmd_or_spawn orig_prompt prompt_change new_promptrextra_init_cmds 2/usr/lib/python3/dist-packages/pexpect/replwrap.py__init__zREPLWrapper.__init__!s lJ / |%'RDJ%DJ ::?? JJ  u % JJ ! ! #  %DK OOK%,,Z9LM O$DK#6    %   ^ , &cp|jj||jj|y)N)rexpectsendline)rrrs rrzREPLWrapper.set_prompt<s& +& M*r cj|jj|j|jg||S)N)timeoutasync_)r expect_exactrr)rr%r&s rrzREPLWrapper._expect_prompt@s6zz&& T5M5M'N/6v'G Gr c|j}|jdr|jd|s td|rddlm}||||Sg}|j j|d|ddD]T}|j||j|j j|j j|V|j|dk(rI|j jtj|jdtd |zdj||j jgzS) 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)r%z2Continuation prompt found - input was incomplete: ) splitlinesendswithappend ValueError_asyncr,rr#rbeforekillsignalSIGINTjoin)rcommandr%r&cmdlinesr,reslines rrzREPLWrapper.run_commandDs/ %%'   D ! OOB 34 4  6)$'B B HQK(QRL &D     0 JJtzz(( ) JJ   % &   w  /1 4 JJOOFMM *     *R&'( (xxtzz001122r )F) __name__ __module__ __qualname____doc__PEXPECT_PROMPTPEXPECT_CONTINUATION_PROMPTrrrrr rrrs' +%@ $-6+G)3r rct|ddS)z>Start a Python shell and return a :class:`REPLWrapper` object.z>>> z(import sys; sys.ps1={0!r}; sys.ps2={1!r})r)r7s rpythonrDos w)T UUr ctj||dd}tdd|ztddz}tdd|ztddz}dj ||}t |d|dS) NFrrz%PS1='{0}' PS2='{1}' PROMPT_COMMAND=''z\$zexport PAGER=cat)r)r rr@rArr)r7argsnon_printable_insertrps1ps2rs r_repl_shrKss MM'4eg FE ! 3 3nQR6H HC %bq ),@ @C^_`_aCb bC<CCCMM ufm&8 ::r ctjjtjjtd}t |d|gdS)zr^sm  aJ$1\3&\3|>>V :R Hr