PNG  IHDR;IDATxܻn0K )(pA 7LeG{ §㻢|ذaÆ 6lذaÆ 6lذaÆ 6lom$^yذag5bÆ 6lذaÆ 6lذa{ 6lذaÆ `}HFkm,mӪôô! x|'ܢ˟;E:9&ᶒ}{v]n&6 h_tڠ͵-ҫZ;Z$.Pkž)!o>}leQfJTu іچ\X=8Rن4`Vwl>nG^is"ms$ui?wbs[m6K4O.4%/bC%t Mז -lG6mrz2s%9s@-k9=)kB5\+͂Zsٲ Rn~GRC wIcIn7jJhۛNCS|j08yiHKֶۛkɈ+;SzL/F*\Ԕ#"5m2[S=gnaPeғL lذaÆ 6l^ḵaÆ 6lذaÆ 6lذa; _ذaÆ 6lذaÆ 6lذaÆ RIENDB`  Ɵ[c@sddlmZmZddlZddlZddlZddlZddlZddlm Z m Z m Z ddl m Z mZmZejddkZereneZdefd YZd efd YZdS( i(tStringIOtBytesIONi(tExceptionPexpecttEOFtTIMEOUT(tExpectertsearcher_stringt searcher_reiit _NullCodercBs2eZdZeedZeedZRS(sPass bytes through unchanged.cCs|S(N((tbtfinal((s2/tmp/pip-build-ViqJzN/pexpect/pexpect/spawnbase.pytencodescCs|S(N((R R ((s2/tmp/pip-build-ViqJzN/pexpect/pexpect/spawnbase.pytdecodes(t__name__t __module__t__doc__t staticmethodtFalseR R (((s2/tmp/pip-build-ViqJzN/pexpect/pexpect/spawnbase.pyR s t SpawnBasecBs7eZdZdZdZeZdddddddZdZ dZ dZ dZ d Z ee e Zd dd Zd Zd ZddedZddedZddedZdddZddZddZdZddZdZdZdZdZdZRS(sA base class providing the backwards-compatible spawn API for Pexpect. This should not be instantiated directly: use :class:`pexpect.spawn` or :class:`pexpect.fdpexpect.fdspawn`. iitstrictcCsttj|_tj|_tj|_d|_t|_d|_d|_ d|_ d|_ t |_ d|_d|_d|_d|_||_t|_||_d|_d|_||_||_d|_d|_d|_d|_t|_dt|d|_ t |_!||_"||_#|dkrt$|_%|_&t'|_(t)|_*d|_+t,rt't-f|_.t/j0j1d|_0d }||_2qXt3f|_.t/j0|_0tjj4|_2nt5j6|||_%t5j7|||_&t8|_(t9|_*d |_+t8f|_.t,r4t/j0|_0nt/j0j:d|_0tjj4|_2d|_;|j*|_<dS( Nig?g?g-C6?ts tasciicSsHytjjj|SWn*tk rCtjj|jddSXdS(NRtreplace(tsyststdouttbuffertwritetAttributeErrorR (R ((s2/tmp/pip-build-ViqJzN/pexpect/pexpect/spawnbase.pytwrite_to_stdout^s u (=RtstdinRtstderrtNonetsearcherRt ignorecasetbeforetaftertmatcht match_indextTruet terminatedt exitstatust signalstatuststatustchild_fdttimeoutRt delimitertlogfilet logfile_readt logfile_sendtmaxreadtsearchwindowsizetdelaybeforesendtdelayafterclosetdelayafterterminatetdelayafterreadt softspacetreprtnametclosedtencodingt codec_errorsRt_encodert_decodertbytest string_typeRt buffer_typetcrlftPY3tstrtallowed_string_typestostlinesepR Rt basestringRtcodecstgetincrementalencodertgetincrementaldecodert text_typeRR tasync_pw_transportt_buffer(tselfR-R2R3R/R<R=R((s2/tmp/pip-build-ViqJzN/pexpect/pexpect/spawnbase.pyt__init__!sn                                          cCsw|jdk r/|jj||jjn|dkrD|jn|j}|dk rs|j||jndS(Ntsend(R/R RtflushR1R0(RPtst directiont second_log((s2/tmp/pip-build-ViqJzN/pexpect/pexpect/spawnbase.pyt_log|s  cCs0|jdkr,t|t r,|jdS|S(NR(R<R t isinstanceR@R (RPRT((s2/tmp/pip-build-ViqJzN/pexpect/pexpect/spawnbase.pyt_coerce_expect_strings cCs0|jdkr,t|t r,|jdS|S(Nsutf-8(R<R RXR@R (RPRT((s2/tmp/pip-build-ViqJzN/pexpect/pexpect/spawnbase.pyt_coerce_send_strings cCs |jjS(N(ROtgetvalue(RP((s2/tmp/pip-build-ViqJzN/pexpect/pexpect/spawnbase.pyt _get_bufferscCs#|j|_|jj|dS(N(RBROR(RPtvalue((s2/tmp/pip-build-ViqJzN/pexpect/pexpect/spawnbase.pyt _set_buffersicCsytj|j|}WnDtk r_}|jdtjkrYt|_t dnnX|dkrt|_t dn|j j |dt }|j |d|S(sThis reads data from the file descriptor. This is a simple implementation suitable for a regular file. Subclasses using ptys or pipes should override it. The timeout parameter is ignored. is,End Of File (EOF). Exception style platform.ts/End Of File (EOF). Empty string style platform.R tread(RGR`R,tOSErrortargsterrnotEIOR'tflag_eofRR?R RRW(RPtsizeR-RTterr((s2/tmp/pip-build-ViqJzN/pexpect/pexpect/spawnbase.pytread_nonblockings   c CsStdjdt|d|ddjg|jD]}t|^q.dS(Ns`got {badtype} ({badobj!r}) as pattern, must be one of: {goodtypes}, pexpect.EOF, pexpect.TIMEOUTtbadtypetbadobjt goodtypess, (t TypeErrortformatttypetjoinRFRE(RPtpatterntast((s2/tmp/pip-build-ViqJzN/pexpect/pexpect/spawnbase.pyt_pattern_type_errs    cCs$|dkrgSt|ts+|g}ntj}|jrM|tjB}ng}xt|D]\}}t||jr|j |}|j tj ||q`|t kr|j t q`|t kr|j t q`t|ttj dr|j |q`|j|q`W|S(sThis compiles a pattern-string or a list of pattern-strings. Patterns must be a StringType, EOF, TIMEOUT, SRE_Pattern, or a list of those. Patterns may also be None which results in an empty list (you might do this if waiting for an EOF or TIMEOUT condition without expecting any pattern). This is used by expect() when calling expect_list(). Thus expect() is nothing more than:: cpl = self.compile_pattern_list(pl) return self.expect_list(cpl, timeout) If you are using expect() within a loop it may be more efficient to compile the patterns first and then call expect_list(). This avoid calls in a loop to compile_pattern_list():: cpl = self.compile_pattern_list(my_pattern) while some_condition: ... i = self.expect_list(cpl, timeout) ... R_N(R RXtlisttretDOTALLR"t IGNORECASEt enumerateRFRYtappendtcompileRRRnRr(RPtpatternst compile_flagstcompiled_pattern_listtidxtp((s2/tmp/pip-build-ViqJzN/pexpect/pexpect/spawnbase.pytcompile_pattern_lists(      icKsad|kr|jd}n|r<tdj|n|j|}|j||||S(sThis seeks through the stream until a pattern is matched. The pattern is overloaded and may take several types. The pattern can be a StringType, EOF, a compiled re, or a list of any of those types. Strings will be compiled to re types. This returns the index into the pattern list. If the pattern was not a list this returns index 0 on a successful match. This may raise exceptions for EOF or TIMEOUT. To avoid the EOF or TIMEOUT exceptions add EOF or TIMEOUT to the pattern list. That will cause expect to match an EOF or TIMEOUT condition instead of raising an exception. If you pass a list of patterns and more than one matches, the first match in the stream is chosen. If more than one pattern matches at that point, the leftmost in the pattern list is chosen. For example:: # the input is 'foobar' index = p.expect(['bar', 'foo', 'foobar']) # returns 1('foo') even though 'foobar' is a "better" match Please note, however, that buffering can affect this behavior, since input arrives in unpredictable chunks. For example:: # the input is 'foobar' index = p.expect(['foobar', 'foo']) # returns 0('foobar') if all input is available at once, # but returns 1('foo') if parts of the final 'bar' arrive late When a match is found for the given pattern, the class instance attribute *match* becomes an re.MatchObject result. Should an EOF or TIMEOUT pattern match, then the match attribute will be an instance of that exception class. The pairing before and after class instance attributes are views of the data preceding and following the matching pattern. On general exception, class attribute *before* is all data received up to the exception, while *match* and *after* attributes are value None. When the keyword argument timeout is -1 (default), then TIMEOUT will raise after the default value specified by the class timeout attribute. When None, TIMEOUT will not be raised and may block indefinitely until match. When the keyword argument searchwindowsize is -1 (default), then the value specified by the class maxread attribute is used. A list entry may be EOF or TIMEOUT instead of a string. This will catch these exceptions and return the index of the list entry instead of raising the exception. The attribute 'after' will be set to the exception type. The attribute 'match' will be None. This allows you to write code like this:: index = p.expect(['good', 'bad', pexpect.EOF, pexpect.TIMEOUT]) if index == 0: do_something() elif index == 1: do_something_else() elif index == 2: do_some_other_thing() elif index == 3: do_something_completely_different() instead of code like this:: try: index = p.expect(['good', 'bad']) if index == 0: do_something() elif index == 1: do_something_else() except EOF: do_some_other_thing() except TIMEOUT: do_something_completely_different() These two forms are equivalent. It all depends on what you want. You can also just expect the EOF if you are waiting for all output of a child to finish. For example:: p = pexpect.spawn('/bin/ls') p.expect(pexpect.EOF) print p.before If you are trying to optimize for speed then see expect_list(). On Python 3.4, or Python 3.3 with asyncio installed, passing ``async_=True`` will make this return an :mod:`asyncio` coroutine, which you can yield from to get the same result that this method would normally give directly. So, inside a coroutine, you can replace this code:: index = p.expect(patterns) With this non-blocking form:: index = yield from p.expect(patterns, async_=True) tasyncsUnknown keyword arguments: {}(tpopRlRmRt expect_list(RPRpR-R3tasync_tkwR|((s2/tmp/pip-build-ViqJzN/pexpect/pexpect/spawnbase.pytexpects^  cKs|dkr|j}nd|kr6|jd}n|rTtdj|nt|t||}|rddlm}|||S|j|SdS(smThis takes a list of compiled regular expressions and returns the index into the pattern_list that matched the child output. The list may also contain EOF or TIMEOUT(which are not compiled regular expressions). This method is similar to the expect() method except that expect_list() does not recompile the pattern list on every call. This may help if you are trying to optimize for speed, otherwise just use the expect() method. This is called by expect(). Like :meth:`expect`, passing ``async_=True`` will make this return an asyncio coroutine. iRsUnknown keyword arguments: {}i(t expect_asyncN( R-RRlRmRRt_asyncRt expect_loop(RPt pattern_listR-R3RRtexpR((s2/tmp/pip-build-ViqJzN/pexpect/pexpect/spawnbase.pyRWs    c  s/|dkrj}nd|kr6|jd}n|rTtdj|nt|jsx|ttfkr|g}nfd}yt|}Wntk rj |nXg|D]}||^q}t t ||}|rddl m } | ||S|j|SdS(sThis is similar to expect(), but uses plain string matching instead of compiled regular expressions in 'pattern_list'. The 'pattern_list' may be a string; a list or other sequence of strings; or TIMEOUT and EOF. This call might be faster than expect() for two reasons: string searching is faster than RE matching and it is possible to limit the search to just the end of the input buffer. This method is also useful when you don't want to have to worry about escaping regular expression characters that you want to match. Like :meth:`expect`, passing ``async_=True`` will make this return an asyncio coroutine. iRsUnknown keyword arguments: {}csF|ttfkr|St|jr5j|Sj|dS(N(RRRXRFRYRr(Rp(RP(s2/tmp/pip-build-ViqJzN/pexpect/pexpect/spawnbase.pytprepare_patterns  i(RN(R-RRlRmRXRFRRtiterRrRRRRR( RPRR-R3RRRR~RR((RPs2/tmp/pip-build-ViqJzN/pexpect/pexpect/spawnbase.pyt expect_exactss(      cCst|||}|j|S(sThis is the common loop used inside expect. The 'searcher' should be an instance of searcher_re or searcher_string, which describes how and what to search for in the input. See expect() for other arguments, return value and exceptions. (RR(RPR!R-R3R((s2/tmp/pip-build-ViqJzN/pexpect/pexpect/spawnbase.pyRscCs|dkr|jS|dkr9|j|j|jStj|jd|tj}|j||jg}|dkr|jS|jS(sDThis reads at most "size" bytes from the file (less if the read hits EOF before obtaining size bytes). If the size argument is negative or omitted, read all data until EOF is reached. The bytes are returned as a string object. An empty string is returned when EOF is encountered immediately. is.{%d}( RARR.R#RtRyRYRuR$(RPRftcretindex((s2/tmp/pip-build-ViqJzN/pexpect/pexpect/spawnbase.pyR`s    " cCsV|dkr|jS|j|j|jg}|dkrK|j|jS|jSdS(slThis reads and returns one entire line. The newline at the end of line is returned as part of the string, unless the file ends without a newline. An empty string is returned if EOF is encountered immediately. This looks for a newline as a CR/LF pair (\r\n) even on UNIX because this is what the pseudotty device returns. So contrary to what you may expect you will receive newlines as \r\n. If the size argument is 0 then an empty string is returned. In all other cases the size argument is ignored, which is not standard behavior for a file-like object. iN(RARRCR.R#(RPRfR((s2/tmp/pip-build-ViqJzN/pexpect/pexpect/spawnbase.pytreadlines   cCst|j|jS(s>This is to support iterators over a file-like object. (RRRA(RP((s2/tmp/pip-build-ViqJzN/pexpect/pexpect/spawnbase.pyt__iter__scCs:g}x-tr5|j}|s%Pn|j|q W|S(sThis reads until EOF using readline() and returns a list containing the lines thus read. The optional 'sizehint' argument is ignored. Remember, because this reads until EOF that means the child process should have closed its stdout. If you run this method on a child that is still running with its stdout open then this method will block until it timesout.(R'RRx(RPtsizehinttlinestline((s2/tmp/pip-build-ViqJzN/pexpect/pexpect/spawnbase.pyt readliness  cCs|jS(s9Expose file descriptor for a file-like interface (R,(RP((s2/tmp/pip-build-ViqJzN/pexpect/pexpect/spawnbase.pytfilenoscCsdS(sWThis does nothing. It is here to support the interface for a File-like object. N((RP((s2/tmp/pip-build-ViqJzN/pexpect/pexpect/spawnbase.pyRSscCstS(s Overridden in subclass using tty(R(RP((s2/tmp/pip-build-ViqJzN/pexpect/pexpect/spawnbase.pytisattyscCs|S(N((RP((s2/tmp/pip-build-ViqJzN/pexpect/pexpect/spawnbase.pyt __enter__scCs|jdS(N(tclose(RPtetypetevaluettb((s2/tmp/pip-build-ViqJzN/pexpect/pexpect/spawnbase.pyt__exit__sN( R RRR R<tpidRReRQRWRYRZR\R^tpropertyRRhRrRRRRRR`RRRRRSRRR(((s2/tmp/pip-build-ViqJzN/pexpect/pexpect/spawnbase.pyRs< Z     0g  0        (tioRRRJRGRRtRct exceptionsRRRRRRRt version_infoRDREtunicodeRMtobjectRR(((s2/tmp/pip-build-ViqJzN/pexpect/pexpect/spawnbase.pyts