AlkantarClanX12

Your IP : 13.58.28.196


Current Path : /usr/lib/python3.6/site-packages/pip/__pycache__/
Upload File :
Current File : //usr/lib/python3.6/site-packages/pip/__pycache__/baseparser.cpython-36.pyc

3

�Pf�(�@s�dZddlmZddlZddlZddlZddlZddlZddlm	Z	ddl
mZddlm
Z
ddlmZmZmZmZddlmZmZejd	ej�ZGd
d�dej�ZGdd
�d
e�ZGdd�dej�ZGdd�de�ZdS)zBase option parser setup�)�absolute_importN)�	strtobool)�string_types)�configparser)�legacy_config_file�config_basename�running_under_virtualenv�site_config_files)�appdirs�get_terminal_sizez^PIP_c@sReZdZdZdd�Zdd�Zddd	�Zd
d�Zdd
�Zdd�Z	dd�Z
dd�ZdS)�PrettyHelpFormatterz4A prettier/less verbose help formatter for optparse.cOs:d|d<d|d<t�dd|d<tjj|f|�|�dS)N�Zmax_help_position�Zindent_incrementr��width)r�optparse�IndentedHelpFormatter�__init__)�self�args�kwargs�r� /usr/lib/python3.6/baseparser.pyrszPrettyHelpFormatter.__init__cCs|j|dd�S)Nz <%s>z, )�_format_option_strings)r�optionrrr�format_option_strings!sz)PrettyHelpFormatter.format_option_strings� <%s>�, cCs|g}|jr|j|jd�|jr0|j|jd�t|�dkrH|jd|�|j�rr|jp^|jj�}|j||j��dj	|�S)a
        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 - evaluated as mvarfmt % metavar
        :param optsep:  separator
        rr�)
Z_short_opts�appendZ
_long_opts�len�insertZtakes_value�metavar�dest�lower�join)rrZmvarfmtZoptsepZoptsr"rrrr$sz*PrettyHelpFormatter._format_option_stringscCs|dkrdS|dS)NZOptionsrz:
r)rZheadingrrr�format_heading;sz"PrettyHelpFormatter.format_headingcCsd|jtj|�d�}|S)zz
        Ensure there is only one newline between usage and the first heading
        if there is no description.
        z
Usage: %s
z  )�indent_lines�textwrap�dedent)rZusage�msgrrr�format_usage@sz PrettyHelpFormatter.format_usagecCsV|rNt|jd�rd}nd}|jd�}|j�}|jtj|�d�}d||f}|SdSdS)N�mainZCommandsZDescription�
z  z%s:
%s
r)�hasattr�parser�lstrip�rstripr'r(r))r�descriptionZlabelrrr�format_descriptionHs
z&PrettyHelpFormatter.format_descriptioncCs|r|SdSdS)Nrr)rZepilogrrr�
format_epilogZsz!PrettyHelpFormatter.format_epilogcs"�fdd�|jd�D�}dj|�S)Ncsg|]}�|�qSrr)�.0�line)�indentrr�
<listcomp>bsz4PrettyHelpFormatter.indent_lines.<locals>.<listcomp>r-)�splitr%)r�textr7Z	new_linesr)r7rr'asz PrettyHelpFormatter.indent_linesN)rr)�__name__�
__module__�__qualname__�__doc__rrrr&r+r3r4r'rrrrrs
rc@seZdZdZdd�ZdS)�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.
    cCs(|jdk	r|jj|jj�tjj||�S)N)r/�_update_defaults�defaultsrr�expand_default)rrrrrrBms
z,UpdatingDefaultsHelpFormatter.expand_defaultN)r;r<r=r>rBrrrrr?fsr?c@s eZdZdd�Zedd��ZdS)�CustomOptionParsercOs(|j||�}|jj�|jj||�|S)z*Insert an OptionGroup at a given position.)Zadd_option_group�
option_groups�popr!)r�idxrr�grouprrr�insert_option_groupus
z&CustomOptionParser.insert_option_groupcCs.|jdd�}x|jD]}|j|j�qW|S)z<Get a list of all options, including those in option groups.N)Zoption_listrD�extend)r�res�irrr�option_list_all~sz"CustomOptionParser.option_list_allN)r;r<r=rH�propertyrLrrrrrCss	rCc@s\eZdZdZdZdd�Zdd�Zdd�Zd	d
�Zdd�Z	d
d�Z
dd�Zdd�Zdd�Z
dS)�ConfigOptionParserzsCustom option parser which updates its defaults by checking the
    configuration files and environmental variablesFcOsdtj�|_|jd�|_|jdd�|_|j�|_|jrB|jj|j�|jsLt	�t
jj|f|�|�dS)N�name�isolatedF)
rZRawConfigParser�configrErOrP�get_config_files�files�read�AssertionErrorr�OptionParserr)rrrrrrr�s


zConfigOptionParser.__init__cCs�tjjdd�}|tjkrgStt�}|jsj|rFtjj|�rF|j	|�n$|j	t
�|j	tjjtj
d�t��t�r�tjjtjt�}tjj|�r�|j	|�|S)NZPIP_CONFIG_FILEFZpip)�os�environ�get�devnull�listr	rP�path�existsrrr%r
Zuser_config_dirrr�sys�prefix)rZconfig_filerSZvenv_config_filerrrrR�s&


z#ConfigOptionParser.get_config_filescCsLy|j||�Stjk
rF}ztd|�tjd�WYdd}~XnXdS)Nz*An error occurred during configuration: %s�)�check_valuerZOptionValueError�printr^�exit)rr�key�val�excrrr�
check_default�s
z ConfigOptionParser.check_defaultc	sji}x(d�jfD]}|j�j�j|���qW�jsH|j�j�j���tj�j��_	t
�}x�|j�D]�\�}|stqf�j����dkr�qf�j
d
kr�t|�}n��j
dkr�|j�}���fdd�|D�}nl�j
d	k�r$|j�j��j�}�j||�}�j�p�f}�j�pi}�j�||�f|�|�n�j��|�}||�j<qfWx|D]�t�j	��|�<�qFWd�_	|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).�globalN�
store_true�store_false�countrcsg|]}�j��|��qSr)rg)r5�v)rdrrrrr8�sz7ConfigOptionParser._update_defaults.<locals>.<listcomp>�callback)rirjrk)rO�update�normalize_keys�get_config_sectionrP�get_environ_varsr�ValuesrA�values�set�itemsZ
get_option�actionrr9�addr#�get_opt_stringZ
convert_valueZ
callback_argsZcallback_kwargsrmrg�getattr)	rrArQZsectionZ	late_evalre�opt_strrrr)rdrrrr@�s@




z#ConfigOptionParser._update_defaultscCs@i}x6|D].\}}|jdd�}|jd�s0d|}|||<q
W|S)z�Return a config dictionary with normalized keys regardless of
        whether the keys were specified in environment variables or in config
        files�_�-z--z--%s)�replace�
startswith)rruZ
normalizedrdrerrrro�s
z!ConfigOptionParser.normalize_keyscCs|jj|�r|jj|�SgS)z Get a section of a configuration)rQZhas_sectionru)rrOrrrrpsz%ConfigOptionParser.get_config_sectionccs<x6tjj�D](\}}tj|�rtjd|�j�|fVqWdS)z@Returns a generator with all environmental vars with prefix PIP_rN)rWrXru�_environ_prefix_re�search�subr$)rrdrerrrrqs
z#ConfigOptionParser.get_environ_varscCsn|jstj|j�S|j|jj��}x@|j�D]4}|j|j�}t	|t
�r,|j�}|j||�||j<q,Wtj|�S)z�Overriding to make updating the defaults after instantiation of
        the option parser possible, _update_defaults() does the dirty work.)
Zprocess_default_valuesrrrrAr@�copyZ_get_all_optionsrYr#�
isinstancerrxra)rrAr�defaultrzrrr�get_default_valuess
z%ConfigOptionParser.get_default_valuescCs |jtj�|jdd|�dS)Nrz%s
)Zprint_usager^�stderrrc)rr*rrr�error#szConfigOptionParser.errorN)r;r<r=r>rPrrRrgr@rorprqr�r�rrrrrN�s
(5rN)r>Z
__future__rr^rrW�rer(Zdistutils.utilrZpip._vendor.sixrZpip._vendor.six.movesrZ
pip.locationsrrrr	Z	pip.utilsr
r�compile�Irrrr?rVrCrNrrrr�<module>s O