ronnie
2022-10-14 1504bb53e29d3d46222c0b3ea994fc494b48e153
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
[\¬Qc@sýdZdZddlZddlZddlZddlZddlmZmZdZ    ej
de    ƒZ ej
de    e    fƒZ ej dd    ƒZd
fd „ƒYZd „Zej ejd eejƒƒZd„Zd„Zdfd„ƒYZdS(s6distutils.fancy_getopt
 
Wrapper around the standard getopt module that provides the following
additional features:
  * short and long options are tied together
  * options have help strings, so fancy_getopt could potentially
    create a complete usage summary
  * options set attributes of a passed-in object
s$Id$iÿÿÿÿN(tDistutilsGetoptErrortDistutilsArgErrors[a-zA-Z](?:[a-zA-Z0-9-]*)s^%s$s ^(%s)=!(%s)$t-t_t FancyGetoptcBs¤eZdZdd„Zd„Zd„Zddd„Zd„Zd„Z    d„Z
d„Z d    „Z d
„Z ddd „Zd „Zdd „Zddd„ZRS(sÕWrapper around the standard 'getopt()' module that provides some
    handy extra functionality:
      * short and long options are tied together
      * options have help strings, and help text can be assembled
        from them
      * options set attributes of a passed-in object
      * boolean options can have "negative aliases" -- eg. if
        --quiet is the "negative alias" of --verbose, then "--quiet"
        on the command line sets 'verbose' to false
    cCst||_i|_|jr(|jƒni|_i|_g|_g|_i|_i|_i|_    g|_
dS(N( t option_tablet option_indext _build_indextaliastnegative_aliast
short_optst    long_optst
short2longt    attr_namet    takes_argt option_order(tselfR((s^/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/distutils/fancy_getopt.pyt__init__-s
                                        cCs6|jjƒx"|jD]}||j|d<qWdS(Ni(RtclearR(Rtoption((s^/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/distutils/fancy_getopt.pyRYs cCs||_|jƒdS(N(RR(RR((s^/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/distutils/fancy_getopt.pytset_option_table^s    cCsO||jkrtd|‚n,|||f}|jj|ƒ||j|<dS(Ns'option conflict: already an option '%s'(RRRtappend(Rt long_optiont short_optiont help_stringR((s^/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/distutils/fancy_getopt.pyt
add_optionbs  cCs ||jkS(scReturn true if the option table for this parser has an
        option with long name 'long_option'.(R(RR((s^/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/distutils/fancy_getopt.pyt
has_optionlscCstj|tƒS(s’Translate long option name 'long_option' to the form it
        has as an attribute of some object: ie., translate hyphens
        to underscores.(tstringt    translatet longopt_xlate(RR((s^/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/distutils/fancy_getopt.pyt get_attr_nameqscCsqxj|jƒD]\\}}||jkrAtd|||f‚n||jkr td|||f‚q q WdS(Ns(invalid %s '%s': option '%s' not defineds0invalid %s '%s': aliased option '%s' not defined(titemsRR(RtaliasestwhatRtopt((s^/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/distutils/fancy_getopt.pyt_check_alias_dictxscCs|j|dƒ||_dS(s'Set the aliases for this option parser.RN(R#R(RR((s^/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/distutils/fancy_getopt.pyt set_aliases„scCs|j|dƒ||_dS(sÚSet the negative aliases for this option parser.
        'negative_alias' should be a dictionary mapping option names to
        option names, both the key and value must already be defined
        in the option table.snegative aliasN(R#R    (RR    ((s^/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/distutils/fancy_getopt.pytset_negative_aliases‰scCsŒg|_g|_|jjƒi|_x]|jD]R}t|ƒdkrb|\}}}d}n7t|ƒdkr‰|\}}}}ntd|f‚t|t    ƒ s»t|ƒdkrËt
d|‚n|dkpõt|t    ƒoõt|ƒdkst
d|‚n||j|<|jj |ƒ|d    d
kre|rH|d }n|dd    !}d|j |<nk|jj|ƒ}|dk    rÃ|j |r¦t
d ||f‚n||jd    <d|j |<n d|j |<|jj|ƒ}|dk    r!|j ||j |kr!t
d ||f‚q!ntj|ƒsDt
dd|‚n|j|ƒ|j|<|r2|jj |ƒ||j|d<q2q2WdS(sPopulate the various data structures that keep tabs on the
        option table.  Called by 'getopt()' before it can do anything
        worthwhile.
        iiisinvalid option tuple: %ris9invalid long option '%s': must be a string of length >= 2is:invalid short option '%s': must a single character or Noneiÿÿÿÿt=t:s>invalid negative alias '%s': aliased option '%s' takes a valuesginvalid alias '%s': inconsistent with aliased option '%s' (one of them takes a value, the other doesn'tsinvalid long option name '%s' s'(must be letters, numbers, hyphens onlyN(R R
R RtrepeatRtlent
ValueErrort
isinstancetstrRtNoneRRR    tgetRt
longopt_retmatchRR (RRtlongtshortthelpR(talias_to((s^/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/distutils/fancy_getopt.pyt_grok_option_table’sd                 "
 !
        c Cs×|dkrtjd}n|dkr:tƒ}d}nd}|jƒtj|jƒ}y"tj|||j    ƒ\}}Wntj
k
rŸ}t |‚nXx|D]\}}t |ƒdkré|ddkré|j |d}n
|d}|jj|ƒ}    |    r|    }n|j|sQ|jj|ƒ}    |    rH|    }d}qQd}n|j|}
|r•|jj|
ƒdk    r•t||
dƒd}nt||
|ƒ|jj||fƒq§W|rÏ||fS|SdS(sParse command-line options in args. Store as attributes on object.
 
        If 'args' is None or not supplied, uses 'sys.argv[1:]'.  If
        'object' is None or not supplied, creates a new OptionDummy
        object, stores option values there, and returns a tuple (args,
        object).  If 'object' is supplied, it is modified in place and
        'getopt()' just returns 'args'; in both cases, the returned
        'args' is a modified copy of the passed-in 'args' list, which
        is left untouched.
        iiiRN(R-tsystargvt OptionDummyR5RtjoinR
tgetoptR terrorRR)R RR.RR    R R(tgetattrtsetattrRR( Rtargstobjecttcreated_objectR
toptstmsgR"tvalRtattr((s^/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/distutils/fancy_getopt.pyR:êsB          
" "
              
cCs&|jdkrtd‚n|jSdS(s«Returns the list of (option, value) tuples processed by the
        previous run of 'getopt()'.  Raises RuntimeError if
        'getopt()' hasn't been called yet.
        s!'getopt()' hasn't been called yetN(RR-t RuntimeError(R((s^/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/distutils/fancy_getopt.pytget_option_order*s cCsád}x||jD]q}|d}|d}t|ƒ}|ddkrS|d}n|dk    rl|d}n||kr|}qqW|ddd}d}||}    d|}
|rÃ|g} n    d    g} x|jD]}|d
 \}}} t| |    ƒ} |ddkr|dd!}n|dkrk| rQ| jd ||| dfƒq³| jd ||fƒnHd ||f}| r¢| jd ||| dfƒn| jd|ƒx#| dD]}| j|
|ƒq¾WqÖW| S(sŒGenerate help text (a list of strings, one per suggested line of
        output) from the option table for this FancyGetopt object.
        iiiÿÿÿÿR&iiiNt sOption summary:is   --%-*s  %ss
  --%-*s  s%s (-%s)s  --%-*sN(RR)R-t    wrap_textR(Rtheadertmax_optRR1R2tlt    opt_widtht
line_widtht
text_widtht
big_indenttlinesR3ttextt    opt_names((s^/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/distutils/fancy_getopt.pyt generate_help5sF
 
 
 
      !    cCsG|dkrtj}nx(|j|ƒD]}|j|dƒq(WdS(Ns
(R-R6tstdoutRStwrite(RRItfiletline((s^/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/distutils/fancy_getopt.pyt
print_help‰s  N(t__name__t
__module__t__doc__R-RRRRRRR#R$R%R5R:RFRSRX(((s^/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/distutils/fancy_getopt.pyR!s
 ,        
                           X@     TcCs)t|ƒ}|j|ƒ|j||ƒS(N(RR%R:(toptionst negative_optR?R>tparser((s^/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/distutils/fancy_getopt.pyt fancy_getopt’s  RGcCs~|dkrgSt|ƒ|kr)|gStj|ƒ}tj|tƒ}tjd|ƒ}td|ƒ}g}x|ryg}d}xt|rüt|dƒ}|||krÔ|j    |dƒ|d=||}q‰|rø|dddkrø|d=nPq‰W|r]|dkr<|j    |dd|!ƒ|d||d<n|dddkr]|d=q]n|j    tj
|dƒƒqtW|S(s¶wrap_text(text : string, width : int) -> [string]
 
    Split 'text' into multiple lines of no more than 'width' characters
    each, and return the list of strings that results.
    s( +|-+)iiÿÿÿÿRGtN( R-R)Rt
expandtabsRtWS_TRANStretsplittfilterRR9(RQtwidthtchunksRPtcur_linetcur_lenRK((s^/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/distutils/fancy_getopt.pyRHšs:          
  cCstj|tƒS(sXConvert a long option name to a valid Python identifier by
    changing "-" to "_".
    (RRR(R"((s^/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/distutils/fancy_getopt.pyttranslate_longoptÕsR8cBseZdZgd„ZRS(s_Dummy class just used as a place to hold command-line option
    values as instance attributes.cCs%x|D]}t||dƒqWdS(skCreate a new OptionDummy instance.  The attributes listed in
        'options' will be initialized to None.N(R=R-(RR\R"((s^/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/distutils/fancy_getopt.pyRàs (RYRZR[R(((s^/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/distutils/fancy_getopt.pyR8Üs(R[t __revision__R6RRcR:tdistutils.errorsRRt longopt_pattcompileR/t neg_alias_ret    maketransRRR_t
whitespaceR)RbRHRjR8(((s^/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/distutils/fancy_getopt.pyt<module>    s"    ÿr    "    ;