a Re$*@sdZddlZddlZddlZddlZddlZddlmZddlm Z m Z m Z m Z m Z ddlmZddlmZmZddlmZmZeeZGdd d ejZGd d d eZGd d d ejZGdddeZdS)zBase option parser setupN)suppress)AnyDictIteratorListTuple) UNKNOWN_ERROR) ConfigurationConfigurationError)redact_auth_from_url strtoboolcseZdZdZeeddfdd ZejedddZ dejeeed d d Z eedddZ eedddZ eedddZ eedddZeeedddZZS)PrettyHelpFormatterz4A prettier/less verbose help formatter for optparse.N)argskwargsreturncs:d|d<d|d<tdd|d<tj|i|dS)Nmax_help_positionindent_incrementrwidth)shutilget_terminal_sizesuper__init__)selfrr __class__/builddir/build/BUILDROOT/alt-python39-pip-21.3.1-2.el8.x86_64/opt/alt/python39/lib/python3.9/site-packages/pip/_internal/cli/parser.pyrszPrettyHelpFormatter.__init__optionrcCs ||SN)_format_option_strings)rr!rrrformat_option_stringssz)PrettyHelpFormatter.format_option_strings <{}>, )r!mvarfmtoptseprcCsg}|jr||jd|jr0||jdt|dkrH|d||r|jdus^J|jpl|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 rrN) _short_optsappend _long_optsleninsert takes_valuedestmetavarlowerformatjoin)rr!r'r(optsr1rrrr#s   z*PrettyHelpFormatter._format_option_strings)headingrcCs|dkr dS|dS)NOptionsr): r)rr6rrrformat_heading9sz"PrettyHelpFormatter.format_heading)usagercCsd|t|d}|S)zz Ensure there is only one newline between usage and the first heading if there is no description. z Usage: {}  )r3 indent_linestextwrapdedent)rr:msgrrr format_usage>sz PrettyHelpFormatter.format_usage) descriptionrcCsZ|rRt|jdrd}nd}|d}|}|t|d}|d|d}|SdSdS)NmainCommands Description r;r8r))hasattrparserlstriprstripr<r=r>)rrAlabelrrrformat_descriptionFs  z&PrettyHelpFormatter.format_description)epilogrcCs|r|SdSdS)Nr)r)rrLrrr format_epilogXsz!PrettyHelpFormatter.format_epilog)textindentrcs"fdd|dD}d|S)Ncsg|] }|qSrr).0linerOrr `z4PrettyHelpFormatter.indent_lines..rE)splitr4)rrNrO new_linesrrRrr<_sz PrettyHelpFormatter.indent_lines)r%r&)__name__ __module__ __qualname____doc__rroptparseOptionstrr$r#r9r@rKrMr< __classcell__rrrrr s r cs*eZdZdZejedfdd ZZS)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. Also redact auth from url type options r csd}|jdurLt|jtsJ|j|jj|jdustd|q$|dd\}}||vr$||||fq$|D] }||D]\}}||fVqzqndS)Nglobalz:env:cSsi|] }|gqSrr)rPr}rrr szGConfigOptionParser._get_ordered_configuration_items..z7Ignoring configuration key '%s' as it's value is empty..r)r}r~itemsloggerdebugrUr+)roverride_order section_items section_keyrksectionrrrr _get_ordered_configuration_itemss" z3ConfigOptionParser._get_ordered_configuration_items)rdrc stj_t}D]\}ddur>qjdusLJjdvrz t |}Wn$t y d |Yn0nDjdkr"t t t |}Wdn1s0Yt t t|}Wdn1s0Yt|tr|dkrЈ d |njdkrN|}fd d |D}njd krˆjdusjJ|j}||}jpd }jpi}j||g|Ri|n|}||j<q|D]tj|<qd_|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_falsezm{} is not a valid value for {} option, please specify a boolean value like yes/no, true/false or 1/0 instead.countrz{} is not a valid value for {} option, please instead specify either a non-negative integer or a boolean value like yes/no or false/true which is equivalent to 1/0.r+csg|]}|qSr)r)rPvrr!rrrrSrTz7ConfigOptionParser._update_defaults..callbackr)r[Valuesrdvaluessetr get_optionr0actionr ValueErrorerrorr3rryrarUraddget_opt_string convert_value callback_argscallback_kwargsrgetattr)rrd late_evalrkopt_strrrrrrrcsX     & &        z#ConfigOptionParser._update_defaultsc Cs|jst|jSz|jWn4tyT}z|tt |WYd}~n d}~00| |j }| D]B}|j dusJ||j }t|t rn|}|||||j <qnt|S)zOverriding to make updating the defaults after instantiation of the option parser possible, _update_defaults() does the dirty work.N)process_default_valuesr[rrdr~loadr rrr]rccopy_get_all_optionsr0rerarr)rerrrdr!defaultrrrrget_default_values s &   z%ConfigOptionParser.get_default_values)r?rcCs"|tj|t|ddS)NrE) print_usagerstderrrr)rr?rrrr"s zConfigOptionParser.error)rWrXrYrZrr]boolrr[r\rrrrrrcrrrr^rrrrrbs  @rb)rZloggingr[rrr= contextlibrtypingrrrrrpip._internal.cli.status_codesrpip._internal.configurationr r pip._internal.utils.miscr r getLoggerrWrIndentedHelpFormatterr r_ OptionParserrlrbrrrrs   R