U
    pufá
  ã                   @   s`   zd dl mZ W n: ek
rJ   d dlZd dlZejejB dfdd„ZY nX G dd„ deƒZdS )é    )ÚwhichNc                    s"  dd„ }t j ˆ ¡r&|ˆ |ƒr"ˆ S dS |dkr>t j dt j¡}|sFdS | t j¡}tj	dkr¼t j
|krt| dt j
¡ t j dd¡ t j¡}t‡ fd	d
„|D ƒƒr¨ˆ g}qÂ‡ fdd„|D ƒ}nˆ g}tƒ }|D ]P}t j |¡}||krÌ| |¡ |D ](}	t j ||	¡}
||
|ƒrò|
    S qòqÌd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   ú3/tmp/pip-unpacked-wheel-tk1i2w1w/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      s8    




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
   ?