oMi*4dZddlmZddlZddlZddlZddlZddlZddlm Z ddl m Z ddl m Z mZddlmZddlmZmZdd lmZmZej.eZGd d ej4ZGd d eZGddej:ZGddeZy)zBase option parser setup) annotationsN) Generator)suppress)AnyNoReturn) UNKNOWN_ERROR) ConfigurationConfigurationError)redact_auth_from_url strtoboolcneZdZdZd fd Zd dZ d d dZddZddZddZ ddZ dd Z xZ S)PrettyHelpFormatterz4A prettier/less verbose help formatter for optparse.crd|d<d|d<tjddz |d<t| |i|y)Nmax_help_positionindent_incrementrwidth)shutilget_terminal_sizesuper__init__)selfargskwargs __class__s c/mnt/ssd/data/python-lab/ObsidianTool/venv/lib/python3.12/site-packages/pip/_internal/cli/parser.pyrzPrettyHelpFormatter.__init__sG&("#%&!" 224Q7!;w $)&)c$|j|SN)_format_option_strings)roptions rformat_option_stringsz)PrettyHelpFormatter.format_option_stringss**622rcg}|jr|j|jd|jr|j|jdt|dkDr|j d||j rd|j J|jxs|j j}|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_valuedestmetavarlowerformatjoin)rr#mvarfmtoptsepoptsr.s rr"z*PrettyHelpFormatter._format_option_strings"s    KK**1- .    KK))!, - t9q= KK6 "    ;;* **nn; (9(9(;G KKw}}7 8wwt}rc|dk(ry|dzS)NOptionsr&: )rheadings rformat_headingz"PrettyHelpFormatter.format_heading<s i rcndj|jtj|d}|S)zz Ensure there is only one newline between usage and the first heading if there is no description. z Usage: {}  )r0 indent_linestextwrapdedent)rusagemsgs r format_usagez PrettyHelpFormatter.format_usageAs/ $$T%6%6xu7Mt%TU rc|rkt|jdrd}nd}|jd}|j}|j t j |d}|d|d}|Sy)NmainCommands Description r<r7r&)hasattrparserlstriprstripr=r>r?)r descriptionlabels rformat_descriptionz&PrettyHelpFormatter.format_descriptionIsq t{{F+"%%,,T2K%,,.K++HOOK,H$OK"G3{m26K rc |r|Sy)Nr&r8)repilogs r format_epilogz!PrettyHelpFormatter.format_epilog[s Mrcp|jdDcgc]}||z }}dj|Scc}wNrG)splitr1)rtextindentline new_liness rr=z PrettyHelpFormatter.indent_linesbs7/3zz$/?@tVd]@ @yy##As 3)rrrrreturnNoner#optparse.OptionrYstr)z <{}>z, )r#r\r2r]r3r]rYr])r9r]rYr])r@r]rYr])rL str | NonerYr])rPr^rYr])rUr]rVr]rYr]) __name__ __module__ __qualname____doc__rr$r"r:rBrNrQr= __classcell__rs@rrrsU>*3NR%03GJ 4 $$rrc$eZdZdZdfd 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 cd}|jt|jtsJ|jj|jj|j J|jjj |j }t|!|}|rV|jdk(rGt|tr|g}t|tsg}|D]}|j|t|}|S)NURL)rI isinstanceConfigOptionParser_update_defaultsdefaultsr-getrexpand_defaultr.r]listreplacer )rr#default_values help_textvalrs rrnz,UpdatingDefaultsHelpFormatter.expand_defaultps ;; "dkk+=> >> KK ( ()=)= >;;* **![[1155fkkBNG*62 fnn5.#."0!1nd3!#% N%--c3G3LM  Nrr[)r_r`rarbrnrcrds@rrfrfgsrrfc6eZdZ ddZeddZy)CustomOptionParserc|j|i|}|jj|jj|||S)z*Insert an OptionGroup at a given position.)add_option_group option_groupspopr+)ridxrrgroups rinsert_option_groupz&CustomOptionParser.insert_option_groupsH&%%t6v6   !!#u- rc||jdd}|jD]}|j|j|S)zHAu$)KKM > SLLP#*00a8 n,!'*113*= > >& .G$W- - - .'; ( .s"C B:A*C 'C2B?3 Cc tj|j|_t }|j D]\}}|j d|z}||jJ|jdvr t|}ni|jdk(rstt5t|}dddtt5t|}dddt|tr|dkr|j|d|dn|jd k(r1|j}|Dcgc]}|j!|||}}n|jd k(r|j"J|j%|j|j'}|j)||}|j*xsd }|j,xsi} |j"||||g|i| n|j!|||}|||j<|D]}t/|j|||<d|_|S#t$r|j|d|dY]wxYw#1swYxYw#1swYxYwcc}w) 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_falsez is not a valid value for zO option, please specify a boolean value like yes/no, true/false or 1/0 instead.countrz 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(callbackr8)rValuesrlvaluessetr get_optionr-actionr ValueErrorerrorrrrirTrraddget_opt_string convert_value callback_argscallback_kwargsgetattr) rrl late_evalrrsr#vopt_strrrs rrkz#ConfigOptionParser._update_defaultssa oodmm4 E ==?0 (HC__TCZ0F ~;;* **}} ==#C.C')j))#C.C)j)#c(C#!#s+sQwJJ%9#?66 (*iikCFGat))&#q9GG*,222 fkk* //1**7C8++1r//52dLTLVL((c:$'HV[[ !a0 (d 6C#DKK5HSM 6 M"JJ%9#?55))##Hs0: H+% I I,I++ I II I( cp|jstj|jS |jj |j|jj}|jD]k}|jJ|j|j}t|ts=|j!}|j#||||j<mtj|S#t $r)}|jtt|Yd}~d}~wwxYw)zOverriding to make updating the defaults after instantiation of the option parser possible, _update_defaults() does the dirty work.N)process_default_valuesrrrlrloadr rrr]rkcopy_get_all_optionsr-rmrirr)rerrrlr#defaultrs rget_default_valuesz%ConfigOptionParser.get_default_valuess**??4==1 1 / KK   ((););)=>++- MF;;* **ll6;;/G'3' //1(.(:(:7G(L%  M x((" / IImSX . . /sD D5 D00D5ct|jtj|jt|dyrS) print_usagerstderrrr)rrAs rrzConfigOptionParser.error(s( $ -C5,r) rrrr]rboolrrrYrZ)r#r\rr]rsrrYr)rYz&Generator[tuple[str, Any], None, None])rldict[str, Any]rYr)rYzoptparse.Values)rAr]rYr) r_r`rarbrrrrkrrrcrds@rrjrjsd7 * * * *  *  *. /.:>@),-rrj) rb __future__rloggingrrrr>collections.abcr contextlibrtypingrrpip._internal.cli.status_codesrpip._internal.configurationr r pip._internal.utils.miscr r getLoggerr_rIndentedHelpFormatterrrf OptionParserrurjr8rrrs" % 8ID   8 $O$(88O$d$7@..,M-+M-r