관리-도구
편집 파일: utils.cpython-39.opt-1.pyc
a ��!^� � @ s� d dl Z d dlZd dlZd dlZd dlZd dlZze W n eyP ejZY n0 ej d dkrhe fZnee fZdd� Z d dd�Zdd� Zdd d �Zddd�ZdS )� N� c C sh t j�| �}t j�|�sdS t �|�j}tj�d�rZt � � dkrZt |tjtjB tj B @ �S t �|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)``. FZsunosr )�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 �1/usr/lib/python3.9/site-packages/pexpect/utils.py�is_executable_file s ���r c C sv t j�| �dkrt| �r| S |du r*t j}|�d�}|s>t j}|�t j�}|D ]"}t j� || �}t|�rN| S qNdS )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}|}| D ]�} ||ks8||kr�| dkrF|}q�| dkrT|}q�| d krb|}q�| � � r�||krtq�|�|� d}|}q�|| }|}q$||kr�|| }|}q$||kr�| dkr�|}q�|| }q$||kr$| d kr�|}q$|| }q$|dkr�|�|� |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 r0 c C s� |durt � � | }zt�| |||�W S ty� t�� d }|jd tjkr||dur~|t � � }|dk r~g g g f Y S n� Y q0 qdS )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�errno�EINTR)ZiwtdZowtdZewtd�timeout�end_time�errr r r �select_ignore_interrupts� s r; c C s� |durt � � | }t�� }| D ]$}|�|tjtjB tjB tjB � q z.|du rTdn|d }|�|�}dd� |D �W S ty� t � � d }|jd tj kr�|dur�|t � � }|dk r�g Y S n� Y qF0 qFdS )zOSimple wrapper around poll to register file descriptors and ignore signals.Ni� c S s g | ]\}}|�qS r r )�.0Zafd�_r r r � <listcomp>� � z*poll_ignore_interrupts.<locals>.<listcomp>r$ r )r1 r2 Zpoll�registerZPOLLINZPOLLPRIZPOLLHUPZPOLLERRr3 r r4 r5 r6 r7 )Zfdsr8 r9 Zpoller�fdZ timeout_ms�resultsr: r r r �poll_ignore_interrupts� s"