HEX
Server: Apache
System: Linux zacp120.webway.host 4.18.0-553.50.1.lve.el8.x86_64 #1 SMP Thu Apr 17 19:10:24 UTC 2025 x86_64
User: govancoz (1003)
PHP: 8.3.26
Disabled: exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Upload Files
File: //usr/local/lib/python3.7/site-packages/pip/_internal/cli/__pycache__/parser.cpython-37.pyc
B

L��g*�@s�dZddlZddlZddlZddlZddlZddlmZddlm	Z	m
Z
mZmZm
Z
ddlmZddlmZmZddlmZmZe�e�ZGdd	�d	ej�ZGd
d�de�ZGdd
�d
ej�ZGdd�de�ZdS)zBase option parser setup�N)�suppress)�Any�Dict�	Generator�List�Tuple)�
UNKNOWN_ERROR)�
Configuration�ConfigurationError)�redact_auth_from_url�	strtoboolcs�eZdZdZeedd��fdd�Zejed�dd�Z	dejeeed�dd
�Z
eed�dd�Zeed�dd�Zeed�dd�Z
eed�dd�Zeeed�dd�Z�ZS)�PrettyHelpFormatterz4A prettier/less verbose help formatter for optparse.N)�args�kwargs�returncs6d|d<d|d<t��dd|d<t�j||�dS)N��max_help_position��indent_incrementr��width)�shutil�get_terminal_size�super�__init__)�selfrr)�	__class__��</tmp/pip-unpacked-wheel-hv55ucu3/pip/_internal/cli/parser.pyrszPrettyHelpFormatter.__init__)�optionrcCs
|�|�S)N)�_format_option_strings)rrrrr�format_option_stringssz)PrettyHelpFormatter.format_option_strings� <{}>�, )r�mvarfmt�optseprcCs�g}|jr|�|jd�|jr0|�|jd�t|�dkrH|�d|�|��r�|jdk	s^t�|jpl|j�	�}|�|�
|�	���d�|�S)z�
        Return a comma-separated list of option strings and metavars.

        :param option:  tuple of (short opt, long opt), e.g: ('-f', '--format')
        :param mvarfmt: metavar format string
        :param optsep:  separator
        rrN�)�_short_opts�append�
_long_opts�len�insert�takes_value�dest�AssertionError�metavar�lower�format�join)rrr$r%�optsr/rrrr s
z*PrettyHelpFormatter._format_option_strings)�headingrcCs|dkrdS|dS)N�Optionsr&z:
r)rr4rrr�format_heading9sz"PrettyHelpFormatter.format_heading)�usagercCsd�|�t�|�d��}|S)zz
        Ensure there is only one newline between usage and the first heading
        if there is no description.
        z
Usage: {}
z  )r1�indent_lines�textwrap�dedent)rr7�msgrrr�format_usage>sz PrettyHelpFormatter.format_usage)�descriptionrcCsZ|rRt|jd�rd}nd}|�d�}|��}|�t�|�d�}|�d|�d�}|SdSdS)N�main�Commands�Description�
z  z:
r&)�hasattr�parser�lstrip�rstripr8r9r:)rr=�labelrrr�format_descriptionFs
z&PrettyHelpFormatter.format_description)�epilogrcCs|r|SdSdS)Nr&r)rrHrrr�
format_epilogXsz!PrettyHelpFormatter.format_epilog)�text�indentrcs"�fdd�|�d�D�}d�|�S)Ncsg|]}�|�qSrr)�.0�line)rKrr�
<listcomp>`sz4PrettyHelpFormatter.indent_lines.<locals>.<listcomp>rA)�splitr2)rrJrK�	new_linesr)rKrr8_sz PrettyHelpFormatter.indent_lines)r"r#)�__name__�
__module__�__qualname__�__doc__rr�optparse�Option�strr!r r6r<rGrIr8�
__classcell__rr)rrr
s
r
cs*eZdZdZejed��fdd�Z�ZS)�UpdatingDefaultsHelpFormatterz�Custom help formatter for use in ConfigOptionParser.

    This is updates the defaults before expanding them, allowing
    them to show up correctly in the help listing.

    Also redact auth from url type options
    )rrcs�d}|jdk	rLt|jt�st�|j�|jj�|jdk	s<t�|jj�|j�}t��	|�}|r�|j
dkr�t|t�rv|g}t|t�s�g}x|D]}|�
|t|��}q�W|S)N�URL)rC�
isinstance�ConfigOptionParserr.�_update_defaults�defaultsr-�getr�expand_defaultr/rW�list�replacer)rrZdefault_values�	help_text�val)rrrr`ms



z,UpdatingDefaultsHelpFormatter.expand_default)	rQrRrSrTrUrVrWr`rXrr)rrrYdsrYc@s:eZdZeeeejd�dd�Zee	ej
d�dd��ZdS)�CustomOptionParser)�idxrrrcOs(|j||�}|j��|j�||�|S)z*Insert an OptionGroup at a given position.)�add_option_group�
option_groups�popr+)rrfrr�grouprrr�insert_option_group�s
z&CustomOptionParser.insert_option_group)rcCs.|jdd�}x|jD]}|�|j�qW|S)z<Get a list of all options, including those in option groups.N)�option_listrh�extend)r�res�irrr�option_list_all�sz"CustomOptionParser.option_list_allN)rQrRrS�intrrU�OptionGrouprk�propertyrrVrprrrrre�s	recs�eZdZdZdd�eeeedd��fdd�Zej	eeed�d	d
�Z
eeeefddfd�dd
�Z
eeefeeefd�dd�Zejd�dd�Zedd�dd�Z�ZS)r\zsCustom option parser which updates its defaults by checking the
    configuration files and environmental variablesF)�isolatedN)r�namertrrcs,||_t|�|_|jst�t�j||�dS)N)rur	�configr.rr)rrurtrr)rrrr�s

zConfigOptionParser.__init__)r�keyrdrc
CsNy|�||�Stjk
rH}ztd|���t�d�Wdd}~XYnXdS)Nz(An error occurred during configuration: �)�check_valuerU�OptionValueError�print�sys�exit)rrrwrd�excrrr�
check_default�s
z ConfigOptionParser.check_default)rccs�d|jdg}dd�|D�}xR|j��D]D\}}|s@t�d|�q&|�dd�\}}||kr&||�||f�q&Wx,|D]$}x||D]\}}||fVq�WqtWdS)N�globalz:env:cSsi|]
}g|�qSrr)rLrurrr�
<dictcomp>�szGConfigOptionParser._get_ordered_configuration_items.<locals>.<dictcomp>z7Ignoring configuration key '%s' as it's value is empty.�.r)rurv�items�logger�debugrOr()r�override_order�
section_items�section_keyrd�sectionrwrrr� _get_ordered_configuration_items�s
z3ConfigOptionParser._get_ordered_configuration_items)r^rc
s�t��j��_t�}�x����D�]�\�}��d����dkrBq �jdk	sPt��j	dkr�yt
|�}Wn*tk
r���|�d��d��YnX�n�j	dk�rt
t��t
|�}WdQRXt
t��t|�}WdQRXt|t�r�|dk�r���|�d��d��n��j	d	k�r2|��}���fd
d�|D�}n|�j	dk�r��jdk	�sNt�|��j����}��||�}�j�pxd
}�j�p�i}�j�||�f|�|�n����|�}||�j<q Wx|D]�t�j��|�<�q�Wd�_|S)z�Updates the given defaults with values from the config files and
        the environ. Does a little special handling for certain types of
        options (lists).z--N)�
store_true�store_falsez is not a valid value for zO option, please specify a boolean value like yes/no, true/false or 1/0 instead.�countrz� option, please instead specify either a non-negative integer or a boolean value like yes/no or false/true which is equivalent to 1/0.r(csg|]}����|��qSr)r)rL�v)rwrrrrrN�sz7ConfigOptionParser._update_defaults.<locals>.<listcomp>�callbackr)rU�Valuesr^�values�setr��
get_optionr-r.�actionr�
ValueError�errorrrqr[rOr��add�get_opt_string�
convert_value�
callback_args�callback_kwargsr�getattr)rr^�	late_evalrd�opt_strrrr)rwrrrr]�sL



z#ConfigOptionParser._update_defaultsc
Cs�|jst�|j�Sy|j��Wn2tk
rR}z|�tt	|��Wdd}~XYnX|�
|j���}xN|��D]B}|j
dk	s�t�|�|j
�}t|t	�rn|��}|�||�||j
<qnWt�|�S)z�Overriding to make updating the defaults after instantiation of
        the option parser possible, _update_defaults() does the dirty work.N)�process_default_valuesrUr�r^rv�loadr
r}rrWr]�copy�_get_all_optionsr-r.r_r[r�ry)r�errr^r�defaultr�rrr�get_default_valuess"
z%ConfigOptionParser.get_default_values)r;rcCs"|�tj�|�t|�d��dS)NrA)�print_usager|�stderrr}r)rr;rrrr�$szConfigOptionParser.error)rQrRrSrTrrW�boolrrUrVrrrr�rr]r�r�r�rXrr)rrr\�s	  @r\)rT�loggingrUrr|r9�
contextlibr�typingrrrrr�pip._internal.cli.status_codesr�pip._internal.configurationr	r
�pip._internal.utils.miscrr�	getLoggerrQr��IndentedHelpFormatterr
rY�OptionParserrer\rrrr�<module>s
R