B Re%@sdZddlmZddlZddlZddlZddlZddlmZddl m Z ddl m Z ddl mZmZddlmZeeZGd d d ejZGd d d eZGd ddejZGdddeZddZdS)zBase option parser setup)absolute_importN) strtobool) string_types) UNKNOWN_ERROR) ConfigurationConfigurationError)get_terminal_sizec@sReZdZdZddZddZddd Zd d Zd d ZddZ ddZ ddZ dS)PrettyHelpFormatterz4A prettier/less verbose help formatter for optparse.cOs:d|d<d|d<tdd|d<tjj|f||dS)Nmax_help_positionindent_incrementrwidth)roptparseIndentedHelpFormatter__init__)selfargskwargsr/builddir/build/BUILDROOT/alt-python37-pip-20.2.4-6.el8.x86_64/opt/alt/python37/lib/python3.7/site-packages/pip/_internal/cli/parser.pyrszPrettyHelpFormatter.__init__cCs ||S)N)_format_option_strings)roptionrrrformat_option_strings!sz)PrettyHelpFormatter.format_option_strings <{}>, cCs~g}|jr||jd|jr0||jdt|dkrH|d||rt|jp^|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 rr ) _short_optsappend _long_optsleninsert takes_valuemetavardestlowerformatjoin)rrmvarfmtoptsepoptsr$rrrr$s  z*PrettyHelpFormatter._format_option_stringscCs|dkr dS|dS)NOptionsrz: r)rheadingrrrformat_heading;sz"PrettyHelpFormatter.format_headingcCsd|t|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_usagecCsV|rNt|jdrd}nd}|d}|}|t|d}d||}|SdSdS)NmainCommands Description z z{}: {} r)hasattrparserlstriprstripr/r0r1r')r descriptionlabelrrrformat_descriptionIs   z&PrettyHelpFormatter.format_descriptioncCs|r|SdSdS)Nrr)repilogrrr format_epilog[sz!PrettyHelpFormatter.format_epilogcs"fdd|dD}d|S)Ncsg|] }|qSrr).0line)indentrr csz4PrettyHelpFormatter.indent_lines..r8)splitr()rtextrD new_linesr)rDrr/bsz PrettyHelpFormatter.indent_linesN)rr) __name__ __module__ __qualname____doc__rrrr.r4r?rAr/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|j|jjtj||S)N)r:_update_defaultsdefaultsrrexpand_default)rrrrrrPns z,UpdatingDefaultsHelpFormatter.expand_defaultN)rIrJrKrLrPrrrrrMgsrMc@s eZdZddZeddZdS)CustomOptionParsercOs(|j||}|j|j|||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]}||jqW|S)zszGConfigOptionParser._get_ordered_configuration_items..z7Ignoring configuration key '%s' as it's value is empty..r )r_raitemsloggerdebugrFr)roverride_order section_items section_keyrksectionrjrrr _get_ordered_configuration_itemss  z3ConfigOptionParser._get_ordered_configuration_itemsc sRtj_t}xD]\}ddkrBq jdkry t|}Wn,t k rt j|} |YnXnjdkr| }fdd|D}nhjdkr | j}||}jpd}jpi}j||f||n|}||j<q Wx|D]tj|<q.Wd_|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_true store_falsecountrcsg|]}|qSr)rm)rBv)rjrrrrrEsz7ConfigOptionParser._update_defaults..callbackr)rValuesrOvaluessetrx get_optionactionr ValueErrorinvalid_config_error_messageerrorrFaddr%get_opt_string convert_value callback_argscallback_kwargsr}rmgetattr)rrO late_evalrk error_msgopt_strrrr)rjrrrrNs:          z#ConfigOptionParser._update_defaultsc Cs|jst|jSy|jWn2tk rR}z|tt |Wdd}~XYnX| |j }x@| D]4}| |j}t|trn|}|||||j<qnWt|S)zOverriding to make updating the defaults after instantiation of the option parser possible, _update_defaults() does the dirty work.N)process_default_valuesrr~rOraloadrrirstrrNcopy_get_all_optionsgetr% isinstancerrre)rerrrOrdefaultrrrrget_default_valuess "  z%ConfigOptionParser.get_default_valuescCs"|tj|td|dS)Nz{} ) print_usagerhstderrrirr')rr3rrrrs zConfigOptionParser.errorN) rIrJrKrLrrmrxrNrrrrrrr^s 1r^cCs |dkrd||Sd||S)zQReturns a better error message when invalid configuration option is provided.)ryrzzo{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.)r')rrjrkrrrrs r)rL __future__rloggingrrhr0distutils.utilrZpip._vendor.sixrpip._internal.cli.status_codesrpip._internal.configurationrrpip._internal.utils.compatr getLoggerrIrrrr rMrcrQr^rrrrrs       P w