HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //snap/certbot/4965/lib/python3.12/site-packages/setuptools/__pycache__/_scripts.cpython-312.pyc
�

9�h�+��T�ddlmZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
mZddlm
Z
mZddlmZmZe
rddlmZddlmZdd	lmZdd
lmZGd�ded
��ZGd�de�ZGd�de�ZGd�d�ZGd�de�ZGd�de�Z d�Z!d�Z"d�Z#d�Z$d�Z%y)�)�annotationsN)�Iterable)�
TYPE_CHECKING�	TypedDict�)�metadata�	resources)�Self)�SetuptoolsWarning)�
first_line_re)�get_platformc�"�eZdZUded<ded<y)�
_SplitArgs�bool�comments�posixN)�__name__�
__module__�__qualname__�__annotations__����/build/snapcraft-certbot-c9561b03ef7f16aa90eb6754ca5f17a1/parts/certbot/install/lib/python3.12/site-packages/setuptools/_scripts.pyrrs���N��KrrF)�totalc��eZdZUdZgZded<e�Zed��Z	ed��Z
edd��Zed��Zedd��Z
dd	�Zed
��Zd�Zed��Zed
��Zy)�CommandSpeczm
    A command spec for a #! header, specified as a list of arguments akin to
    those passed to Popen.
    z	list[str]�optionsc��|S)zV
        Choose the best CommandSpec class based on environmental conditions.
        r��clss r�bestzCommandSpec.best's	��
�
rc��tjjtj�}tj
j
d|�S)N�__PYVENV_LAUNCHER__)�os�path�normpath�sys�
executable�environ�get)r �_defaults  r�_sys_executablezCommandSpec._sys_executable.s0���7�7�#�#�C�N�N�3���z�z�~�~�3�X�>�>rc���t||�r|St|t�r|j|�St|t�r||�S|�|j	�Stdt
|�����)zg
        Construct a CommandSpec from a parameter to build_scripts, which may
        be None.
        z!Argument has an unsupported type )�
isinstance�str�from_stringr�from_environment�	TypeError�type)r �params  r�
from_paramzCommandSpec.from_param3sk���e�S�!��L��e�S�!��?�?�5�)�)��e�X�&��u�:���=��'�'�)�)��;�D��K�=�I�J�Jrc�0�||j�g�S�N)r,rs rr1zCommandSpec.from_environmentCs���C�'�'�)�*�+�+rc�R�tj|fi|j��}||�S)z}
        Construct a command spec from a simple string representing a command
        line parseable by shlex.split.
        )�shlex�split�
split_args)r �string�itemss   rr0zCommandSpec.from_stringGs%�����F�5�c�n�n�5���5�z�rc��tj|j|��|_t	j
|�}t
|�sdg|jddyy)Nz-xr)r9r:�_extract_optionsr�
subprocess�list2cmdline�isascii)�self�script_text�cmdlines   r�install_optionszCommandSpec.install_optionsPsL���{�{�4�#8�#8��#E�F����)�)�$�/���w�� $�v�D�L�L��!�� rc��|dzj�d}t�j|�}|r|jd�xsdnd}|j	�S)zH
        Extract any options from the first line of the script.
        �
rr�)�
splitlines�_first_line_re�match�group�strip)�orig_script�firstrLrs    rr?zCommandSpec._extract_optionsVsQ��
�t�#�/�/�1�!�4��� �&�&�u�-��*/�%�+�+�a�.�&�B�R���}�}��rc�P�|j|t|j�z�Sr7)�_render�listr)rCs r�	as_headerzCommandSpec.as_header`s���|�|�D�4����#5�5�6�6rc�l�d}|D],}|j|�s�|j|�s�'|ddcS|S)Nz"'r���)�
startswith�endswith)�item�_QUOTES�qs   r�
_strip_quoteszCommandSpec._strip_quotescs@�����	"�A����q�!�d�m�m�A�&6��A�b�z�!�	"��rc�J�tjd�|D��}d|zdzS)Nc3�bK�|]'}tj|j�����)y�wr7)rr\rN)�.0rYs  r�	<genexpr>z&CommandSpec._render.<locals>.<genexpr>ms&����*
�8<�K�%�%�d�j�j�l�3�*
�s�-/z#!rH)r@rA)r=rEs  rrRzCommandSpec._renderks0���)�)�*
�@E�*
�
���g�~��$�$rN)r4z!Self | str | Iterable[str] | None�returnr
)r<r/rar
)rDr/)rrr�__doc__rrrr;�classmethodr!r,r5r1r0rF�staticmethodr?rTr\rRrrrrrs����
�G�Y����J������?��?��
K��
K��,��,�����&�����7������%��%rrc��eZdZed��Zy)�WindowsCommandSpecF)rN)rrrrr;rrrrfrfss���%�(�Jrrfc��eZdZdZej
d�j
�ZeZ	e
d	d��Zed��Z
e
d��Ze
d��Ze
		d
					dd��Zy)�ScriptWriterz`
    Encapsulates behavior around writing entry point scripts for console and
    gui apps.
    aJ
        # EASY-INSTALL-ENTRY-SCRIPT: %(spec)r,%(group)r,%(name)r
        import re
        import sys

        # for compatibility with easy_install; see #2198
        __requires__ = %(spec)r

        try:
            from importlib.metadata import distribution
        except ImportError:
            try:
                from importlib_metadata import distribution
            except ImportError:
                from pkg_resources import load_entry_point


        def importlib_load_entry_point(spec, group, name):
            dist_name, _, _ = spec.partition('==')
            matches = (
                entry_point
                for entry_point in distribution(dist_name).entry_points
                if entry_point.group == group and entry_point.name == name
            )
            return next(matches).load()


        globals().setdefault('load_entry_point', importlib_load_entry_point)


        if __name__ == '__main__':
            sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
            sys.exit(load_entry_point(%(spec)r, %(group)r, %(name)r)())
        Nc#�$K�t|d�s>tjd�tjj|j�}|�|j�}|j�d|j��}dD]�}|�d�}|jj|��D]h}|j}|j|j�|jt�z}|j||j||�}	|	Ed{����j��y7�	�w)z�
        Yield write_script() argument tuples for a distribution's
        console_scripts and gui_scripts entry points.
        �entry_pointsz%Unsupported distribution encountered.Nz==��console�gui�_scripts)rM)�hasattrr�emitr�Distribution�at�egg_info�
get_header�name�versionrj�select�_ensure_safe_name�template�locals�_get_script_args)
r �dist�header�spec�type_rM�eprurD�argss
          r�get_argszScriptWriter.get_args�s������t�^�,��"�"�#J�K��(�(�+�+�D�M�M�:�D��>��^�^�%�F��)�)��B�t�|�|�n�-��%�	 �E��g�X�&�E��'�'�.�.�U�.�;�
 ���w�w���%�%�b�g�g�.�!�l�l�V�X�5���+�+�E�2�7�7�F�K�P�����
 �	 � �s�DD�D�
Dc�J�tjd|�}|rtd��y)z?
        Prevent paths in *_scripts entry point names.
        z[\\/]z+Path separators not allowed in script namesN)�re�search�
ValueError)ru�has_path_seps  rrxzScriptWriter._ensure_safe_name�s(��
�y�y��4�0����J�K�K�rc��tjdk(s&tjdk(r'tjdk(rt
j
�S|S)zD
        Select the best ScriptWriter for this environment.
        �win32�java�nt)r'�platformr$ru�_name�WindowsScriptWriterr!rs rr!zScriptWriter.best�s:��
�<�<�7�"�r�w�w�&�'8�R�X�X��=M�&�+�+�-�-��Jrc#�K�|||zf��y�wr7r)r rrur}rDs     rr{zScriptWriter._get_script_args�s�����V�k�)�*�*�s�
c��|jj�j|�}|j|�|j	�S)z;Create a #! line, getting options (if any) from script_text)�command_spec_classr!r5rFrT)r rDr(�cmds    rrtzScriptWriter.get_header�s=���$�$�)�)�+�6�6�z�B�����K�(��}�}��rr7)rIN)rDr/r(z(str | CommandSpec | Iterable[str] | Nonerar/)rrrrb�textwrap�dedent�lstripryrr�rcr�rdrxr!r{rtrrrrhrhws����
�x���!	�#�F
�f�h�G
�J%��� �� �0�L��L������+��+���?C����=��

�	��rrhc�P�eZdZeZed��Zed��Zed��Ze	d��Z
y)r�c�n�tt|��}tjj	dd�}||S)zC
        Select the best ScriptWriter suitable for Windows
        )r(�natural�SETUPTOOLS_LAUNCHERr()�dict�WindowsExecutableLauncherWriterr$r)r*)r �
writer_lookup�launchers   rr!zWindowsScriptWriter.best�s6��
�6��
�
�
�:�:�>�>�"7��F���X�&�&rc#�K�tdd��|}|tjdj�j	d�vr/dj
d
it
���}tj|�gd�}|j|�|j||�}|D�cgc]}||z��	}	}||z||zd|	f��y	cc}w�w)z For Windows, add a .py extension�.pya�.pywrk�PATHEXT�;zK{ext} not listed in PATHEXT; scripts will not be recognized as executables.)r��.py�
-script.py�.pyc�.pyor��.exe�tNr)r�r$r)�lowerr:�formatrzrrp�remove�_adjust_header)
r rrur}rD�ext�msg�old�x�blockerss
          rr{z$WindowsScriptWriter._get_script_args�s������6�v�.�u�5���b�j�j��+�1�1�3�9�9�#�>�>��-��f�!��x�!�C�
�"�"�3�'�K���
�
�3���#�#�E�6�2��&)�*��D�1�H�*��*��S�j�&�;�.��X�=�=��+�s�BC�B<�+Cc���d}d}|dk(r||}}tjtj|�tj�}|j	||��}|j|�r|S|S)z�
        Make sure 'pythonw' is used for gui and 'python' is used for
        console (regardless of what sys.executable is).
        zpythonw.exez
python.exerm)r<�repl)r��compile�escape�
IGNORECASE�sub�_use_header)r r�orig_header�patternr��
pattern_ob�
new_headers       rr�z"WindowsScriptWriter._adjust_headersc�� �����E�>� �'�T�G��Z�Z��	�	�'� 2�B�M�M�B�
��^�^�;�T�^�B�
� �_�_�Z�8�z�I�k�Irc�~�|ddjd�}tjdk7xstj|�S)z�
        Should _adjust_header use the replaced header?

        On non-windows systems, always use. On
        Windows systems, only use the replaced header if it resolves
        to an executable on the system.
        �rV�"r�)rNr'r��shutil�which)r��clean_headers  rr�zWindowsScriptWriter._use_headers8��"�!�B�'�-�-�c�2���|�|�w�&�D�&�,�,�|�*D�DrN)rrrrfr�rcr!r{r�rdr�rrrr�r��sZ��+���
'��
'��
>��
>��J��J��	E��	Err�c��eZdZed��Zy)r�c#�
K�|dk(rd}d}dg}nd}d}gd�}|j||�}|D�	cgc]}	||	z��	}
}	||z||zd|
f��|dzt|�d	f��t�s|d
z}|t|�df��yycc}	w�w)zG
        For Windows, add a .py extension and an .exe launcher
        rmz-script.pywr��clir�)r�r�r�r�r��bz
.exe.manifestN)r��get_win_launcher�is_64bit�load_launcher_manifest)r rrur}rD�
launcher_typer�r��hdrr�r��m_names            rr{z0WindowsExecutableLauncherWriter._get_script_argss�����
�E�>�!�M��C��(�C�!�M��C�)�C�� � ���/��&)�*��D�1�H�*��*��c�z�3��,�c�8�<�<��6�M��]�+��
�	
�
�z��O�+�F��1�$�7��=�=���+�s�,B�A>�A	BN)rrrrcr{rrrr�r�s���>��>rr�c��|�d�}t�r3t�dk(r|jdd�}n%|jdd�}n|jdd�}tjd�j|�j
�S)z�
    Load the Windows launcher (executable) suitable for launching a script.

    `type` should be either 'cli' or 'gui'

    Returns the executable as a byte string.
    r�z	win-arm64�.z-arm64.z-64.z-32.�
setuptools)r�r
�replacer	�files�joinpath�
read_bytes)r3�launcher_fns  rr�r�<sw���F�$�-�K��z��>�[�(�%�-�-�c�9�=�K�%�-�-�c�6�:�K�!�)�)�#�v�6���?�?�<�(�1�1�+�>�I�I�K�Krc��tjt�jd�}|j	d��t�zS)Nzlauncher manifest.xmlzutf-8)�encoding)r	r�rr��	read_text�vars)ru�ress  rr�r�Os4��
�/�/�(�
#�
,�
,�-D�
E�C��=�=�'�=�*�T�V�3�3rc��ttjt�rtSt	j
tjj
��S)z_
    Return a regular expression based on first_line_re suitable for matching
    strings.
    )r.rr�r/r�r��decoderrrrKrKTs:��
�-�'�'��-����:�:�m�+�+�2�2�4�5�5rc�2�tjd�dk(S)N�P�)�struct�calcsizerrrr�r�`s���?�?�3��1�$�$rc�F�	|jd�y#t$rYywxYw)N�asciiFT)�encode�UnicodeError)�ss rrBrBds,���	�����������s��	 � )&�
__future__rr$r�r9r�r�r@r'r��collections.abcr�typingrr�
_importlibrr	�typing_extensionsr
�warningsr�distutils.command.build_scriptsr�distutils.utilr
rrSrrfrhr�r�r�r�rKr�rBrrr�<module>r�s���"�	�	��
�
��
��$�+�+��&�'�9�'���%��
R%�$�R%�j)��)�g�g�T8E�,�8E�v>�&9�>�@L�&4�
	6�%�r