idA**dZddlZddlZddlZddlZddlZddlmZddlm Z m Z m Z m Z m Z ddlmZddlmZmZddlmZmZejeZGdd ejZGd d eZGd d ejZGddeZdS)zBase option parser setupN)suppress)AnyDict GeneratorListTuple) UNKNOWN_ERROR) ConfigurationConfigurationError)redact_auth_from_url strtoboolc eZdZdZdededdffd ZdejdefdZ ddejd ed edefd Z dedefdZ dedefdZ dedefdZ dedefdZdededefdZxZS)PrettyHelpFormatterz4A prettier/less verbose help formatter for optparse.argskwargsreturnNcd|d<d|d<tjddz |d<tj|i|dS)Nmax_help_positionindent_incrementrwidth)shutilget_terminal_sizesuper__init__)selfrr __class__s M/opt/cloudlinux/venv/lib/python3.11/site-packages/pip/_internal/cli/parser.pyrzPrettyHelpFormatter.__init__sW&("#%&!" 244Q7!;w$)&)))))optionc,||SN)_format_option_strings)rr"s r format_option_stringsz)PrettyHelpFormatter.format_option_stringss**6222r! <{}>, mvarfmtoptsepcg}|jr ||jd|jr ||jdt|dkr|d||rZ|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)rr"r)r*optsr3s r r%z*PrettyHelpFormatter._format_option_stringss   / KK*1- . . .   . KK)!, - - - t99q== KK6 " " "      9n; (9(9(;(;G KKw}}77 8 8 8wwt}}r!headingc|dkrdS|dzS)NOptionsr,: )rr9s r format_headingz"PrettyHelpFormatter.format_heading9s i  2r!usagec|d|tj|d}|S)zz Ensure there is only one newline between usage and the first heading if there is no description. z Usage: {}  )r6 indent_linestextwrapdedent)rr?msgs r format_usagez PrettyHelpFormatter.format_usage>s6 $$T%6%6xu7M7Mt%T%TUU r! descriptionc|rut|jdrd}nd}|d}|}|t j|d}|d|d}|SdS)NmainCommands Description rAr<r,)hasattrparserlstriprstriprBrCrD)rrGlabels r format_descriptionz&PrettyHelpFormatter.format_descriptionFs  t{F++ &"%%,,T22K%,,..K++HOK,H,H$OOK"66{666K 2r!epilogc|r|SdS)Nr,r=)rrSs r format_epilogz!PrettyHelpFormatter.format_epilogXs  M2r!textindentcpfd|dD}d|S)Ncg|]}|zSr=r=).0linerWs r z4PrettyHelpFormatter.indent_lines..`s@@@tVd]@@@r!rL)splitr7)rrVrW new_liness ` r rBz PrettyHelpFormatter.indent_lines_s:@@@@tzz$/?/?@@@ yy###r!)r'r()__name__ __module__ __qualname____doc__rroptparseOptionstrr&r%r>rFrRrUrB __classcell__rs@r rrso>>*c*S*T******3HO33333NRo03GJ 4cc ##cc$CC$$c$c$$$$$$$$r!rc6eZdZdZdejdeffd ZxZS)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"rcd}|jH|j|jj|jj|j}t |}|rb|jdkrWt|tr|g}t|tsg}|D]%}| |t|}&|S)NURL) rN_update_defaultsdefaultsgetr4rexpand_defaultr3 isinstancerelistreplacer )rr"default_values help_textvalrs r roz,UpdatingDefaultsHelpFormatter.expand_defaultms ; " K ( ()= > > >![155fkBBNGG**622  Nfn55.#.. 2"0!1nd33 $!#% N N%--c3G3L3LMM r!) r_r`rarbrcrdrerorfrgs@r riridsWX_r!ricbeZdZdedededejfdZede ej fdZ dS)CustomOptionParseridxrrrc|j|i|}|j|j|||S)z*Insert an OptionGroup at a given position.)add_option_group option_groupspopr1)rrxrrgroups r insert_option_groupz&CustomOptionParser.insert_option_groupsN&%t6v66     !!#u--- r!cl|jdd}|jD]}||j|S)zzGConfigOptionParser._get_ordered_configuration_items..s'; ; ; D"; ; ; r!z7Ignoring configuration key '%s' as it's value is empty..r)rritemsloggerdebugr]r.)roverride_order section_items section_keyrusectionrs r _get_ordered_configuration_itemsz3ConfigOptionParser._get_ordered_configuration_itemss #DIw7; ; !/; ; ; !% 1 1 3 3 : : K  M&,,S!44LGS.((g&--sCj999&  G)'2  S3h   r!rmctjj_t }D]\}dz!jdvrL t|}n#t$r- d |YnwxYwjdkrtt5t|}dddn #1swxYwYtt5t|}dddn #1swxYwYt|tr|dkr) d |njdkr%|}fd |D}njd krk|j}||}jpd }jpi}j||g|Ri|n|}||j<|D]t1j|<d_|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.c>g|]}|Sr=)r)rZvrr"rs r r\z7ConfigOptionParser._update_defaults..s+GGGat))&#q99GGGr!callbackr=)rcValuesrmvaluessetr get_optionactionr ValueErrorerrorr6rrrpr]addr4get_opt_string convert_value callback_argscallback_kwargsrrgetattr) rrm late_evalruopt_strrrrr"s ` @@r rlz#ConfigOptionParser._update_defaultss% odm44 EE ==??0 (0 (HC__TCZ00F ~} ===#C..CC!JJ55;VC5E5E '))j))))#C..C)))))))))))))))j))##c((C###############!#s++sQwwJJ67=fS#6F6F  (**iikkGGGGGG3GGG*,, fk*** //11**7C88+1r/52dLTLLLVLLLL((c::$'HV[ ! ! 6 6C#DK55HSMM s6/B3B76B7C55C9 <C9 D00D4 7D4 cf|jstj|jS |jn?#t $r2}|tt|Yd}~nd}~wwxYw| |j }| D]c}| |j}t|tr2|}|||||j<dtj|S)zOverriding to make updating the defaults after instantiation of the option parser possible, _update_defaults() does the dirty work.N)process_default_valuesrcrrmrloadr rr rerlcopy_get_all_optionsrnr4rprr)rerrrmr"defaultrs r get_default_valuesz%ConfigOptionParser.get_default_valuess)* 2?4=11 1 / K      ! / / / IImSXX . . . . . . . . /((););)=)=>>++-- M MFll6;//G'3'' M //11(.(:(:7G(L(L%x(((s< A8(A33A8rEc|tj|t|ddS)NrL) print_usagerstderrrr )rrEs r rzConfigOptionParser.error$s8 $$$ -C,,,,,r!)r_r`rarbrreboolrrcrdrrrrrrlrrrrfrgs@r rrsZ77 * * * * * *  *  * * * * * *HO#CC 5c?D$. /8>c3h>DcN>>>>@)HO)))),----------r!r)rbloggingrcrrrC contextlibrtypingrrrrrpip._internal.cli.status_codesr pip._internal.configurationr r pip._internal.utils.miscr r getLoggerr_rIndentedHelpFormatterrri OptionParserrwrr=r!r rs 44444444444444888888IIIIIIIIDDDDDDDD  8 $ $O$O$O$O$O$(8O$O$O$d$7@.,L-L-L-L-L-+L-L-L-L-L-r!