File: //usr/local/lib/python3.6/site-packages/pexpect/__pycache__/utils.cpython-36.pyc
3
��Zd� � @ s� d dl Z d dlZd dlZd dlZd dlZd dlZye W n ek
rR ejZY nX ej d dkrje
fZnee
fZdd� Z
d
dd�Zdd� Zdd d
�Zddd�ZdS )� N� c C sh t jj| �}t jj|�sdS t j|�j}tjjd�rZt j � dkrZt
|tjtjB tj
B @ �S t j|t j�S )z�Checks 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 Zfpath�mode� r �0/tmp/pip-build-hc5bmb4z/pexpect/pexpect/utils.py�is_executable_file s
r c C sv t jj| �dkrt| �r| S |dkr*t j}|jd�}|s>t j}|jt j�}x&|D ]}t jj || �}t|�rP|S qPW dS )z�This 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 �ffr r r �which0 s
r&