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: //lib/python3/dist-packages/pip/_internal/cli/__pycache__/parser.cpython-310.pyc
o

@%Ne$*�@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�Iterator�List�Tuple)�
UNKNOWN_ERROR)�
Configuration�ConfigurationError)�redact_auth_from_url�	strtoboolc	s�eZdZdZdededdf�fdd�Zdejdefd	d
�Z		d!dejd
ededefdd�Z
dedefdd�Zdedefdd�Zdedefdd�Z
dedefdd�Zdededefdd �Z�ZS)"�PrettyHelpFormatterz4A prettier/less verbose help formatter for optparse.�args�kwargs�returnNcs:d|d<d|d<t��dd|d<t�j|i|��dS)N��max_help_position��indent_incrementr��width)�shutil�get_terminal_size�super�__init__)�selfrr��	__class__��:/usr/lib/python3/dist-packages/pip/_internal/cli/parser.pyrszPrettyHelpFormatter.__init__�optioncCs
|�|�S�N)�_format_option_strings)rr rrr�format_option_stringss
z)PrettyHelpFormatter.format_option_strings� <{}>�, �mvarfmt�optsepcCs�g}|jr
|�|jd�|jr|�|jd�t|�dkr$|�d|�|��rA|jdus/J�|jp6|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�metavar�lower�format�join)rr r&r'�optsr0rrrr"s

z*PrettyHelpFormatter._format_option_strings�headingcCs|dkrdS|dS)N�Optionsr(�:
r)rr5rrr�format_heading9sz"PrettyHelpFormatter.format_heading�usagecCsd�|�t�|�d��}|S)zz
        Ensure there is only one newline between usage and the first heading
        if there is no description.
        z
Usage: {}
�  )r2�indent_lines�textwrap�dedent)rr9�msgrrr�format_usage>sz PrettyHelpFormatter.format_usage�descriptioncCsV|r)t|jd�rd}nd}|�d�}|��}|�t�|�d�}|�d|�d�}|SdS)N�main�Commands�Description�
r:r7r()�hasattr�parser�lstrip�rstripr;r<r=)rr@�labelrrr�format_descriptionFs
z&PrettyHelpFormatter.format_description�epilogcCs|r|SdS)Nr(r)rrKrrr�
format_epilogXsz!PrettyHelpFormatter.format_epilog�text�indentcs"�fdd�|�d�D�}d�|�S)Ncsg|]}�|�qSrr)�.0�line�rNrr�
<listcomp>`sz4PrettyHelpFormatter.indent_lines.<locals>.<listcomp>rD)�splitr3)rrMrN�	new_linesrrQrr;_s
z PrettyHelpFormatter.indent_lines)r$r%)�__name__�
__module__�__qualname__�__doc__rr�optparse�Option�strr#r"r8r?rJrLr;�
__classcell__rrrrr
s&����
�r
cs,eZdZdZdejdef�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
    r rcs�d}|jdur&t|jt�sJ�|j�|jj�|jdusJ�|jj�|j�}t��|�}|rO|j	dkrOt|t
�r;|g}t|t�sBg}|D]
}|�|t
|��}qD|S)N�URL)rF�
isinstance�ConfigOptionParser�_update_defaults�defaultsr/�getr�expand_defaultr0r[�list�replacer)rr �default_values�	help_text�valrrrrdms


z,UpdatingDefaultsHelpFormatter.expand_default)	rUrVrWrXrYrZr[rdr\rrrrr]ds r]c@s@eZdZdedededejfdd�Zede	ej
fdd��Zd	S)
�CustomOptionParser�idxrrrcOs,|j|i|��}|j��|j�||�|S)z*Insert an OptionGroup at a given position.)�add_option_group�
option_groups�popr-)rrkrr�grouprrr�insert_option_group�s
z&CustomOptionParser.insert_option_groupcCs*|jdd�}|jD]}|�|j�q
|S)z<Get a list of all options, including those in option groups.N)�option_listrm�extend)r�res�irrr�option_list_all�s
z"CustomOptionParser.option_list_allN)rUrVrW�intrrY�OptionGrouprp�propertyrrZrurrrrrj�s���
�rjcs�eZdZdZdd�dededededd	f
�fd
d�Zdej	d
ededefdd�Z
deeeeffdd�Z
deeefdeeeffdd�Zdejfdd�Zdedd	fdd�Z�ZS)r`zsCustom option parser which updates its defaults by checking the
    configuration files and environmental variablesF)�isolatedr�nameryrrNcs0||_t|�|_|js
J�t�j|i|��dSr!)rzr	�configrr)rrzryrrrrrr�s

zConfigOptionParser.__init__r �keyric
CsPz|�||�WStjy'}ztd|���t�d�WYd}~dSd}~ww)Nz(An error occurred during configuration: �)�check_valuerY�OptionValueError�print�sys�exit)rr r|ri�excrrr�
check_default�s��z ConfigOptionParser.check_defaultccs��d|jdg}dd�|D�}|j��D]"\}}|s t�d|�q|�dd�\}}||vr5||�||f�q|D]}||D]	\}}||fVq>q8dS)N�globalz:env:cSsi|]}|g�qSrr)rOrzrrr�
<dictcomp>�s�zGConfigOptionParser._get_ordered_configuration_items.<locals>.<dictcomp>z7Ignoring configuration key '%s' as it's value is empty.�.r)rzr{�items�logger�debugrSr*)r�override_order�
section_items�section_keyri�sectionr|rrr� _get_ordered_configuration_items�s*������z3ConfigOptionParser._get_ordered_configuration_itemsrbc
s�t��j��_t�}���D]�\�}��d����durq�jdus%J��jdvrCzt	|�}Wn�t
yB��d�|���Yn�w�jdkr�t
t
��t	|�}Wd�n1s[wYt
t
��t|�}Wd�n1sswYt|t�r�|dkr���d�|���nR�jdkr�|��}���fd	d
�|D�}n=�jdkrֈjdus�J�|��j����}��||�}�jp�d}�jp�i}�j�||�g|�Ri|��n����|�}||�j<q|D]
�t�j��|�<q�d�_|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_falsezm{} is not a valid value for {} option, please specify a boolean value like yes/no, true/false or 1/0 instead.�countrz�{} is not a valid value for {} 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�)rO�v�r|r rrrrR�sz7ConfigOptionParser._update_defaults.<locals>.<listcomp>�callbackr)rY�Valuesrb�values�setr��
get_optionr/�actionr�
ValueError�errorr2rrvr_rSr��add�get_opt_string�
convert_value�
callback_args�callback_kwargsr��getattr)rrb�	late_evalri�opt_strrrrr�rra�s\
��


�

���



 z#ConfigOptionParser._update_defaultsc
Cs�|js	t�|j�Sz|j��Wnty*}z|�tt	|��WYd}~nd}~ww|�
|j���}|��D]!}|j
dus@J�|�|j
�}t|t	�rX|��}|�||�||j
<q7t�|�S)z�Overriding to make updating the defaults after instantiation of
        the option parser possible, _update_defaults() does the dirty work.N)�process_default_valuesrYr�rbr{�loadr
r�rr[ra�copy�_get_all_optionsr/rcr_r�r~)r�errrbr �defaultr�rrr�get_default_valuess"��
�
z%ConfigOptionParser.get_default_valuesr>cCs"|�tj�|�t|�d��dS)NrD)�print_usager��stderrr�r)rr>rrrr�"szConfigOptionParser.error)rUrVrWrXrr[�boolrrYrZr�rrr�rrar�r�r�r\rrrrr`�s&������
"@r`)rX�loggingrYrr�r<�
contextlibr�typingrrrrr�pip._internal.cli.status_codesr�pip._internal.configurationr	r
�pip._internal.utils.miscrr�	getLoggerrUr��IndentedHelpFormatterr
r]�OptionParserrjr`rrrr�<module>s 
R