o ÿé!^ƒã@s¢ddlZddlZddlZddlZddlZddlZzeWn ey(ejZYnwej ddkr4e fZ ne e fZ dd„Z d dd„Zdd„Zd d d „Zd d d „ZdS)éNécCshtj |¡}tj |¡sdSt |¡j}tj d¡r-t  ¡dkr-t |tj tj Btj B@ƒSt |tj¡S)zšChecks 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)``. FÚsunosr)ÚosÚpathÚrealpathÚisfileÚstatÚst_modeÚsysÚplatformÚ startswithÚgetuidÚboolÚS_IXUSRÚS_IXGRPÚS_IXOTHÚaccessÚX_OK)rÚfpathÚmode©rú//usr/lib/python3/dist-packages/pexpect/utils.pyÚis_executable_files     ÿþrcCsvtj |¡dkrt|ƒr|S|durtj}| d¡}|stj}| tj¡}|D]}tj  ||¡}t|ƒr8|Sq'dS)zÐThis 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.ÚNÚPATH) rrÚdirnamerÚenvironÚgetÚdefpathÚsplitÚpathsepÚjoin)ÚfilenameÚenvÚpÚpathlistrÚffrrrÚwhich0s  ÿr'c Csg}d}d}d}d}d}d}|}|D]c} ||ks||krK| dkr#|}q| dkr*|}q| d kr1|}q|  ¡rD||kr:q| |¡d}|}q|| }|}q||krV|| }|}q||krf| dkra|}q|| }q||kru| d krq|}q|| }q|dkr| |¡|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. rrééréú\ú'ú")ÚisspaceÚappend) Ú command_lineÚarg_listÚargÚ state_basicÚ state_escÚstate_singlequoteÚstate_doublequoteÚstate_whitespaceÚstateÚcrrrÚsplit_command_lineEsN  € r:cCsˆ|dur t ¡|} z t ||||¡WStyBt ¡d}|jdtjkr?|dur>|t ¡}|dkr>gggfYSn‚Ynwq )zæThis 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). NTr(r)ÚtimeÚselectÚInterruptedErrorr Úexc_infoÚargsÚerrnoÚEINTR)ÚiwtdÚowtdÚewtdÚtimeoutÚend_timeÚerrrrrÚselect_ignore_interrupts‚s"    €€ôýrHcCsÐ|dur t ¡|}t ¡}|D]}| |tjtjBtjBtjB¡q z|dur+dn|d}| |¡}dd„|DƒWStyft   ¡d}|j dt j krc|durb|t ¡}|dkrbgYSn‚Ynwq$)zOSimple wrapper around poll to register file descriptors and ignore signals.NTiècSsg|]\}}|‘qSrr)Ú.0ÚafdÚ_rrrÚ ®sz*poll_ignore_interrupts..r(r)r;r<ÚpollÚregisterÚPOLLINÚPOLLPRIÚPOLLHUPÚPOLLERRr=r r>r?r@rA)ÚfdsrErFÚpollerÚfdÚ timeout_msÚresultsrGrrrÚpoll_ignore_interruptsŸs, "    €€ôûrX)N)rr rr<r;r@r=Ú NameErrorÚerrorÚ version_infoÚstrÚ string_typesÚunicoderr'r:rHrXrrrrÚs&  þ  =