AlkantarClanX12

Your IP : 3.145.95.233


Current Path : /opt/alt/python34/lib/python3.4/site-packages/pip/__pycache__/
Upload File :
Current File : //opt/alt/python34/lib/python3.4/site-packages/pip/__pycache__/baseparser.cpython-34.pyc

�
�Re��@s�dZddlZddlZddlZddlZddlmZddlmZm	Z	ddl
mZddlm
Z
mZddlmZGdd	�d	ej�ZGd
d�de�ZGdd
�d
ej�ZGdd�de�ZdS)zBase option parser setup�N)�	strtobool)�ConfigParser�string_types)�default_config_file)�get_terminal_size�get_prog)�
pkg_resourcesc@s|eZdZdZdd�Zdd�Zdddd	�Zd
d�Zdd
�Zdd�Z	dd�Z
dd�ZdS)�PrettyHelpFormatterz4A prettier/less verbose help formatter for optparse.cOsCd|d<d|d<t�dd|d<tjj|||�dS)N��max_help_position��indent_incrementr��width)r�optparse�IndentedHelpFormatter�__init__)�self�args�kwargs�r�)/tmp/pip-ztkk0jow-build/pip/baseparser.pyrs

zPrettyHelpFormatter.__init__cCs|j|dd�S)Nz <%s>z, )�_format_option_strings)r�optionrrr�format_option_stringssz)PrettyHelpFormatter.format_option_stringsz <%s>z, cCs�g}|jr&|j|jd�n|jrF|j|jd�nt|�dkrk|jd|�n|j�r�|jp�|jj�}|j||j��ndj	|�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�)
�_short_opts�append�
_long_opts�len�insert�takes_value�metavar�dest�lower�join)rr�mvarfmt�optsep�optsr"rrrrs		z*PrettyHelpFormatter._format_option_stringscCs|dkrdS|dS)N�Optionsrz:
r)r�headingrrr�format_heading3sz"PrettyHelpFormatter.format_headingcCs#d|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)r�usage�msgrrr�format_usage8sz PrettyHelpFormatter.format_usagecCsy|rqt|jd�r!d}nd}|jd�}|j�}|jtj|�d�}d||f}|SdSdS)N�main�Commands�Description�
z  z%s:
%s
r)�hasattr�parser�lstrip�rstripr,r-r.)r�description�labelrrr�format_description@s	z&PrettyHelpFormatter.format_descriptioncCs|r
|SdSdS)Nrr)r�epilogrrr�
format_epilogRsz!PrettyHelpFormatter.format_epilogcs/�fdd�|jd�D�}dj|�S)Ncsg|]}�|�qSrr)�.0�line)�indentrr�
<listcomp>Zs	z4PrettyHelpFormatter.indent_lines.<locals>.<listcomp>r5)�splitr%)r�textrA�	new_linesr)rArr,Ys"z PrettyHelpFormatter.indent_linesN)�__name__�
__module__�__qualname__�__doc__rrrr+r1r<r>r,rrrrr	sr	c@s"eZdZdZdd�ZdS)�UpdatingDefaultsHelpFormatterz�Custom help formatter for use in ConfigOptionParser that updates
    the defaults before expanding them, allowing them to show up correctly
    in the help listingcCs;|jdk	r(|jj|jj�ntjj||�S)N)r7�update_defaults�defaultsrr�expand_default)rrrrrrMcsz,UpdatingDefaultsHelpFormatter.expand_defaultN)rFrGrHrIrMrrrrrJ^srJc@s.eZdZdd�Zedd��ZdS)�CustomOptionParsercOs6|j||�}|jj�|jj||�|S)z*Insert an OptionGroup at a given position.)�add_option_group�
option_groups�popr )r�idxrr�grouprrr�insert_option_groupjs
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)�option_listrP�extend)r�res�irrr�option_list_allssz"CustomOptionParser.option_list_allN)rFrGrHrT�propertyrYrrrrrNis	rNc@s�eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	ddd�Z
dd�Zdd�ZdS)�ConfigOptionParserzsCustom option parser which updates its defaults by checking the
    configuration files and environmental variablescOsxtj�|_|jd�|_|j�|_|jrO|jj|j�n|js^t�t	j
j|||�dS)N�name)r�RawConfigParser�configrQr\�get_config_files�files�read�AssertionErrorr�OptionParserr)rrrrrrr�s	zConfigOptionParser.__init__cCsNtjjdd�}|tjkr(gS|rGtjj|�rG|gStgS)N�PIP_CONFIG_FILEF)�os�environ�get�devnull�path�existsr)r�config_filerrrr_�sz#ConfigOptionParser.get_config_filescCs[y|j||�SWn@tjk
rVtj�d}td|�tjd�YnXdS)Nrz*An error occurred during configuration: %s�)�check_valuer�OptionValueError�sys�exc_info�print�exit)rr�key�val�errr�
check_default�sz ConfigOptionParser.check_defaultcs#i}x6d�jfD]%}|j�j�j|���qW|j�j�j���x�|j�D]�\�}�j����dk	rh|s�qhn�jd	kr�t|�}n�jdkr�|j	�}���fdd�|D�}n�j
��|�}||�j<qhqhW|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�countrcs%g|]}�j��|��qSr)rv)r?�v)rsrrrrrB�s	z6ConfigOptionParser.update_defaults.<locals>.<listcomp>)z
store_truezstore_falsezcount)r\�update�normalize_keys�get_config_section�get_environ_vars�items�
get_option�actionrrCrvr#)rrLr^�sectionrtr)rsrrrrK�s"#"z"ConfigOptionParser.update_defaultscCsYi}xL|D]D\}}|jdd�}|jd�sGd|}n|||<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)rr��
normalizedrsrtrrrr}�s
z!ConfigOptionParser.normalize_keyscCs&|jj|�r"|jj|�SgS)z Get a section of a configuration)r^�has_sectionr�)rr\rrrr~�sz%ConfigOptionParser.get_config_section�PIP_ccsSxLtjj�D];\}}|j|�r|j|d�j�|fVqqWdS)z@Returns a generator with all environmental vars with prefix PIP_rN)rerfr�r�r�r$)r�prefixrsrtrrrr�sz#ConfigOptionParser.get_environ_varscCs�|jstj|j�S|j|jj��}x]|j�D]O}|j|j�}t	|t
�r>|j�}|j||�||j<q>q>Wtj|�S)z�Overridding to make updating the defaults after instantiation of
        the option parser possible, update_defaults() does the dirty work.)
�process_default_valuesr�ValuesrLrK�copy�_get_all_optionsrgr#�
isinstancer�get_opt_stringrm)rrLr�default�opt_strrrr�get_default_values�s	 z%ConfigOptionParser.get_default_valuescCs(|jtj�|jdd|�dS)Nrz%s
)�print_usagero�stderrrr)rr0rrr�error�szConfigOptionParser.errorN)
rFrGrHrIrr_rvrKr}r~rr�r�rrrrr[}s	r[)rIrorrer-�distutils.utilrZpip.backwardcompatrr�
pip.locationsr�pip.utilrr�pip._vendorrrr	rJrcrNr[rrrr�<module>sO