
    Mh                         d dl Z d dlZd dlZd dlZd dlZd dlZ	 e n# e$ r
 ej        ZY nw xY wej	        d          dk    re
fZnee
fZd ZddZd ZddZddZdS )	    N   c                    t           j                            |           }t           j                            |          sdS t          j        |          j        }t          j                            d          rMt          j	                    dk    r6t          |t          j        t          j        z  t          j        z  z            S t          j        |t           j                  S )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)``.
    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modes      M/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/pexpect/utils.pyis_executable_filer      s     GT""E7>>%   u75>>!D(( 	+	q   DDL L) L) * + + 	+ 9UBG$$$    c                 ~   t           j                            |           dk    rt          |           r| S |t           j        }|                    d          }|st           j        }|                    t           j                  }|D ]5}t           j        	                    ||           }t          |          r|c S 6dS )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. NPATH)
r   r   dirnamer   environgetdefpathsplitpathsepjoin)filenameenvppathlistr   ffs         r   whichr*   0   s     
wx  B&&+=h+G+G&
{jA Jwwrz""H  W\\$))b!! 	III	4r   c                    g }d}d}d}d}d}d}|}| D ]}	||k    s||k    rX|	dk    r|}|	dk    r|} |	d	k    r|})|	                                 r!||k    rD|                    |           d}|}^||	z   }|}f||k    r||	z   }|}t||k    r|	dk    r|}||	z   }||k    r|	d	k    r|}||	z   }|dk    r|                    |           |S )
a  This 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. r   r         r      \'")isspaceappend)
command_linearg_listargstate_basic	state_escstate_singlequotestate_doublequotestate_whitespacestatecs
             r   split_command_liner>   E   s[    H
C KIE # #K5,<#<#<Dyy!d)d) $,,,OOC(((C,EEAg#i'CEE'''Dyy#Ag'''Dyy#Ag
byyOr   c                 <   |t          j                     |z   }	 	 t          j        | |||          S # t          $ r^ t          j                    d         }|j        d         t          j        k    r&|#|t          j                     z
  }|dk     rg g g fcY S n Y nw xY w)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). NTr,   r   )timeselectInterruptedErrorr   exc_infoargserrnoEINTR)iwtdowtdewtdtimeoutend_timeerrs         r   select_ignore_interruptsrM      s     9;;(	=tT7;;; 	 	 	,..#Cx{ek)) &&4G{{!2rl*** 	s   2 A!BBBc                    |t          j                     |z   }t          j                    }| D ]I}|                    |t          j        t          j        z  t          j        z  t          j        z             J	 	 |dn|dz  }|                    |          }d |D             S # t          $ r[ t          j
                    d         }|j        d         t          j        k    r#| |t          j                     z
  }|dk     rg cY S n Y nw xY w)zOSimple wrapper around poll to register file descriptors and
    ignore signals.NTi  c                     g | ]\  }}|S  rP   ).0afd_s      r   
<listcomp>z*poll_ignore_interrupts.<locals>.<listcomp>   s    ...FCC...r   r,   r   )r@   rA   pollregisterPOLLINPOLLPRIPOLLHUPPOLLERRrB   r   rC   rD   rE   rF   )fdsrJ   rK   pollerfd
timeout_msresultsrL   s           r   poll_ignore_interruptsr`      s    9;;([]]F ^ ^FMFN:V^Kfn\]]]]	!(gnJkk*--G..g.... 	 	 	,..#Cx{ek)) &&4G{{!			 	s   :)B$ $AD	D	D	)N)r   r   r
   rA   r@   rE   rB   	NameErrorerrorversion_infostrstring_typesunicoder   r*   r>   rM   r`   rP   r   r   <module>rg      s    				 



    $ $ $ $|$ A!6LLS>L% % %8   *: : :z   :     s    ,,