eddlZddlZddlZddlZddlZddlZ eejddk\re fZ ne e fZ dZ ddZdZddZddZy#e$rejZY@wxYw) Nctjj|}tjj|sytj|j }t jjdrUtjdk(r>t|tjtjztjzzStj|tjS)zChecks that path is an executable regular file, or a symlink towards one. This is roughly ``os.path isfile(path) and os.access(path, os.X_OK)``. Fsunosr)ospathrealpathisfilestatst_modesysplatform startswithgetuidboolS_IXUSRS_IXGRPS_IXOTHaccessX_OK)rfpathmodes //usr/lib/python3/dist-packages/pexpect/utils.pyis_executable_filers GG  T "E 77>>%  775> ! !D ( q DDLL LL) LL)*+ + 99UBGG $$cvtjj|dk7r t|r|S|tj}|j d}|stj }|jtj}|D]1}tjj||}t|s/|cSy)zThis takes a given filename; tries to find it in the environment path; then checks if it is executable. This returns the full path to the filename if found and executable. Otherwise this returns None.NPATH) rrdirnamerenvirongetdefpathsplitpathsepjoin)filenameenvppathlistrffs rwhichr*0s  wwx B&+=h+G {jj A JJwwrzz"H WW\\$ ) b !I rcrg}d}d}d}d}d}d}|}|D]} ||k(s||k(rL| dk(r|}| dk(r|}| d k(r|}%| jr||k(r;|j|d}|}Q|| z}|}Y||k(r|| z}|}f||k(r| dk(r|}s|| z}y||k(s| d k(r|}|| z}|dk7r|j||S) aThis splits a command line into a list of arguments. It splits arguments on spaces, but handles embedded quotes, doublequotes, and escaped characters. It's impossible to do this with a regular expression, so I wrote a little state machine to parse the command line. rrr\'")isspaceappend) command_linearg_listarg state_basic state_escstate_singlequotestate_doublequotestate_whitespacestatecs rsplit_command_liner>EsH CKI E # K 5,<#<Dy!d)d),,OOC(C,EAg# i 'CE ' 'Dy#Ag ' 'Dy#AgG#J by OrcB|tj|z} tj||||S#t$r`tjd}|j dt jk(r%|$tjz }|dkrgggfcYSYnwxYw)zThis is a wrapper around select.select() that ignores signals. If select.select raises a select.error exception and errno is an EINTR error then it is ignored. Mainly this is used to ignore sigwinch (terminal resize). r,r)timeselectInterruptedErrorr exc_infoargserrnoEINTR)iwtdowtdewtdtimeoutend_timeerrs rselect_ignore_interruptsrMs99;(  ==tT7; ; ,,.#Cxx{ekk)&&4G{!2rl*  s4A#BBBcR|tj|z}tj}|D]U}|j|tjtj ztj ztjzW |dn|dz}|j|}|Dcgc]\}}| c}}Scc}}w#t$r]tjd} | jdtjk(r"|!tjz }|dkrgcYSYnwxYw)zOSimple wrapper around poll to register file descriptors and ignore signals.Nir,r)r@rApollregisterPOLLINPOLLPRIPOLLHUPPOLLERRrBr rCrDrErF) fdsrJrKpollerfd timeout_msresultsafd_rLs rpoll_ignore_interruptsr\s99;( [[]F^FMMFNN:V^^Kfnn\]^  !(gnJkk*-G&-.FCC. .. ,,.#Cxx{ekk)&&4G{!   s+ B?) B95B?9B??A D%!D%$D%)N)rr r rAr@rErB NameErrorerror version_infostr string_typesunicoderr*r>rMr\rrrdsz $ A!6LS>L%8*:z:k$||$sA AA