관리-도구
편집 파일: parse_shebang.cpython-38.pyc
U ,�e� � @ s� d dl mZ d dlZd dlmZ d dlmZ d dlmZ G dd� de �Z dd d �dd�Zdd �dddd�dd�Zdd �dddd�dd�Z dd �d dd d�dd�ZdS )� )�annotationsN)�Mapping)�NoReturn)�parse_shebang_from_filec @ s e Zd Zdd�dd�ZdS )�ExecutableNotFoundErrorztuple[int, bytes, None])�returnc C s d| j d �� d fS )N� r )�args�encode)�self� r �F/opt/hc_python/lib/python3.8/site-packages/pre_commit/parse_shebang.py� to_output s z!ExecutableNotFoundError.to_outputN)�__name__� __module__�__qualname__r r r r r r s r �strztuple[str, ...])�filenamer c C s t j�| �sdS t| �S d S )Nr )�os�path�existsr )r r r r �parse_filename s r ��envzMapping[str, str] | Nonez str | None)�exer r c s� t j�� �� t j� kr� S |d k r&|nt j}d|krb|d �t j�}t� fdd�|D ��� f }n� f}|�dd��t j�D ]B}|D ]8}t j� ||�}t j� |�r�t �|t j�r�| S q�q|d S )N�PATHEXTc 3 s | ]}� � |� �V qd S )Nr )�.0�ext�r r r � <genexpr>! s z"find_executable.<locals>.<genexpr>�PATH� ) r r �normpath�sep�environ�split�pathsep�tuple�get�join�isfile�access�X_OK)r r r$ �extsZpossible_exe_namesr Zpossible_exe_nameZjoinedr r r �find_executable s r. )�origr r c s� ddd�� fdd�}t j� krNt jr.t j� krNt� |d�}|d krJ|d� |S t j�� �rd|d� n2t j�� �sz|d� nt �� t j�s�|d � n� S d S ) Nr r )�msgr c s t d� � d| � ���d S )NzExecutable `z` )r )r0 �r/ r r �_error/ s znormexe.<locals>._errorr z not foundzis a directoryzis not executable) r r# �altsepr. r �isdirr* r+ r, )r/ r r2 r r r1 r �normexe. s r5 )�cmdr r c C sL t | d |d�}t|�|f | dd� } t | d |d�}|f| dd� S )z�Fixes for the following issues on windows - https://bugs.python.org/issue8557 - windows does not parse shebangs This function also makes deep-path shebangs work just fine r r r N)r5 r )r6 r r r r r � normalize_cmdA s r7 )� __future__r �os.pathr �typingr r Zidentify.identifyr �OSErrorr r r. r5 r7 r r r r �<module> s ��