3 Bu_%@sdZddlmZddlZddlZddlZddlZddlmZddl m Z ddl m Z ddl mZmZddlmZejeZGd 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-python36-pip-20.2.4-1.el7.x86_64/opt/alt/python36/lib/python3.6/site-packages/pip/_internal/cli/parser.pyrszPrettyHelpFormatter.__init__cCs |j|S)N)_format_option_strings)roptionrrrformat_option_strings!sz)PrettyHelpFormatter.format_option_strings <{}>, cCs~g}|jr|j|jd|jr0|j|jdt|dkrH|jd||jrt|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_optsleninsert takes_valuemetavardestlowerformatjoin)rrmvarfmtoptsepoptsr$rrrr$s  z*PrettyHelpFormatter._format_option_stringscCs|dkr dS|dS)NOptionsrz: r)rheadingrrrformat_heading;sz"PrettyHelpFormatter.format_headingcCsdj|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_usagecCsV|rNt|jdrd}nd}|jd}|j}|jtj|d}dj||}|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|jdD}dj|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|jj|jjtjj||S)N)r:_update_defaultsdefaultsrrexpand_default)rrrrrrPns z,UpdatingDefaultsHelpFormatter.expand_defaultN)rIrJrKrLrPrrrrrMgsrMc@s eZdZddZeddZdS)CustomOptionParsercOs(|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)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 sRtjj_t}xjD]\}jddkrBq jd kry t|}Wn,t k rt j|}j |YnXnjdkr|j }fdd|D}nhjd kr |j jj}j||}jpf}jpi}j||f||nj|}||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|]}j|qSr)rm)rBv)rjrrrrrEsz7ConfigOptionParser._update_defaults..callback)ryrzr{)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_defaultscCs|jstj|jSy|jjWn2tk rR}z|jtt |WYdd}~XnX|j |jj }x@|j D]4}|j |j}t|trn|j}|j||||j<qnWtj|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"|jtj|jtdj|dS)Nz{} ) print_usagerhstderrrirr')rr3rrrrs zConfigOptionParser.errorN) rIrJrKrLrrmrxrNrrrrrrr^s 1r^cCs |dkrdj||Sdj||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.)ryrz)r')rrjrkrrrrs r)rL __future__rloggingrrhr0distutils.utilrZpip._vendor.sixrpip._internal.cli.status_codesrpip._internal.configurationrrpip._internal.utils.compatr getLoggerrIrrrr rMrcrQr^rrrrrs       P w