zmc
2023-12-22 9fdbf60165db0400c2e8e6be2dc6e88138ac719a
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
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
U
ß=®dJOã    @spddlZddlZddlZddlZddlmZddlmZddlm    Z    ddl
m Z ddl
m Z ddl
m Z dd    l
mZdd
l
mZdd l
mZdd l
mZdd l
mZddl
mZddl
mZddlmZejràddlZe d¡Ze d¡Zeedœdd„Zdddœdd„Z ej!edœdd„Z"dFee#edœd d!„Z$Gd"d#„d#ƒZ%Gd$d%„d%ƒZ&dGej'ej!ej'ej(ej!e)e)ej'e)dd(œd)d*„Z*d+ej+dœd,d-„Z,dHd+ej'eej'eej-d/œd0d1„Z.dIeeej'eej'ee)e)ej(ej!d3œd4d5„Z/dJd6e)ed7œd8d9„Z0dKee)e)ed:œd;d<„Z1Gd=d>„d>ƒZ2dLej'eej'eed?œd@dA„Z3d&d&d&dBœej4ee)e)e)ej5edCœdDdE„Z6dS)MéN)Úupdate_wrapper)Ú
ModuleType)Ú TracebackTypeé)Ú_default_text_stderr)Ú_default_text_stdout)Ú_find_binary_writer)Úauto_wrap_for_ansi)Úbinary_streams)Ú open_stream)Úshould_strip_ansi)Ú
strip_ansi)Ú text_streams)ÚWIN)Úresolve_color_defaultÚPÚR©ÚnameÚreturncCsd | ¡¡ ¡S)Nú-)ÚjoinÚsplitÚlower)r©rúBd:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\click/utils.pyÚ    _posixifysrzt.Callable[P, R]zt.Callable[P, t.Optional[R]])Úfuncrcs&ddtjtdœ‡fdd„ }t|ˆƒS)z0Wraps a function so that it swallows exceptions.zP.argszP.kwargs)ÚargsÚkwargsrcs&z ˆ||ŽWStk
r YnXdS©N)Ú    Exception)rr©rrrÚwrapper$s
 zsafecall.<locals>.wrapper)ÚtÚOptionalrr)rr#rr"rÚsafecall!sr&)ÚvaluercCsDt|tƒr<z| t ¡¡WStk
r:| dd¡YSXt|ƒS)z%Converts a value into a valid string.úutf-8Úreplace)Ú
isinstanceÚbytesÚdecodeÚsysÚgetfilesystemencodingÚ UnicodeErrorÚstr)r'rrrÚmake_str.s 
r1é-)ÚhelpÚ
max_lengthrcCs(| d¡}|dkr|d|…}| ¡}|s.dS|ddkrF|dd…}d}t|ƒd}t|ƒD]b\}}|t|ƒ|dk7}||kr†qÌ|ddkr¬d     |d|d…¡S||kr^||kr^qÌq^d     |¡S|td
ƒ7}|dkr|t||ƒ|dk8}||krq|d8}qØd     |d|…¡d
S) z+Returns a condensed version of help string.z
 
éÿÿÿÿNÚrúrÚ.ú z...)ÚfindrÚlenÚ    enumerater)r3r4Z paragraph_endÚwordsÚ total_lengthÚ
last_indexÚiÚwordrrrÚmake_default_short_help8s4
 
 
 
 
rBc@sàeZdZdZdejedfeejeejeedœdd    „Z    eej
d
œd d „Z ed œdd„Z ej ej
d œdd„Zdd œdd„Zdd œdd„Zdd œdd„Zejejeejeejeddœdd„Zejejd œdd„ZdS)ÚLazyFilezîA lazy file works like a regular file but it does not fully open
    the file but it does perform some basic checks early to see if the
    filename parameter does make sense.  This is useful for safely opening
    files for writing.
    ÚrNÚstrictFzos.PathLike[str])ÚfilenameÚmodeÚencodingÚerrorsÚatomiccCstt |¡|_||_||_||_||_|||jdkrNt||||ƒ\|_|_    n"d|krdt
||ƒ  ¡d|_d|_    dS)NrrDT) ÚosÚfspathrrGrHrIrJr Ú_fÚ should_closeÚopenÚclose)ÚselfrFrGrHrIrJrrrÚ__init__qs 
zLazyFile.__init__rcCst| ¡|ƒSr )ÚgetattrrO©rQrrrrÚ __getattr__ŒszLazyFile.__getattr__©rcCs.|jdk    rt|jƒSdt|jƒ›d|j›dS)Nz<unopened file 'z' ú>)rMÚreprÚformat_filenamerrG©rQrrrÚ__repr__s
 
zLazyFile.__repr__c
Cs‚|jdk    r|jSz&t|j|j|j|j|jd\}|_Wn@tk
rv}z"ddl    m
}||j|j d|‚W5d}~XYnX||_|S)z­Opens the file if it's not yet open.  This call might fail with
        a :exc:`FileError`.  Not handling this error will produce an error
        that Click shows.
        N©rJr)Ú    FileError)Úhint) rMr rrGrHrIrJrNÚOSErrorÚ
exceptionsr]Ústrerror)rQÚrvÚer]rrrrO”s
ÿ $z LazyFile.opencCs|jdk    r|j ¡dS)z+Closes the underlying file, no matter what.N)rMrPrZrrrrP¦s
zLazyFile.closecCs|jr| ¡dS)z‰This function only closes the file if it was opened by the lazy
        file wrapper.  For instance this will never close stdin.
        N)rNrPrZrrrÚclose_intelligently«szLazyFile.close_intelligentlycCs|Sr rrZrrrÚ    __enter__²szLazyFile.__enter__©Úexc_typeÚ    exc_valueÚtbrcCs | ¡dSr )rd©rQrgrhrirrrÚ__exit__µszLazyFile.__exit__cCs| ¡t|jƒSr )rOÚiterrMrZrrrÚ__iter__½szLazyFile.__iter__)rDNrEF)Ú__name__Ú
__module__Ú __qualname__Ú__doc__r$ÚUnionr0r%ÚboolrRÚAnyrUr[ÚIOrOrPrdreÚTypeÚ BaseExceptionrrkÚIteratorÚAnyStrrmrrrrrCjs0    ú ú û rCc@s”eZdZejejddœdd„Zeejdœdd„Zddœd    d
„Z    ej
ej e ej
e ej
e dd œd d „Zedœdd„Zejejdœdd„ZdS)Ú KeepOpenFileN)ÚfilercCs
||_dSr )Ú_file)rQr{rrrrRÃszKeepOpenFile.__init__rcCs t|j|ƒSr )rSr|rTrrrrUÆszKeepOpenFile.__getattr__rVcCs|Sr rrZrrrreÉszKeepOpenFile.__enter__rfcCsdSr rrjrrrrkÌszKeepOpenFile.__exit__cCs
t|jƒSr )rXr|rZrrrr[ÔszKeepOpenFile.__repr__cCs
t|jƒSr )rlr|rZrrrrm×szKeepOpenFile.__iter__)rnrorpr$rurtrRr0rUrer%rvrwrrkr[rxryrmrrrrrzÂsû rzTF)Úmessager{ÚnlÚerrÚcolorrcCs|dkr&|rtƒ}ntƒ}|dkr&dS|dk    rHt|tttfƒsHt|ƒ}n|}|rt|pVd}t|tƒrl|d7}n|d7}|s„| ¡dSt|ttfƒrÂt|ƒ}|dk    rÀ| ¡| |¡| ¡dSnBt    |ƒ}t
||ƒrÞt |ƒ}n&t rt dk    röt |ƒ}n|st |ƒ}| |¡| ¡dS)aPrint a message and newline to stdout or a file. This should be
    used instead of :func:`print` because it provides better support
    for different data, files, and environments.
 
    Compared to :func:`print`, this does the following:
 
    -   Ensures that the output encoding is not misconfigured on Linux.
    -   Supports Unicode in the Windows console.
    -   Supports writing to binary outputs, and supports writing bytes
        to text outputs.
    -   Supports colors and styles on Windows.
    -   Removes ANSI color and style codes if the output does not look
        like an interactive terminal.
    -   Always flushes the output.
 
    :param message: The string or bytes to output. Other objects are
        converted to strings.
    :param file: The file to write to. Defaults to ``stdout``.
    :param err: Write to ``stderr`` instead of ``stdout``.
    :param nl: Print a newline after the message. Enabled by default.
    :param color: Force showing or hiding colors and other styles. By
        default Click will remove color if the output does not look like
        an interactive terminal.
 
    .. versionchanged:: 6.0
        Support Unicode output on the Windows console. Click does not
        modify ``sys.stdout``, so ``sys.stdout.write()`` and ``print()``
        will still not support Unicode.
 
    .. versionchanged:: 4.0
        Added the ``color`` parameter.
 
    .. versionadded:: 3.0
        Added the ``err`` parameter.
 
    .. versionchanged:: 2.0
        Support colors on Windows if colorama is installed.
    Nr6Ú
ó
)rrr*r0r+Ú    bytearrayÚflushrÚwriterr r rr    )r}r{r~rr€ÚoutÚ binary_filerrrÚechoÛsD-
 
 
 
 
 
 
 
rˆz'te.Literal['stdin', 'stdout', 'stderr']cCs(t |¡}|dkr"td|›dƒ‚|ƒS)z°Returns a system stream for byte processing.
 
    :param name: the name of the stream to open.  Valid names are ``'stdin'``,
                 ``'stdout'`` and ``'stderr'``
    NúUnknown standard stream 'ú')r
ÚgetÚ    TypeError)rÚopenerrrrÚget_binary_streamBs
rŽrE)rrHrIrcCs,t |¡}|dkr"td|›dƒ‚|||ƒS)aÞReturns a system stream for text processing.  This usually returns
    a wrapped stream around a binary stream returned from
    :func:`get_binary_stream` but it also can take shortcuts for already
    correctly configured streams.
 
    :param name: the name of the stream to open.  Valid names are ``'stdin'``,
                 ``'stdout'`` and ``'stderr'``
    :param encoding: overrides the detected default encoding.
    :param errors: overrides the default error mode.
    Nr‰rŠ)rr‹rŒ)rrHrIrrrrÚget_text_streamNs
rrD)rFrGrHrIÚlazyrJrc
Cs\|r&t tjtjt|||||d¡St|||||d\}}|sXt tjtjt|ƒ¡}|S)aVOpen a file, with extra behavior to handle ``'-'`` to indicate
    a standard stream, lazy open on write, and atomic write. Similar to
    the behavior of the :class:`~click.File` param type.
 
    If ``'-'`` is given to open ``stdout`` or ``stdin``, the stream is
    wrapped so that using it in a context manager will not close it.
    This makes it possible to use the function without accidentally
    closing a standard stream:
 
    .. code-block:: python
 
        with open_file(filename) as f:
            ...
 
    :param filename: The name of the file to open, or ``'-'`` for
        ``stdin``/``stdout``.
    :param mode: The mode in which to open the file.
    :param encoding: The encoding to decode or encode a file opened in
        text mode.
    :param errors: The error handling mode.
    :param lazy: Wait to open the file until it is accessed. For read
        mode, the file is temporarily opened to raise access errors
        early, then closed until it is read again.
    :param atomic: Write to a temporary file and replace the given file
        on close.
 
    .. versionadded:: 3.0
    r\)r$ÚcastrurtrCr rz)rFrGrHrIrrJÚfrNrrrÚ    open_filecs$
ÿr“z9t.Union[str, bytes, os.PathLike[str], os.PathLike[bytes]])rFÚshortenrcCsP|rtj |¡}n
t |¡}t|tƒr8| t ¡d¡}n|     dd¡ dd¡}|S)u»Format a filename as a string for display. Ensures the filename can be
    displayed by replacing any invalid bytes or surrogate escapes in the name
    with the replacement character ``�``.
 
    Invalid bytes or surrogate escapes will raise an error when written to a
    stream with ``errors="strict". This will typically happen with ``stdout``
    when the locale is something like ``en_GB.UTF-8``.
 
    Many scenarios *are* safe to write surrogates though, due to PEP 538 and
    PEP 540, including:
 
    -   Writing to ``stderr``, which uses ``errors="backslashreplace"``.
    -   The system has ``LANG=C.UTF-8``, ``C``, or ``POSIX``. Python opens
        stdout and stderr with ``errors="surrogateescape"``.
    -   None of ``LANG/LC_*`` are set. Python assumes ``LANG=C.UTF-8``.
    -   Python is started in UTF-8 mode  with  ``PYTHONUTF8=1`` or ``-X utf8``.
        Python opens stdout and stderr with ``errors="surrogateescape"``.
 
    :param filename: formats a filename for UI display.  This will also convert
                     the filename into unicode without failing.
    :param shorten: this optionally shortens the filename to strip of the
                    path that leads up to it.
    r)r(Úsurrogateescape)
rKÚpathÚbasenamerLr*r+r,r-r.Úencode)rFr”rrrrY”s
 
 ÿrY)Úapp_nameÚroamingÚ force_posixrcCs¤tr>|r dnd}tj |¡}|dkr0tj d¡}tj ||¡S|r`tj tj dt|ƒ›¡¡Stj    dkr€tj tj d¡|¡Stj tj dtj d    ¡¡t|ƒ¡S)
a†Returns the config folder for the application.  The default behavior
    is to return whatever is most appropriate for the operating system.
 
    To give you an idea, for an app called ``"Foo Bar"``, something like
    the following folders could be returned:
 
    Mac OS X:
      ``~/Library/Application Support/Foo Bar``
    Mac OS X (POSIX):
      ``~/.foo-bar``
    Unix:
      ``~/.config/foo-bar``
    Unix (POSIX):
      ``~/.foo-bar``
    Windows (roaming):
      ``C:\Users\<user>\AppData\Roaming\Foo Bar``
    Windows (not roaming):
      ``C:\Users\<user>\AppData\Local\Foo Bar``
 
    .. versionadded:: 2.0
 
    :param app_name: the application name.  This should be properly capitalized
                     and can contain whitespace.
    :param roaming: controls if the folder should be roaming or not on Windows.
                    Has no effect otherwise.
    :param force_posix: if this is set to `True` then on any POSIX system the
                        folder will be stored in the home folder with a leading
                        dot instead of the XDG config home or darwin's
                        application support folder.
    ÚAPPDATAÚ LOCALAPPDATANú~z~/.Údarwinz~/Library/Application SupportÚXDG_CONFIG_HOMEz    ~/.config)
rrKÚenvironr‹r–Ú
expanduserrrr-Úplatform)r™ršr›ÚkeyÚfolderrrrÚ get_app_dir¾s"   
 
ÿþr¦c@sHeZdZdZejejddœdd„Zddœdd„Ze    ejd    œd
d „Z
dS) ÚPacifyFlushWrappera«This wrapper is used to catch and suppress BrokenPipeErrors resulting
    from ``.flush()`` being called on broken pipe during the shutdown/final-GC
    of the Python interpreter. Notably ``.flush()`` is always called on
    ``sys.stdout`` and ``sys.stderr``. So as to have minimal impact on any
    other cleanup code, and the case where the underlying file is not a broken
    pipe, all calls and attributes are proxied.
    N)ÚwrappedrcCs
||_dSr )r¨)rQr¨rrrrRøszPacifyFlushWrapper.__init__rVc
CsLz|j ¡Wn8tk
rF}zddl}|j|jkr6‚W5d}~XYnXdS)Nr)r¨r„r_ÚerrnoÚEPIPE)rQrcr©rrrr„ûs  zPacifyFlushWrapper.flush)ÚattrrcCs t|j|ƒSr )rSr¨)rQr«rrrrUszPacifyFlushWrapper.__getattr__) rnrorprqr$rurtrRr„r0rUrrrrr§ïs    r§)r–Ú_mainrcCsº|dkrtjd}|s tjd}t|ddƒdksbtjdkrn|jdkrntj |¡sntj |›d¡rntj     |¡St
  t |j¡}tj  tj     |¡¡d}|dkrª|›d    |›}d
| d    ¡›S) a:Determine the command used to run the program, for use in help
    text. If a file or entry point was executed, the file name is
    returned. If ``python -m`` was used to execute a module or package,
    ``python -m name`` is returned.
 
    This doesn't try to be too precise, the goal is to give a concise
    name for help text. Files are only shown as their name without the
    path. ``python`` is only shown for modules, and the full path to
    ``sys.executable`` is not shown.
 
    :param path: The Python file being executed. Python puts this in
        ``sys.argv[0]``, which is used by default.
    :param _main: The ``__main__`` module. This should only be passed
        during internal testing.
 
    .. versionadded:: 8.0
        Based on command args detection in the Werkzeug reloader.
 
    :meta private:
    NÚ__main__rÚ __package__>Nr6Úntr6z.exer8z
python -m )r-ÚmodulesÚargvrSrKrr®r–Úexistsr—r$r‘r0ÚsplitextÚlstrip)r–r¬Z    py_modulerrrrÚ_detect_program_names&
 
ÿþ
ýü rµ)ÚuserÚenvÚglob_recursive)rr¶r·r¸rc    Cs„ddlm}g}|D]j}|r(tj |¡}|r8tj |¡}z|||d}Wntjk
rbg}YnX|st| |¡q| |¡q|S)a­Simulate Unix shell expansion with Python functions.
 
    See :func:`glob.glob`, :func:`os.path.expanduser`, and
    :func:`os.path.expandvars`.
 
    This is intended for use on Windows, where the shell does not do any
    expansion. It may not exactly match what a Unix shell would do.
 
    :param args: List of command line arguments to expand.
    :param user: Expand user home directory.
    :param env: Expand environment variables.
    :param glob_recursive: ``**`` matches directories recursively.
 
    .. versionchanged:: 8.1
        Invalid glob patterns are treated as empty expansions rather
        than raising an error.
 
    .. versionadded:: 8.0
 
    :meta private:
    r)Úglob)Ú    recursive)    r¹rKr–r¢Ú
expandvarsÚreÚerrorÚappendÚextend)rr¶r·r¸r¹r†ÚargÚmatchesrrrÚ _expand_args?s   
  rÂ)r2)NNTFN)NrE)rDNrEFF)F)TF)NN)7rKr¼r-Útypingr$Ú    functoolsrÚtypesrrÚ_compatrrrr    r
r r r rrÚglobalsrÚ TYPE_CHECKINGZtyping_extensionsÚteZ    ParamSpecrÚTypeVarrr0rr&rtr1ÚintrBrCrzr%rursrˆÚBinaryIOrŽÚTextIOrr“rYr¦r§rµÚIterableÚListrÂrrrrÚ<module>s°              
 
 
2Xû
ú gýü ú
ù 3þý *1ÿþ :ûú