Sindbad~EG File Manager
3
.�]N � @ s� d dl Z d dlZd dlZd dlZd dlZd dlZye W n ek
rR ejZY nX ej d dkrje
fZnee
fZdd� Z
ddd�Zdd� Zdd d
�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 �/usr/lib/python3.6/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�pZpathlistr Zffr r r �which0 s
r$ c
C s g }d}d}d}d}d}d}|}x�| D ]�} ||ks:||kr�| dkrH|}q�| dkrV|}q�| d krd|}q�| j � r�||krvq�|j|� d}|}q�|| }|}q&||kr�|| }|}q&||kr�| dkr�|}q�|| }q&||kr&| d kr�|}q&|| }q&W |dk�r|j|� |S )
a This splits a command line into a list of arguments. It splits arguments
on spaces, but handles embedded quotes, doublequotes, and escaped
characters. It's impossible to do this with a regular expression, so I
wrote a little state machine to parse the command line. r r � � r � �\�'�")�isspace�append)
Zcommand_line�arg_list�argZstate_basicZ state_escZstate_singlequoteZstate_doublequoteZstate_whitespace�state�cr r r �split_command_lineE sL
r1 c C s� |dk rt j � | }xpytj| |||�S tk
r� tj� d }|jd tjkrz|dk r||t j � }|dk r|g g g fS n� Y qX qW dS )z�This is a wrapper around select.select() that ignores signals. If
select.select raises a select.error exception and errno is an EINTR
error then it is ignored. Mainly this is used to ignore sigwinch
(terminal resize). Nr% r )�time�select�InterruptedErrorr
�exc_info�args�errnoZEINTR)ZiwtdZowtdZewtdZtimeoutZend_time�errr r r �select_ignore_interrupts� s r9 )N)N)r r
r r3 r2 r7 r4 � NameError�error�version_info�strZstring_typesZunicoder r$ r1 r9 r r r r �<module> s
=
Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists