3 �i�V� � @ sP yd dl mZ W n: ek rJ d dlZd dlZejejB dfdd�ZY nX dS )� )�whichNc s" dd� }t jj� �r&|� |�r"� S dS |dkr>t jjdt j�}|sFdS |jt j�}tj dkr�t j |krt|jdt j � t jjdd�jt j�}t� fd d �|D ��r�� g}q fdd�|D �}n� g}t � }xT|D ]L}t jj|�}||kr�|j|� x(|D ] } t jj|| �} || |�r�| S q�W q�W dS ) 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&