o
    5_
                     @   s^   zd dl mZ W n ey$   d dlZd dlZejejB dfddZY nw G dd deZdS )    )whichNc                    s"  dd }t j r| |r S dS |du rt jdt j}|s#dS |t j}tj	dkr^t j
|vr:|dt j
 t jddt j}t fd	d
|D rT g}n fdd|D }n g}t }|D ](}t j|}||vr|| |D ]}	t j||	}
||
|r|
    S qyqfdS )aS  Given a command, mode, and a PATH string, return the path which
        conforms to the given mode on the PATH, or None if there is no such
        file.
    
        `mode` defaults to os.F_OK | os.X_OK. `path` defaults to the result
        of os.environ.get("PATH"), or can be overridden with a custom search
        path.
    
        c                 S   s&   t j| ot | |ot j|  S N)ospathexistsaccessisdir)fnmode r   1/usr/lib/python3/dist-packages/ptyprocess/util.py_access_check   s   zwhich.<locals>._access_checkNPATHwin32r   PATHEXT c                 3   s"    | ]}   |  V  qd S r   )lowerendswith.0extcmdr   r   	<genexpr>1   s     zwhich.<locals>.<genexpr>c                    s   g | ]} | qS r   r   r   r   r   r   
<listcomp>4   s    zwhich.<locals>.<listcomp>)r   r   dirnameenvirongetdefpathsplitpathsepsysplatformcurdirinsertanysetnormcaseaddjoin)r   r
   r   r   pathextfilesseendirnormdirthefilenamer   r   r   r      s<   




r   c                   @   s   e Zd ZdZdS )PtyProcessErrorz%Generic error class for this package.N)__name__
__module____qualname____doc__r   r   r   r   r1   F   s    r1   )	shutilr   ImportErrorr   r!   F_OKX_OK	Exceptionr1   r   r   r   r   <module>   s    C