3 ”Re%ã@sÊdZddlmZddlZddlZddlZddlZddlmZddl m Z ddl m Z ddl mZmZddlmZejeƒZGd d „d ejƒZGd d „d eƒZGd d„dejƒZGdd„deƒZdd„ZdS)zBase option parser setupé)Úabsolute_importN)Ú strtobool)Ú string_types)Ú UNKNOWN_ERROR)Ú ConfigurationÚConfigurationError)Úget_terminal_sizec@sReZdZdZdd„Zdd„Zddd „Zd d „Zd d „Zdd„Z dd„Z dd„Z dS)ÚPrettyHelpFormatterz4A prettier/less verbose help formatter for optparse.cOs:d|d<d|d<tƒdd|d<tjj|f|ž|ŽdS)NéÚmax_help_positionéÚindent_incrementréÚwidth)rÚoptparseÚIndentedHelpFormatterÚ__init__)ÚselfÚargsÚkwargs©rú‡/builddir/build/BUILDROOT/alt-python36-pip-20.2.4-5.el8.x86_64/opt/alt/python36/lib/python3.6/site-packages/pip/_internal/cli/parser.pyrszPrettyHelpFormatter.__init__cCs |j|ƒS)N)Ú_format_option_strings)rÚoptionrrrÚformat_option_strings!sz)PrettyHelpFormatter.format_option_stringsú <{}>ú, cCs~g}|jr|j|jdƒ|jr0|j|jdƒt|ƒdkrH|jd|ƒ|jƒrt|jp^|jjƒ}|j|j |jƒƒƒdj |ƒ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_optsÚappendÚ _long_optsÚlenÚinsertÚ takes_valueÚmetavarÚdestÚlowerÚformatÚjoin)rrÚmvarfmtÚoptsepÚoptsr$rrrr$s  z*PrettyHelpFormatter._format_option_stringscCs|dkr dS|dS)NÚOptionsrz: r)rÚheadingrrrÚformat_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_linesÚtextwrapÚdedent)rÚusageÚmsgrrrÚ format_usage@sz PrettyHelpFormatter.format_usagecCsV|rNt|jdƒrd}nd}|jdƒ}|jƒ}|jtj|ƒdƒ}dj||ƒ}|SdSdS)NÚmainÚCommandsÚ DescriptionÚ z z{}: {} r)ÚhasattrÚparserÚlstripÚrstripr/r0r1r')rÚ descriptionÚlabelrrrÚformat_descriptionIs   z&PrettyHelpFormatter.format_descriptioncCs|r|SdSdS)Nrr)rÚepilogrrrÚ format_epilog[sz!PrettyHelpFormatter.format_epilogcs"‡fdd„|jdƒDƒ}dj|ƒS)Ncsg|] }ˆ|‘qSrr)Ú.0Úline)Úindentrrú csz4PrettyHelpFormatter.indent_lines..r8)Úsplitr()rÚtextrDÚ new_linesr)rDrr/bsz PrettyHelpFormatter.indent_linesN)rr) Ú__name__Ú __module__Ú __qualname__Ú__doc__rrrr.r4r?rAr/rrrrr s  r c@seZdZdZdd„ZdS)ÚUpdatingDefaultsHelpFormatterz®Custom 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|jjƒtjj||ƒS)N)r:Ú_update_defaultsÚdefaultsrrÚexpand_default)rrrrrrPns z,UpdatingDefaultsHelpFormatter.expand_defaultN)rIrJrKrLrPrrrrrMgsrMc@s eZdZdd„Zedd„ƒZdS)ÚCustomOptionParsercOs(|j||Ž}|jjƒ|jj||ƒ|S)z*Insert an OptionGroup at a given position.)Úadd_option_groupÚ option_groupsÚpopr")rÚidxrrÚgrouprrrÚinsert_option_groupvs  z&CustomOptionParser.insert_option_groupcCs.|jdd…}x|jD]}|j|jƒqW|S)z¢szGConfigOptionParser._get_ordered_configuration_items..z7Ignoring configuration key '%s' as it's value is empty.Ú.r )r_raÚitemsÚloggerÚdebugrFr)rÚoverride_orderÚ section_itemsÚ section_keyrkÚsectionrjrrrÚ _get_ordered_configuration_items�s  z3ConfigOptionParser._get_ordered_configuration_itemsc sRtjˆjƒˆ_tƒ}�xˆjƒD�]\‰}ˆjdˆƒ‰ˆdkrBq ˆjd krˆy t|ƒ}Wn,t k r„t ˆjˆ|ƒ}ˆj |ƒYnXn’ˆjdkr²|j ƒ}‡‡‡fdd„|Dƒ}nhˆjd k�r |j ˆjƒˆjƒ}ˆj||ƒ}ˆjpæf}ˆjpði}ˆjˆ||ˆf|ž|Žnˆjˆˆ|ƒ}||ˆj<q Wx|D]‰tˆjˆƒ|ˆ<�q.Wdˆ_|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).z--NÚ store_trueÚ store_falseÚcountrcsg|]}ˆjˆˆ|ƒ‘qSr)rm)rBÚv)rjrrrrrEÓsz7ConfigOptionParser._update_defaults..Úcallback)ryrzr{)rÚValuesrOÚvaluesÚsetrxÚ get_optionÚactionrÚ ValueErrorÚinvalid_config_error_messageÚerrorrFÚaddr%Úget_opt_stringÚ convert_valueÚ callback_argsÚcallback_kwargsr}rmÚgetattr)rrOÚ late_evalrkÚ error_msgÚopt_strrrr)rjrrrrNµs:          z#ConfigOptionParser._update_defaultscCs°|jstj|jƒSy|jjƒWn2tk rR}z|jtt |ƒƒWYdd}~XnX|j |jj ƒƒ}x@|j ƒD]4}|j |jƒ}t|tƒrn|jƒ}|j||ƒ||j<qnWtj|ƒS)z‹Overriding to make updating the defaults after instantiation of the option parser possible, _update_defaults() does the dirty work.N)Úprocess_default_valuesrr~rOraÚloadrrirÚstrrNÚcopyÚ_get_all_optionsÚgetr%Ú isinstancerr‡re)rÚerrrOrÚdefaultrŽrrrÚget_default_valuesæs "  z%ConfigOptionParser.get_default_valuescCs"|jtjƒ|jtdj|ƒƒdS)Nz{} )Ú print_usagerhÚstderrrirr')rr3rrrr…ûs zConfigOptionParser.errorN) rIrJrKrLrrmrxrNr˜r…rrrrr^‰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')r‚rjrkrrrr„s r„)rLÚ __future__rÚloggingrrhr0Údistutils.utilrZpip._vendor.sixrÚpip._internal.cli.status_codesrÚpip._internal.configurationrrÚpip._internal.utils.compatrÚ getLoggerrIrrrr rMrcrQr^r„rrrrÚs       P w