Viewing File: /opt/alt/python35/lib/python3.5/site-packages/pip/_internal/cli/__pycache__/parser.cpython-35.pyc



t_%@sdZddlmZddlZddlZddlZddlZddlmZddl	m
Z
ddlmZddl
mZmZddlmZejeZGd	d
d
ejZGdddeZGd
ddejZGdddeZddZdS)zBase option parser setup)absolute_importN)	strtobool)string_types)
UNKNOWN_ERROR)
ConfigurationConfigurationError)get_terminal_sizec@s|eZdZdZddZddZdddd	Zd
dZdd
ZddZ	ddZ
ddZdS)PrettyHelpFormatterz4A prettier/less verbose help formatter for optparse.cOsCd|d<d|d<tdd|d<tjj|||dS)Nmax_help_positionindent_incrementrwidth)roptparseIndentedHelpFormatter__init__)selfargskwargsr/builddir/build/BUILDROOT/alt-python35-pip-20.2.4-1.el7.x86_64/opt/alt/python35/lib/python3.5/site-packages/pip/_internal/cli/parser.pyrs

zPrettyHelpFormatter.__init__cCs
|j|S)N)_format_option_strings)roptionrrrformat_option_strings!sz)PrettyHelpFormatter.format_option_stringsz <{}>z, cCsg}|jr#|j|jd|jr@|j|jdt|dkrb|jd||jr|jp|jj}|j|j	|jdj
|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
        rr)_short_optsappend
_long_optsleninserttakes_valuemetavardestlowerformatjoin)rrmvarfmtoptsepoptsr"rrrr$s		z*PrettyHelpFormatter._format_option_stringscCs|dkrdS|dS)NOptionsrz:
r)rheadingrrrformat_heading;sz"PrettyHelpFormatter.format_headingcCs(dj|jtj|d}|S)zz
        Ensure there is only one newline between usage and the first heading
        if there is no description.
        z
Usage: {}
z  )r%indent_linestextwrapdedent)rusagemsgrrrformat_usage@sz PrettyHelpFormatter.format_usagecCs{|rst|jdr!d}nd}|jd}|j}|jtj|d}dj||}|SdSdS)NmainCommandsDescription
z  z{}:
{}
r)hasattrparserlstriprstripr-r.r/r%)rdescriptionlabelrrrformat_descriptionIs	z&PrettyHelpFormatter.format_descriptioncCs|r
|SdSdS)Nrr)repilogrrr
format_epilog[sz!PrettyHelpFormatter.format_epilogcs/fdd|jdD}dj|S)Ncsg|]}|qSrr).0line)indentrr
<listcomp>cs	z4PrettyHelpFormatter.indent_lines.<locals>.<listcomp>r6)splitr&)rtextrB	new_linesr)rBrr-bs"z PrettyHelpFormatter.indent_linesN)__name__
__module____qualname____doc__rrrr,r2r=r?r-rrrrr	s	r	c@s"eZdZdZddZdS)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.
    cCs8|jdk	r%|jj|jjtjj||S)N)r8_update_defaultsdefaultsrrexpand_default)rrrrrrNnsz,UpdatingDefaultsHelpFormatter.expand_defaultN)rGrHrIrJrNrrrrrKgsrKc@s.eZdZddZeddZdS)CustomOptionParsercOs6|j||}|jj|jj|||S)z*Insert an OptionGroup at a given position.)add_option_group
option_groupspopr )ridxrrgrouprrrinsert_option_groupvs
z&CustomOptionParser.insert_option_groupcCs;|jdd}x!|jD]}|j|jqW|S)z<Get a list of all options, including those in option groups.N)option_listrQextend)rresirrroption_list_allsz"CustomOptionParser.option_list_allN)rGrHrIrUpropertyrZrrrrrOts	rOc@s^eZdZdZddZddZddZdd	Zd
dZdd
Z	dS)ConfigOptionParserzsCustom option parser which updates its defaults by checking the
    configuration files and environmental variablescOs\|jd|_|jdd}t||_|jsBttjj|||dS)NnameisolatedF)rRr]rconfigAssertionErrorrOptionParserr)rrrr^rrrrs
zConfigOptionParser.__init__cCscy|j||SWnHtjk
r^}z%tdj|tjdWYdd}~XnXdS)Nz*An error occurred during configuration: {})check_valuerOptionValueErrorprintr%sysexit)rrkeyvalexcrrr
check_defaults
z ConfigOptionParser.check_defaultccsd|jdg}dd|D}xq|jjD]`\}}|sZtjd|q5|jdd\}}||kr5||j||fq5Wx4|D],}x#||D]\}}||fVqWqWdS)Nglobalz:env:cSsi|]}g|qSrr)r@r]rrr
<dictcomp>s	zGConfigOptionParser._get_ordered_configuration_items.<locals>.<dictcomp>z7Ignoring configuration key '%s' as it's value is empty..r)r]r_itemsloggerdebugrDr)roverride_order
section_itemssection_keyrisectionrhrrr _get_ordered_configuration_itemss
z3ConfigOptionParser._get_ordered_configuration_itemscstjj_t}xnjD]`\}jddkrYq+jd
kryt|}Wq~t	k
rt
j|}j|Yq~Xnjdkr|j}fdd|D}njd	kri|j
jj}j||}jp8f}jpGi}j||||nj|}||j<q+Wx$|D]tj|<qWd_|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).z--N
store_truestore_falsecountrcs%g|]}j|qSr)rk)r@v)rhrrrrrCs	z7ConfigOptionParser._update_defaults.<locals>.<listcomp>callback)rwrxry)rValuesrMvaluessetrv
get_optionactionr
ValueErrorinvalid_config_error_messageerrorrDaddr#get_opt_string
convert_value
callback_argscallback_kwargsr{rkgetattr)rrM	late_evalri	error_msgopt_strrrr)rhrrrrLs:	
"
	z#ConfigOptionParser._update_defaultscCs|jstj|jSy|jjWn;tk
rg}z|jtt	|WYdd}~XnX|j
|jj}xZ|jD]L}|j
|j}t|tr|j}|j||||j<qWtj|S)zOverriding to make updating the defaults after instantiation of
        the option parser possible, _update_defaults() does the dirty work.N)process_default_valuesrr|rMr_loadrrgrstrrLcopy_get_all_optionsgetr#
isinstancerrrc)rerrrMrdefaultrrrrget_default_valuess	)z%ConfigOptionParser.get_default_valuescCs-|jtj|jtdj|dS)Nz{}
)print_usagerfstderrrgrr%)rr1rrrrszConfigOptionParser.errorN)
rGrHrIrJrrkrvrLrrrrrrr\s	1r\cCs,|dkrdj||Sdj||S)zQReturns a better error message when invalid configuration option
    is provided.rwrxzo{0} is not a valid value for {1} option, please specify a boolean value like yes/no, true/false or 1/0 instead.z[{0} is not a valid value for {1} option, please specify a numerical value like 1/0 instead.)rwrx)r%)rrhrirrrrs

r)rJ
__future__rloggingrrfr.distutils.utilrZpip._vendor.sixrpip._internal.cli.status_codesrpip._internal.configurationrrpip._internal.utils.compatr	getLoggerrGrprr	rKrarOr\rrrrr<module>s P
w
Back to Directory File Manager