zmc
2023-08-08 e792e9a60d958b93aef96050644f369feb25d61b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
U
H=®d%ã@sÊdZddlmZddlZddlZddlZddlZddlmZddl    m
Z
ddl m Z ddl mZmZddlmZe e¡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úOD:\z\workplace\VsCode\pyvenv\venv\Lib\site-packages\pip/_internal/cli/parser.pyrszPrettyHelpFormatter.__init__cCs
| |¡S©N)Ú_format_option_strings©rÚoptionrrrÚformat_option_strings!sz)PrettyHelpFormatter.format_option_stringsú <{}>ú, cCs~g}|jr| |jd¡|jr0| |jd¡t|ƒdkrH| d|¡| ¡rt|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_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_headingcCsd | t |¡d¡¡}|S)zz
        Ensure there is only one newline between usage and the first heading
        if there is no description.
        z
Usage: {}
ú  )r)Ú indent_linesÚtextwrapÚdedent)rÚusageÚmsgrrrÚ format_usage@sÿz PrettyHelpFormatter.format_usagecCsV|rNt|jdƒrd}nd}| d¡}| ¡}| t |¡d¡}d ||¡}|SdSdS)NÚmainÚCommandsÚ DescriptionÚ
r1z{}:
{}
r)ÚhasattrÚparserÚlstripÚrstripr2r3r4r))rÚ descriptionÚlabelrrrÚformat_descriptionIs 
 z&PrettyHelpFormatter.format_descriptioncCs|r|SdSdS)Nrr)rÚepilogrrrÚ format_epilog[sz!PrettyHelpFormatter.format_epilogcs"‡fdd„| d¡Dƒ}d |¡S)Ncsg|] }ˆ|‘qSrr)Ú.0Úline©ÚindentrrÚ
<listcomp>csz4PrettyHelpFormatter.indent_lines.<locals>.<listcomp>r;)Úsplitr*)rÚtextrHÚ    new_linesrrGrr2bsz PrettyHelpFormatter.indent_linesN)rr) Ú__name__Ú
__module__Ú __qualname__Ú__doc__rrrr0r7rBrDr2rrrrr    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|j |jj¡tj ||¡Sr)r=Ú_update_defaultsÚdefaultsrrÚexpand_defaultrrrrrTns
z,UpdatingDefaultsHelpFormatter.expand_defaultN)rMrNrOrPrTrrrrrQgsrQc@s eZdZdd„Zedd„ƒZdS)ÚCustomOptionParsercOs(|j||Ž}|j ¡|j ||¡|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…}|jD]}| |j¡q|S)z<Get a list of all options, including those in option groups.N)Ú option_listrWÚextend)rÚresÚirrrÚoption_list_alls
z"CustomOptionParser.option_list_allN)rMrNrOr[Úpropertyr`rrrrrUts    rUc@s@eZdZdZdd„Zdd„Zdd„Zdd    „Zd
d „Zd d „Z    dS)ÚConfigOptionParserzsCustom option parser which updates its defaults by checking the
    configuration files and environmental variablescOsD| d¡|_| dd¡}t|ƒ|_|js,t‚tjj|f|ž|ŽdS)NÚnameÚisolatedF)rXrcrÚconfigÚAssertionErrorrÚ OptionParserr)rrrrdrrrrs
 
 
zConfigOptionParser.__init__c
CsPz| ||¡WStjk
rJ}ztd |¡ƒt d¡W5d}~XYnXdS)Nz*An error occurred during configuration: {}é)Ú check_valuerÚOptionValueErrorÚprintr)ÚsysÚexit)rrÚkeyÚvalÚexcrrrÚ check_default–s
z ConfigOptionParser.check_defaultccs”d|jdg}dd„|Dƒ}|j ¡D]D\}}|s>t d|¡q$| dd¡\}}||kr$|| ||f¡q$|D] }||D]\}}||fVqzqndS)NÚglobalz:env:cSsi|]
}|g“qSrr)rErcrrrÚ
<dictcomp>¢szGConfigOptionParser._get_ordered_configuration_items.<locals>.<dictcomp>z7Ignoring configuration key '%s' as it's value is empty.Ú.r )rcreÚitemsÚloggerÚdebugrJr!)rÚoverride_orderÚ section_itemsÚ section_keyroÚsectionrnrrrÚ _get_ordered_configuration_itemss þz3ConfigOptionParser._get_ordered_configuration_itemsc    sHt ˆj¡ˆ_tƒ}ˆ ¡D]\‰}ˆ dˆ¡‰ˆdkr>qˆjdkr„z t|ƒ}Wn,t    k
r€t
ˆjˆ|ƒ}ˆ  |¡YnXn’ˆjdkr®|  ¡}‡‡‡fdd„|Dƒ}nhˆjdkr|  ˆj¡ˆ ¡}ˆ ||¡}ˆjpâd}ˆjpìi}ˆjˆ||ˆf|ž|Žnˆ ˆˆ|¡}||ˆj<q|D]‰tˆjˆƒ|ˆ<q&dˆ_|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Úcountr!csg|]}ˆ ˆˆ|¡‘qSr)rq)rEÚv©rnrrrrrIÓsz7ConfigOptionParser._update_defaults.<locals>.<listcomp>Úcallbackr)rÚValuesrSÚvaluesÚsetr|Ú
get_optionÚactionrÚ
ValueErrorÚinvalid_config_error_messageÚerrorrJÚaddr'Úget_opt_stringÚ convert_valueÚ callback_argsÚcallback_kwargsr‚rqÚgetattr)rrSÚ    late_evalroÚ    error_msgÚopt_strrrrrrrRµs@
 ÿ
 
 
 z#ConfigOptionParser._update_defaultsc
Cs¬|jst |j¡Sz|j ¡Wn2tk
rR}z| tt    |ƒ¡W5d}~XYnX| 
|j  ¡¡}|  ¡D]4}|  |j¡}t|tƒrl| ¡}| ||¡||j<qlt |¡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ƒrSreÚloadrrmrÚstrrRÚcopyÚ_get_all_optionsÚgetr'Ú
isinstancerrŒri)rÚerrrSrÚdefaultr“rrrÚget_default_valuesæs "  
z%ConfigOptionParser.get_default_valuescCs"| tj¡| td |¡¡dS)Nz{}
)Ú print_usagerlÚstderrrmrr))rr6rrrrŠûs zConfigOptionParser.errorN)
rMrNrOrPrrqr|rRrrŠrrrrrb‰s    1rbcCs |dkrd ||¡Sd ||¡S)zQReturns a better error message when invalid configuration option
    is provided.)r}r~zo{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.)r))r‡rnrorrrr‰sþþr‰)rPÚ
__future__rÚloggingrrlr3Údistutils.utilrZpip._vendor.sixrÚpip._internal.cli.status_codesrÚpip._internal.configurationrrÚpip._internal.utils.compatrÚ    getLoggerrMrvrr    rQrgrUrbr‰rrrrÚ<module>s      
P w