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

3

aj(@sdZddlmZddlZddlZddlZddlZddlZddlm	Z	ddl
mZddlm
Z
ddlmZmZmZmZddlmZmZejd	ejZGd
ddejZGdd
d
eZGdddejZGdddeZdS)zBase option parser setup)absolute_importN)	strtobool)string_types)configparser)legacy_config_fileconfig_basenamerunning_under_virtualenvsite_config_files)appdirsget_terminal_sizez^PIP_c@sReZdZdZddZddZddd	Zd
dZdd
ZddZ	ddZ
ddZdS)PrettyHelpFormatterz4A prettier/less verbose help formatter for optparse.cOs:d|d<d|d<tdd|d<tjj|f||dS)NZmax_help_positionZindent_incrementrwidth)roptparseIndentedHelpFormatter__init__)selfargskwargsr /usr/lib/python3.6/baseparser.pyrszPrettyHelpFormatter.__init__cCs|j|ddS)Nz <%s>z, )_format_option_strings)roptionrrrformat_option_strings!sz)PrettyHelpFormatter.format_option_strings <%s>, cCs|g}|jr|j|jd|jr0|j|jdt|dkrH|jd||jrr|jp^|jj}|j||jdj	|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_optsappendZ
_long_optsleninsertZtakes_valuemetavardestlowerjoin)rrZmvarfmtZoptsepZoptsr"rrrr$sz*PrettyHelpFormatter._format_option_stringscCs|dkrdS|dS)NZOptionsrz:
r)rZheadingrrrformat_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_linestextwrapdedent)rZusagemsgrrrformat_usage@sz PrettyHelpFormatter.format_usagecCsV|rNt|jdrd}nd}|jd}|j}|jtj|d}d||f}|SdSdS)NmainZCommandsZDescription
z  z%s:
%s
r)hasattrparserlstriprstripr'r(r))rdescriptionZlabelrrrformat_descriptionHs
z&PrettyHelpFormatter.format_descriptioncCs|r|SdSdS)Nrr)rZepilogrrr
format_epilogZsz!PrettyHelpFormatter.format_epilogcs"fdd|jdD}dj|S)Ncsg|]}|qSrr).0line)indentrr
<listcomp>bsz4PrettyHelpFormatter.indent_lines.<locals>.<listcomp>r-)splitr%)rtextr7Z	new_linesr)r7rr'asz PrettyHelpFormatter.indent_linesN)rr)__name__
__module____qualname____doc__rrrr&r+r3r4r'rrrrrs
rc@seZdZdZddZdS)UpdatingDefaultsHelpFormatterzCustom 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|jjtjj||S)N)r/_update_defaultsdefaultsrrexpand_default)rrrrrrBms
z,UpdatingDefaultsHelpFormatter.expand_defaultN)r;r<r=r>rBrrrrr?fsr?c@s eZdZddZeddZdS)CustomOptionParsercOs(|j||}|jj|jj|||S)z*Insert an OptionGroup at a given position.)Zadd_option_group
option_groupspopr!)ridxrrgrouprrrinsert_option_groupus
z&CustomOptionParser.insert_option_groupcCs.|jdd}x|jD]}|j|jqW|S)z<Get a list of all options, including those in option groups.N)Zoption_listrDextend)rresirrroption_list_all~sz"CustomOptionParser.option_list_allN)r;r<r=rHpropertyrLrrrrrCss	rCc@s\eZdZdZdZddZddZddZd	d
ZddZ	d
dZ
ddZddZddZ
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)NnameisolatedF)
rZRawConfigParserconfigrErOrPget_config_filesfilesreadAssertionErrorrOptionParserr)rrrrrrrs


zConfigOptionParser.__init__cCstjjdd}|tjkrgStt}|jsj|rFtjj|rF|j	|n$|j	t
|j	tjjtj
dttrtjjtjt}tjj|r|j	||S)NZPIP_CONFIG_FILEFZpip)osenvirongetdevnulllistr	rPpathexistsrrr%r
Zuser_config_dirrrsysprefix)rZconfig_filerSZvenv_config_filerrrrRs&


z#ConfigOptionParser.get_config_filescCsLy|j||Stjk
rF}ztd|tjdWYdd}~XnXdS)Nz*An error occurred during configuration: %s)check_valuerZOptionValueErrorprintr^exit)rrkeyvalexcrrr
check_defaults
z ConfigOptionParser.check_defaultc	sji}x(djfD]}|jjj|qWjsH|jjjtjj_	t
}x|jD]\}|stqfjdkrqfj
d
krt|}nj
dkr|j}fdd|D}nlj
d	kr$|jjj}j||}jpf}jpi}j||f||nj|}||j<qfWx|D]tj	|<qFWd_	|S)zUpdates 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_truestore_falsecountrcsg|]}j|qSr)rg)r5v)rdrrrrr8sz7ConfigOptionParser._update_defaults.<locals>.<listcomp>callback)rirjrk)rOupdatenormalize_keysget_config_sectionrPget_environ_varsrValuesrAvaluessetitemsZ
get_optionactionrr9addr#get_opt_stringZ
convert_valueZ
callback_argsZcallback_kwargsrmrggetattr)	rrArQZsectionZ	late_evalreopt_strrrr)rdrrrr@s@




z#ConfigOptionParser._update_defaultscCs@i}x6|D].\}}|jdd}|jds0d|}|||<q
W|S)zReturn 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
normalizedrdrerrrros
z!ConfigOptionParser.normalize_keyscCs|jj|r|jj|SgS)z Get a section of a configuration)rQZhas_sectionru)rrOrrrrpsz%ConfigOptionParser.get_config_sectionccs<x6tjjD](\}}tj|rtjd|j|fVqWdS)z@Returns a generator with all environmental vars with prefix PIP_rN)rWrXru_environ_prefix_researchsubr$)rrdrerrrrqs
z#ConfigOptionParser.get_environ_varscCsn|jstj|jS|j|jj}x@|jD]4}|j|j}t	|t
r,|j}|j||||j<q,Wtj|S)zOverriding 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)rrArdefaultrzrrrget_default_valuess
z%ConfigOptionParser.get_default_valuescCs |jtj|jdd|dS)Nrz%s
)Zprint_usager^stderrrc)rr*rrrerror#szConfigOptionParser.errorN)r;r<r=r>rPrrRrgr@rorprqrrrrrrrNs
(5rN)r>Z
__future__rr^rrWrer(Zdistutils.utilrZpip._vendor.sixrZpip._vendor.six.movesrZ
pip.locationsrrrr	Z	pip.utilsr
rcompileIrrrr?rVrCrNrrrr<module>s O

Back to Directory File Manager