Viewing File: /opt/hc_python/lib/python3.12/site-packages/pre_commit/__pycache__/parse_shebang.cpython-312.pyc

�

i0i�	���ddlmZddlZddlmZddlmZddlm	Z	Gd�de
�Zd
d�Zdd	�					dd
�Z
dd	�dd�Zdd	�					dd�Zy)�)�annotationsN)�Mapping)�NoReturn)�parse_shebang_from_filec��eZdZdd�Zy)�ExecutableNotFoundErrorc�B�d|jdj�dfS)N�r)�args�encode)�selfs �G/opt/hc_python/lib/python3.12/site-packages/pre_commit/parse_shebang.py�	to_outputz!ExecutableNotFoundError.to_outputs ���4�9�9�Q�<�&�&�(�$�/�/�N)�returnztuple[int, bytes, None])�__name__�
__module__�__qualname__r�rrrr
s��0rrc�X�tjj|�syt|�S)Nr)�os�path�existsr)�filenames r�parse_filenamers ��
�7�7�>�>�(�#��&�x�0�0r��envc�b��tjj���tj�vr�S|�|ntj}d|vr;|djtj�}t�fd�|D���fz}n�f}|jdd�jtj�D]s}|D]l}tjj||�}tjj|�s�Ctj|tj�s�h|ccS�uy)N�PATHEXTc3�*�K�|]
}��|�����y�w)Nr)�.0�ext�exes  �r�	<genexpr>z"find_executable.<locals>.<genexpr>!s�����"A�D�S�c�U�3�%�=�D�s��PATH�)
rr�normpath�sep�environ�split�pathsep�tuple�get�join�isfile�access�X_OK)r#rr)�exts�possible_exe_namesr�possible_exe_name�joineds`       r�find_executabler6s����
�'�'�
�
�3�
�C�	�v�v��}��
��_�c�"�*�*�G��G���y�!�'�'��
�
�3��"�"A�D�"A�A�S�F�J��!�V�����F�B�'�-�-�b�j�j�9��!3���W�W�\�\�$�(9�:�F��w�w�~�~�f�%�"�)�)�F�B�G�G�*D��
�"4�:�rc���d�fd�}tj�vr;tjrtj�vrt�|��}|�|d�|Stjj��r	|d�ytjj
��s	|d�ytj�tj�s	|d�y�S)Nc�&��td��d|����)NzExecutable `z` )r)�msg�origs �r�_errorznormexe.<locals>._error/s���%��T�F�"�S�E�&B�C�Crrz	not foundzis a directoryzis not executable)r9�strrr)	rr(�altsepr6r�isdirr/r0r1)r:rr;r#s`   r�normexer?.s����D�
�v�v�T��2�9�9��	�	��0E��d��,���;��;���
�	�����t�	��� �
�W�W�^�^�D�
!��{��
�Y�Y�t�R�W�W�
%��"�#��rc�~�t|d|��}t|�|fz|ddz}t|d|��}|f|ddzS)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
    rrr
N)r?r)�cmdrr#s   r�
normalize_cmdrBAsW���#�a�&�c�
"�C���
���
&��Q�R��
0�C��#�a�&�c�
"�C��6�C���G��r)rr<r�tuple[str, ...])r#r<r�Mapping[str, str] | Nonerz
str | None)r:r<rrDrr<)rArCrrDrrC)�
__future__r�os.pathr�collections.abcr�typingr�identify.identifyr�OSErrorrrr6r?rBrrr�<module>rKsw��"��#��5�0�g�0�
1�6:��
��2����0;?��,)-��
��&���	r
Back to Directory File Manager