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