eTddlmZmZddlZddlZddlZddlZddlZddlm Z m Z m Z ddl m Z mZmZej ddk\ZereneZGddeZGd d eZy) )StringIOBytesION)ExceptionPexpectEOFTIMEOUT)Expectersearcher_string searcher_rec4eZdZdZeddZeddZy) _NullCoderzPass bytes through unchanged.c|SNbfinals 3/usr/lib/python3/dist-packages/pexpect/spawnbase.pyencodez_NullCoder.encodec|Srrrs rdecodez_NullCoder.decoderrN)F)__name__ __module__ __qualname____doc__ staticmethodrrrrrrr s+'rrceZdZdZdZdZdZ ddZdZdZ dZ dZ d Z d Z ee e Zdd Zd Zd ZddZ ddZ ddZddZddZddZdZddZdZdZdZdZdZy) SpawnBasezA 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`. NFctj|_tj|_tj|_d|_d|_d|_d|_d|_d|_ d|_ d|_ d|_ d|_ d|_||_t |_||_d|_d|_||_||_d|_d|_d|_d|_d|_dt9|zdz|_d|_||_||_ |tCx|_"|_#tH|_%tL|_'d |_(tRrAtHtTf|_+tXjZj]d |_-d }||_/n t`f|_+tXjZ|_-tjjb|_/ntejf|||_"tejh|||_#tj|_%tl|_'d |_(tjf|_+tRrtXjZ|_-n$tXjZjod |_-tjjb|_/d|_8|jO|_9|jO|_:y) NFTg?g?g-C6?<>s asciic tjjj|S#t$r2tjj|j ddcYSwxYw)Nr&replace)sysstdoutbufferwriteAttributeErrorr)rs rwrite_to_stdoutz+SpawnBase.__init__..write_to_stdout^sTN"zz0066q99)N"zz//)0LMMNs(+8A&%A&z );r)stdinr*stderrsearcher ignorecasebeforeaftermatch match_index terminated exitstatus signalstatusstatuschild_fdtimeoutr delimiterlogfile logfile_read logfile_sendmaxreadsearchwindowsizedelaybeforesenddelayafterclosedelayafterterminatedelayafterread softspacereprnameclosedencoding codec_errorsr_encoder_decoderbytes string_typer buffer_typecrlfPY3strallowed_string_typesoslineseprr. basestringr,codecsgetincrementalencodergetincrementaldecoder text_typerrasync_pw_transport_buffer_before)selfr<rArBr>rKrLr.s r__init__zSpawnBase.__init__!sAYY jj jj             0 $ #$' %$t*$s*  ! (  ,6L 8DMDM$D &D DI-2CL)!zz009 N (7$-7M)!zz '*zz'7'7$CF88B<PDMBF88B<PDM(D 'D DI)2 D %!zz !zz009 #&::#3#3D "&'') '') rc|j5|jj||jj|dk(r |jn |j}|"|j||jyy)Nsend)r>r,flushr@r?)r`s direction second_logs r_logzSpawnBase._logsm << # LL  q ! LL   +4f+.prepare_patternsC7C.('4#<#<=11'::  " "7 +rrr)r<rrrrkrUrriterrr r rrr) r`rr<rBrrrrurrs ` r expect_exactzSpawnBase.expect_exacts$ b=llG b=VVG_F ;BB2FG G |T%>%> ?#.(>L , 1 -L5AAq*A At_\:t|||}|j|S)aThis 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. )r r)r`r1r<rBrs rrzSpawnBase.expect_loops"tX'78w''rcd|dk(r|jS|dkr'|j|j|jSt j |j d|ztj}|j||jg}|dk(r |jS|jS)aDThis 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. rz.{%d}) rPrr=r3rrrsrmrr4)r`rcreindexs rrzSpawnBase.reads 19##% % !8 KK ';; jj33GdNCRYYO S$..12 A::: {{rc|dk(r|jS|j|j|jg}|dk(r|j|jzS|jS)alThis 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. r)rPrrRr=r3)r`rrs rreadlinezSpawnBase.readlinesY 19##% % TYY78 A:;;* *;; rcJt|j|jS)z>This is to support iterators over a file-like object. )rrrPr{s r__iter__zSpawnBase.__iter__sDMM4#3#3#566rcVg} |j}|s |S|j|')aThis 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.)rr)r`sizehintlineslines r readlineszSpawnBase.readliness5==?D  LL  rc|jS)z9Expose file descriptor for a file-like interface )r;r{s rfilenozSpawnBase.filenos}}rcy)zWThis does nothing. It is here to support the interface for a File-like object. Nrr{s rrdzSpawnBase.flushs rcy)z Overridden in subclass using ttyFrr{s risattyzSpawnBase.isatty src|Srrr{s r __enter__zSpawnBase.__enter__s rc$|jyr)close)r`etypeevaluetbs r__exit__zSpawnBase.__exit__s  r)iNNNstrict)rN)r#r#F)r#r#)r#) rrrrrKpidrrarhrmrvrxr|rpropertyr+rrrrrrrrrrrrrdrrrrrrr!r!s H CHBF;C\*|  '" k; /F2/%be3NFH ,8GI!/,b(:*7     rr!)iorrrYrVr)rrr exceptionsrrrrr r r version_inforSrTunicoder\objectrr!rrrrs[ 66:: aCG AAr