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
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
U
ß=®dLã @s|UddlZddlZddlZddlmZddlmZddlm    Z    ddlm
Z
ddlm Z ddlm Z dd    lm Z dd
lmZdd lmZdd lmZejrªddlZe d ¡Ze d¡Ze d¡ZejdejfZejegefZded<ejdej ee
fdZ!dddœdd„Z"dddœdd„Z#dKej$ee%ejdgdfdœd d!„Z&dd"œe'ej(e'd#d$œd%d&„Z)ejd'e
dZ*ej+ee
d(œd)d*„ƒZ,ej+ej(e'ej$e*ejejege*fd+œd,d*„ƒZ,ej+dLdej$e*ejejege*fd+œd-d*„ƒZ,ej+dMej(e'dejejege
fd+œd.d*„ƒZ,dNej ej(e'efej(ej$e*ejej e
ejegej e
e*fffd+œd/d*„Z,ejd0e dZ-ej+ee d(œd1d2„ƒZ.ej+ej(e'ej$e-ejejege-fd+œd3d2„ƒZ.ej+dOdej$e-ejejege-fd+œd4d2„ƒZ.ej+dPej(e'dejejege fd+œd5d2„ƒZ.dQej e'edfej(ej$e-ejej e ejegej e e-fffd+œd6d2„Z.ejdejfedd7œd8d9„Z/dd:œe'ej(ej$e    ejee!d;œd<d=„Z0dd:œe'ej(ej$e ejee!d;œd>d?„Z1e'ejee!d@œdAdB„Z2e'ejee!d@œdCdD„Z3dRddddEœej(e'e'ej(e'ej(e'ej(e'ejee!dFœdGdH„Z4e'ejee!d@œdIdJ„Z5dS)SéN©Úupdate_wrapper)Úgettexté)ÚArgument)ÚCommand)ÚContext)ÚGroup)ÚOption)Ú    Parameter©Úget_current_context)ÚechoÚPÚRÚT.z te.TypeAliasÚ
_DecoratorÚFC)Úboundz)t.Callable[te.Concatenate[Context, P], R]út.Callable[P, R]©ÚfÚreturncs ddddœ‡fdd„ }t|ˆƒS)z]Marks a callback as wanting to receive the current context
    object as first argument.
    úP.argsúP.kwargsr©ÚargsÚkwargsrcsˆtƒf|ž|ŽS©Nr ©rr©r©úGd:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\click/decorators.pyÚnew_func!szpass_context.<locals>.new_funcr©rr#r!r r"Ú pass_contextsr%ú't.Callable[te.Concatenate[t.Any, P], R]cs ddddœ‡fdd„ }t|ˆƒS)z¼Similar to :func:`pass_context`, but only pass the object on the
    context onwards (:attr:`Context.obj`).  This is useful if that object
    represents the state of a nested system.
    rrrrcsˆtƒjf|ž|ŽSr)r Úobjrr r!r"r#-szpass_obj.<locals>.new_funcrr$r!r r"Úpass_obj'sr(Fú#t.Callable[te.Concatenate[T, P], R])Ú object_typeÚensurercsdddœ‡‡fdd„ }|S)a.Given an object type this creates a decorator that will work
    similar to :func:`pass_obj` but instead of passing the object of the
    current context, it will find the innermost context of type
    :func:`object_type`.
 
    This generates a decorator that works roughly like this::
 
        from functools import update_wrapper
 
        def decorator(f):
            @pass_context
            def new_func(ctx, *args, **kwargs):
                obj = ctx.find_object(object_type)
                return ctx.invoke(f, obj, *args, **kwargs)
            return update_wrapper(new_func, f)
        return decorator
 
    :param object_type: the type of the object to pass.
    :param ensure: if set to `True`, a new object will be created and
                   remembered on the context if it's not there yet.
    r)rrcs$ddddœ‡‡‡fdd„ }t|ˆƒS)NrrrrcsNtƒ}ˆr| ˆ¡}n
| ˆ¡}|dkr:tdˆj›dƒ‚|jˆ|f|ž|ŽS)Nz<Managed to invoke callback without a context object of type z
 existing.)r Z ensure_objectZ find_objectÚ RuntimeErrorÚ__name__Úinvoke©rrÚctxr')r+rr*r!r"r#Ms 
 ÿz8make_pass_decorator.<locals>.decorator.<locals>.new_funcrr$©r+r*r r"Ú    decoratorLsz&make_pass_decorator.<locals>.decoratorr!)r*r+r2r!r1r"Úmake_pass_decorator3sr3)Údoc_descriptionzGt.Callable[[t.Callable[te.Concatenate[t.Any, P], R]], t.Callable[P, R]])Úkeyr4rcs:dddœ‡fdd„ }|dkr(dˆ›d}d    |›d
|_|S) a{Create a decorator that passes a key from
    :attr:`click.Context.meta` as the first argument to the decorated
    function.
 
    :param key: Key in ``Context.meta`` to pass.
    :param doc_description: Description of the object being passed,
        inserted into the decorator's docstring. Defaults to "the 'key'
        key from Context.meta".
 
    .. versionadded:: 8.0
    r&rrcs"ddtdœ‡‡fdd„ }t|ˆƒS)Nrrrcs$tƒ}|jˆ}|jˆ|f|ž|ŽSr)r Úmetar.r/)rr5r!r"r#ts
z2pass_meta_key.<locals>.decorator.<locals>.new_func)rrr$©r5r r"r2ssz pass_meta_key.<locals>.decoratorNzthe z$ key from :attr:`click.Context.meta`zDecorator that passes z1 as the first argument to the decorated function.)Ú__doc__)r5r4r2r!r7r"Ú pass_meta_keyds  
ÿr9ÚCmdType)ÚnamercCsdSrr!©r;r!r!r"Úcommand‰sr=)r;ÚclsÚattrsrcKsdSrr!©r;r>r?r!r!r"r=scKsdSrr!r@r!r!r"r=ŸscKsdSrr!r@r!r!r"r=©sc svd}tˆƒr0ˆ}d‰ˆdks$tdƒ‚ˆr0tdƒ‚ˆdkrJt tjtt¡‰ttdœ‡‡‡fdd„ }|dk    rr||ƒS|S)a±Creates a new :class:`Command` and uses the decorated function as
    callback.  This will also automatically attach all decorated
    :func:`option`\s and :func:`argument`\s as parameters to the command.
 
    The name of the command defaults to the name of the function with
    underscores replaced by dashes.  If you want to change that, you can
    pass the intended name as the first argument.
 
    All keyword arguments are forwarded to the underlying command class.
    For the ``params`` argument, any decorated params are appended to
    the end of the list.
 
    Once decorated the function turns into a :class:`Command` instance
    that can be invoked as a command line utility or be attached to a
    command :class:`Group`.
 
    :param name: the name of the command.  This defaults to the function
                 name with underscores replaced by dashes.
    :param cls: the command class to instantiate.  This defaults to
                :class:`Command`.
 
    .. versionchanged:: 8.1
        This decorator can be applied without parentheses.
 
    .. versionchanged:: 8.1
        The ``params`` argument can be used. Decorated params are
        appended to the end of the list.
    Nz4Use 'command(cls=cls)(callable)' to specify a class.z7Use 'command(**kwargs)(callable)' to provide arguments.rcsÊt|tƒrtdƒ‚ˆ dd¡}|dk    r*|ng}z
|j}Wntk
rLYnX|`| t|ƒ¡ˆ d¡dkrx|j    ˆd<t
j r–ˆdk    sŠt ‚t ˆƒr–t ‚ˆfˆp®|j ¡ dd¡||dœˆ—Ž}|j    |_    |S)Nz5Attempted to convert a callback into a command twice.ÚparamsÚhelpÚ_ú-)r;ÚcallbackrA)Ú
isinstancerÚ    TypeErrorÚpopÚ__click_params__ÚAttributeErrorÚextendÚreversedÚgetr8ÚtÚ TYPE_CHECKINGÚAssertionErrorÚcallabler-ÚlowerÚreplace)rZ attr_paramsrAZdecorator_paramsÚcmd©r?r>r;r!r"r2Ýs0
 
 
  ýüzcommand.<locals>.decorator)rQrPrNÚcastÚTyper:rÚ _AnyCallable)r;r>r?Úfuncr2r!rUr"r=°s" ÚGrpTypecCsdSrr!r<r!r!r"Úgroupsr[cKsdSrr!r@r!r!r"r[ scKsdSrr!r@r!r!r"r[scKsdSrr!r@r!r!r"r[&scKsF|dkrt tjtt¡}t|ƒr8tfd|i|—Ž|ƒSt||f|ŽS)aCreates a new :class:`Group` with a function as callback.  This
    works otherwise the same as :func:`command` just that the `cls`
    parameter is set to :class:`Group`.
 
    .. versionchanged:: 8.1
        This decorator can be applied without parentheses.
    Nr>)rNrVrWrZr    rQr=r@r!r!r"r[-s
)rÚparamrcCs8t|tƒr|j |¡nt|dƒs(g|_|j |¡dS)NrI)rFrrAÚappendÚhasattrrI)rr\r!r!r"Ú _param_memoBs
 
 
r_)r>)Ú param_declsr>r?rcs(ˆdkr t‰ttdœ‡‡‡fdd„ }|S)aØAttaches an argument to the command.  All positional arguments are
    passed as parameter declarations to :class:`Argument`; all keyword
    arguments are forwarded unchanged (except ``cls``).
    This is equivalent to creating an :class:`Argument` instance manually
    and attaching it to the :attr:`Command.params` list.
 
    For the default argument class, refer to :class:`Argument` and
    :class:`Parameter` for descriptions of parameters.
 
    :param cls: the argument class to instantiate.  This defaults to
                :class:`Argument`.
    :param param_decls: Passed as positional arguments to the constructor of
        ``cls``.
    :param attrs: Passed as keyword arguments to the constructor of ``cls``.
    Nrcst|ˆˆfˆŽƒ|Sr©r_r ©r?r>r`r!r"r2aszargument.<locals>.decorator)rr©r>r`r?r2r!rbr"ÚargumentLsrdcs(ˆdkr t‰ttdœ‡‡‡fdd„ }|S)aÊAttaches an option to the command.  All positional arguments are
    passed as parameter declarations to :class:`Option`; all keyword
    arguments are forwarded unchanged (except ``cls``).
    This is equivalent to creating an :class:`Option` instance manually
    and attaching it to the :attr:`Command.params` list.
 
    For the default option class, refer to :class:`Option` and
    :class:`Parameter` for descriptions of parameters.
 
    :param cls: the option class to instantiate.  This defaults to
                :class:`Option`.
    :param param_decls: Passed as positional arguments to the constructor of
        ``cls``.
    :param attrs: Passed as keyword arguments to the constructor of ``cls``.
    Nrcst|ˆˆfˆŽƒ|Srrar rbr!r"r2}szoption.<locals>.decorator)r
rrcr!rbr"Úoptionhsre)r`rrcOsbtttddœdd„}|sd}| dd¡| d|¡| d    d
¡| d d ¡| d d¡t||ŽS)a-Add a ``--yes`` option which shows a prompt before continuing if
    not passed. If the prompt is declined, the program will exit.
 
    :param param_decls: One or more option names. Defaults to the single
        value ``"--yes"``.
    :param kwargs: Extra arguments are passed to :func:`option`.
    N©r0r\ÚvaluercSs|s | ¡dSr)Úabort©r0r\rgr!r!r"rEsz%confirmation_option.<locals>.callback)z--yesÚis_flagTrEÚ expose_valueFÚpromptzDo you want to continue?rBz%Confirm the action without prompting.)rr ÚboolÚ
setdefaultre©r`rrEr!r!r"Úconfirmation_option„s         rpcOs6|sd}| dd¡| dd¡| dd¡t||ŽS)a0Add a ``--password`` option which prompts for a password, hiding
    input and asking to enter the value again for confirmation.
 
    :param param_decls: One or more option names. Defaults to the single
        value ``"--password"``.
    :param kwargs: Extra arguments are passed to :func:`option`.
    )z
--passwordrlTZconfirmation_promptZ
hide_input)rnre)r`rr!r!r"Úpassword_optionœs    rq)Ú package_nameÚ    prog_nameÚmessage)Úversionr`rrrsrtrrc
sðˆdkrtdƒ‰ˆdkr„ˆdkr„t ¡}|dk    r6|jnd}|dk    rH|jnd}~|dk    r„| d¡‰ˆdkrr| d¡‰ˆr„ˆ d¡d‰ttt    ddœ‡‡‡‡fd    d
„ }    |sªd }| 
d d ¡| 
dd¡| 
dd ¡| 
dtdƒ¡|    |d<t ||ŽS)aÃAdd a ``--version`` option which immediately prints the version
    number and exits the program.
 
    If ``version`` is not provided, Click will try to detect it using
    :func:`importlib.metadata.version` to get the version for the
    ``package_name``. On Python < 3.8, the ``importlib_metadata``
    backport must be installed.
 
    If ``package_name`` is not provided, Click will try to detect it by
    inspecting the stack frames. This will be used to detect the
    version, so it must match the name of the installed package.
 
    :param version: The version number to show. If not provided, Click
        will try to detect it.
    :param param_decls: One or more option names. Defaults to the single
        value ``"--version"``.
    :param package_name: The package name to detect the version from. If
        not provided, Click will try to detect it.
    :param prog_name: The name of the CLI to show in the message. If not
        provided, it will be detected from the command.
    :param message: The message to show. The values ``%(prog)s``,
        ``%(package)s``, and ``%(version)s`` are available. Defaults to
        ``"%(prog)s, version %(version)s"``.
    :param kwargs: Extra arguments are passed to :func:`option`.
    :raise RuntimeError: ``version`` could not be detected.
 
    .. versionchanged:: 8.0
        Add the ``package_name`` parameter, and the ``%(package)s``
        value for messages.
 
    .. versionchanged:: 8.0
        Use :mod:`importlib.metadata` instead of ``pkg_resources``. The
        version is detected based on the package name, not the entry
        point name. The Python package name must match the installed
        package name, or be passed with ``package_name=``.
    Nz%(prog)s, version %(version)sr-Ú__main__Ú __package__Ú.rrfcsÒ|r
|jrdSˆdkr | ¡j‰ˆdkr”ˆdk    r”zddlm}Wntk
r\ddl}YnXz| ˆ¡‰Wn&|jk
r’t    ˆ›dƒd‚YnXˆdkr¬t    dˆ›dƒ‚t
ˆˆˆˆdœ|j d|  ¡dS)Nr)Úmetadataz6 is not installed. Try passing 'package_name' instead.z$Could not determine the version for z automatically.)ÚprogÚpackageru©Úcolor) Úresilient_parsingZ    find_rootZ    info_nameÚ    importlibryÚ ImportErrorZimportlib_metadataruZPackageNotFoundErrorr,rr}Úexit)r0r\rgry©rtrrrsrur!r"rEís4
 
ÿý
ÿþz version_option.<locals>.callback)z    --versionrjTrkFÚis_eagerrBzShow the version and exit.rE) rCÚinspectÚ currentframeÚf_backÚ    f_globalsrMÚ    partitionrr rmrnre)
rurrrsrtr`rÚframer†r‡rEr!r‚r"Úversion_option­s,,
 
&   rŠcOsbtttddœdd„}|sd}| dd¡| dd    ¡| d
d¡| d td ƒ¡||d <t||ŽS)a›Add a ``--help`` option which immediately prints the help page
    and exits the program.
 
    This is usually unnecessary, as the ``--help`` option is added to
    each command automatically unless ``add_help_option=False`` is
    passed.
 
    :param param_decls: One or more option names. Defaults to the single
        value ``"--help"``.
    :param kwargs: Extra arguments are passed to :func:`option`.
    NrfcSs,|r
|jrdSt| ¡|jd| ¡dS)Nr|)r~rZget_helpr}rrir!r!r"rE+s
zhelp_option.<locals>.callback)z--helprjTrkFrƒrBzShow this message and exit.rE)rr rmrnrCreror!r!r"Ú help_options    r‹)F)N.).N)NN)N.).N)NN)N)6r„ÚtypesÚtypingrNÚ    functoolsrrrCÚcorerrrr    r
r Úglobalsr ÚutilsrrOZtyping_extensionsÚteZ    ParamSpecrÚTypeVarrrÚCallableÚAnyrXrÚ__annotations__ÚUnionrr%r(rWrmr3ÚstrÚOptionalr9r:Úoverloadr=rZr[r_rdrerprqrŠr‹r!r!r!r"Ú<module>s          
 
 
  ÿþ 2ÿþ !üþü    ÿþþ"ü Rüþü    ÿþþ"ü  ÿþ ÿþ ÿûù q