a ÿé!^ƒã@s¢ddlZddlZddlZddlZddlZddlZzeWneyPejZYn0ej ddkrhe fZ ne e fZ dd„Z d dd„Zdd„Zdd d „Zdd d „ZdS)éNécCshtj |¡}tj |¡sdSt |¡j}tj d¡rZt  ¡dkrZt |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)``. FZsunosr)ÚosÚpathÚrealpathÚisfileÚstatÚst_modeÚsysÚplatformÚ startswithÚgetuidÚboolÚS_IXUSRÚS_IXGRPÚS_IXOTHÚaccessÚX_OK)rZfpathÚmode©rú1/usr/lib/python3.9/site-packages/pexpect/utils.pyÚis_executable_files     ÿÿþrcCsvtj |¡dkrt|ƒr|S|dur*tj}| d¡}|s>tj}| tj¡}|D]"}tj  ||¡}t|ƒrN|SqNdS)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ÚpZpathlistrZffrrrÚwhich0s   r#c Csg}d}d}d}d}d}d}|}|D]Æ} ||ks8||kr–| dkrF|}qê| dkrT|}qê| d krb|}qê|  ¡rˆ||krtq”| |¡d}|}qê|| }|}q$||kr¬|| }|}q$||krÌ| dkrÂ|}qê|| }q$||kr$| d krâ|}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) Z command_lineÚarg_listÚargZ state_basicZ state_escZstate_singlequoteZstate_doublequoteZstate_whitespaceÚstateÚcrrrÚsplit_command_lineEsL    r0cCsŠ|durt ¡|}zt ||||¡WSty‚t ¡d}|jdtjkr||dur~|t ¡}|dkr~gggfYSn‚Yq0qdS)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). Nr$r)ÚtimeÚselectÚInterruptedErrorr Úexc_infoÚargsÚerrnoÚEINTR)ZiwtdZowtdZewtdÚtimeoutÚend_timeÚerrrrrÚselect_ignore_interrupts‚s     r;cCsÒ|durt ¡|}t ¡}|D]$}| |tjtjBtjBtjB¡q z.|durTdn|d}| |¡}dd„|DƒWStyÊt   ¡d}|j dt j krÄ|durÆ|t ¡}|dkrÆgYSn‚YqF0qFdS)zOSimple wrapper around poll to register file descriptors and ignore signals.NiècSsg|] \}}|‘qSrr)Ú.0ZafdÚ_rrrÚ ®óz*poll_ignore_interrupts..r$r)r1r2ZpollÚregisterZPOLLINZPOLLPRIZPOLLHUPZPOLLERRr3r r4r5r6r7)Zfdsr8r9ZpollerÚfdZ timeout_msÚresultsr:rrrÚpoll_ignore_interruptsŸs" "     rC)N)N)N)rr rr2r1r6r3Ú NameErrorÚerrorÚ version_infoÚstrZ string_typesZunicoderr#r0r;rCrrrrÚs"   =