eaiovnaovbqoebvqoeavibavo 3 .]N @sddlZddlZddlZddlZddlZddlZyeWnek rRejZYnXej ddkrje fZ ne e fZ ddZ d ddZddZd d d ZdS) NcCshtjj|}tjj|sdStj|j}tjjdrZtj dkrZt |tj tj Btj B@Stj|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)rZfpathmoder/usr/lib/python3.6/utils.pyis_executable_files       rcCsvtjj|dkrt|r|S|dkr*tj}|jd}|s>tj}|jtj}x&|D]}tjj ||}t|rP|SqPWdS)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)filenameenvpZpathlistrZffrrrwhich0s   r$c Csg}d}d}d}d}d}d}|}x|D]} ||ks:||kr| dkrH|}q| dkrV|}q| d krd|}q| jr||krvq|j|d}|}q|| }|}q&||kr|| }|}q&||kr| dkr|}q|| }q&||kr&| d kr|}q&|| }q&W|dkr|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) Z command_linearg_listargZ state_basicZ state_escZstate_singlequoteZstate_doublequoteZstate_whitespacestatecrrrsplit_command_lineEsL      r1c Cs|dk rtj|}xpytj||||Stk rtjd}|jdtjkrz|dk r||tj}|dkr|gggfSnYqXqWdS)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). Nr%r)timeselectInterruptedErrorr exc_infoargserrnoZEINTR)ZiwtdZowtdZewtdZtimeoutZend_timeerrrrrselect_ignore_interruptss     r9)N)N)rr rr3r2r7r4 NameErrorerror version_infostrZ string_typesZunicoderr$r1r9rrrrs   =