Files
cms-website/.deps_siteforge_v812/click/__pycache__/utils.cpython-312.pyc
T

279 lines
26 KiB
Plaintext
Raw Normal View History

Ë
îÅÙjjOãó�—ddlZddlZddlZddlZddlmZddlmZddlm Z ddl
m Z ddl
m Z ddl
m
Z
dd l
mZdd
l
mZdd l
mZdd l
mZdd
l
mZddl
mZddl
mZddlmZej.rddlZej4d«Zej8d«Zdedefd„ZdDd„Z dejBdefd„Z"dEdede#defd„Z$Gd„d«Z%Gd„d«Z& dFd!ejNejBd"ejNejPejBd#e)d$e)d%ejNe)ddf d&„Z*dd'dejVfd(„Z, dGdd'd)ejNed*ejNedejZfd+„Z. dHd,ej^ed-fd.ed)ejNed*ejNed/e)d0e)dejPejBfd1„Z0 dId,d2d3e)defd4„Z1dJd5ed6e)d7e)defd8„Z2Gd9„d:«Z3 dKd;ejNed<ejNedefd=„Z4d d d d>œd?ejjed@e)dAe)dBe)dejlef
dC„Z7y)Lé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Úreturncó\—dj|j««j«S)NÚ-)ÚjoinÚsplitÚlower)rs úOC:\Users\30997\AppData\Local\Temp\pip-target-6g32zz5s\lib\python\click/utils.pyÚ _posixifyrs €Ø �8‰8�D—J‘J“LÓ !× 'Ñ 'Ó )Ð)ócó^‡—dddddtjtfˆfd„ }t|‰«S)z0Wraps a function so that it swallows exceptions.ÚargszP.argsÚkwargszP.kwargsrcó4•— ‰|i|¤ŽS#t$rYywxYw©N)Ú Exception)rr Úfuncs €rÚwrapperzsafecall.<locals>.wrapper$s-ø€ð Ù˜Ð( Ñ(Ð (øÜò Ø Øð ús ƒ ‹ –)ÚtÚOptionalrr)r$r%s` rÚsafecallr(!s4ø€ð�xð¨:ð¼!¿*¹*ÄQ¹-õô ˜' 4Ó (Ð(rÚvaluecó—t|t«r$ |jtj««St
|«S#t
$r|jdd«cYSwxYw)z%Converts a value into a valid string.úutf-8Úreplace)Ú
isinstanceÚbytesÚdecodeÚsysÚgetfilesystemencodingÚ UnicodeErrorÚstr)r)s rÚmake_strr4.sW€ä�%œÔð 4Ø—<‘<¤× 9Ñ 9Ó ;Ó<Ð <ô ˆu‹:Ðøôò 4Ø—<‘< ¨Ó3Ò 3ð 4ús’"AÁAÁAÚhelpÚ
max_lengthcó—|jd«}|dk7r|d|}|j«}|sy|ddk(r|dd}d}t|«dz
}t|«D]N\}}|t|«|dkDzz
}||kDrnA|ddk(rd j |d|dz«cS||k(sŒH||k7sŒNnd j |«S|td
«z
}|dkDr(|t||«|dkDzz}||krn |dz}|dkDrŒ(d j |d|«d
zS) z+Returns a condensed version of help string.z
éÿÿÿÿNÚrÚrÚ.Ú z...)ÚfindrÚlenÚ enumerater)r5r6Ú
paragraph_endÚwordsÚ total_lengthÚ
last_indexÚiÚwords rÚmake_default_short_helprF8sK€ð—I‘I˜fÓ%€Mà˜ÒØ�N�]Ð#ˆð
�J‰J‹L€Eá Øð
ˆQ�x�4ÒØ�a�b� ˆà€LÜ�U“˜a‘€Jä˜UÖ#‰ˆˆ4Øœ˜D›  Q¨¡UÑ+Ñ+ˆ à ˜*Ò $Ù à �‰8�sŠ?Ø—8‘8˜E ' A¨¡E˜NÓ+Ò +à ˜:Ó %¨!¨z«/Ù ð$ð�x‰x˜‹Ðð”C˜“JÑ€Lð ˆaŠ%Øœ˜E !™H›
¨¨Q©Ñ/Ñ/ˆ à ˜:Ò %Ø à ˆQ‰ˆð
ˆa‹%ð �8‰8�E˜"˜1�IÓ  Ñ &Ð&rc óÄ—eZdZdZ ddej
edfdedejedejedef
d „Z d
ed ejfd „Z d efd
„Z d ejejfd„Zdd„Zdd„Zdd„Zdejej$edejedejed dfd„Zd ej,ej.fd„Zy)Ú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.
NÚfilenameúos.PathLike[str]ÚmodeÚencodingÚerrorsÚatomiccó&—tj|«|_||_||_||_||_|||jdk(rt||||«\|_|_ yd|vrt||«j«d|_d|_ y)NrÚrT) ÚosÚfspathrrKrLrMrNr Ú_fÚ should_closeÚopenÚclose)ÚselfrIrKrLrMrNs rÚ__init__zLazyFile.__init__qs‡€ôŸ™ 8Ó,ˆŒ ؈Œ Ø ˆŒ
؈Œ ؈Œ Ù Ù à �9‰9˜Ò Ü)4°X¸tÀXÈvÓ)VÑ &ˆDŒG�TÕ&à�d‰{ô�X˜tÓ$×*Ñ*Ô,؈DŒGØ $ˆDÕ rrrcó6—t|j«|«Sr")ÚgetattrrU©rWrs rÚ __getattr__zLazyFile.__getattr__Œs€Ü�t—y‘y“{ DÓ)Ð)rcó�—|j�t|j«Sdt|j«›d|j›d�S)Nz<unopened file 'z' Ú>)rSÚreprÚformat_filenamerrK©rWs rÚ__repr__zLazyFile.__repr__�s=€Ø �7‰7РܘŸ™“=Ð Ø!¤/°$·)±)Ó"<Ð!=¸RÀÇ Á ¸{È!ÐLÐLrcóF—|j� |jS t|j|j|j|j
|j ¬«\}|_||_|S#t$r*}ddl m
}||j|j¬«|‚d}~wwxYw)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©rNr)Ú FileError)Úhint) rSr rrKrLrMrNrTÚOSErrorÚ
exceptionsreÚstrerror)rWÚrvÚeres rrUz
LazyFile.open”s‡€ð
�7‰7Ð Ø—7‘7ˆNð ?Ü$/Ø— ‘ ˜4Ÿ9™9 d§m¡m°T·[±[ÈÏÉô%Ñ !ˆB�Ô!ðˆŒØˆ øô ò ?Ý -á˜DŸI™I¨A¯J©JÔ7¸QÐ >ûð ?úsšA
A-Á- B Á6%BÂB cóR—|j�|jj«yy)z+Closes the underlying file, no matter what.N)rSrVras rrVzLazyFile.close¦s€à �7‰7Ð Ø �G‰G�M‰M�Oð rcó>—|jr|j«yy)z‰This function only closes the file if it was opened by the lazy
file wrapper. For instance this will never close stdin.
N)rTrVras rÚclose_intelligentlyzLazyFile.close_intelligently«s€ð × Ò Ø �J‰J�Lð rcó—|Sr"©ras rÚ __enter__zLazyFile.__enter__²ó€Øˆ rÚexc_typeÚ exc_valueÚtbcó$—|j«yr")rn©rWrsrtrus rÚ__exit__zLazyFile.__exit__µs€ð
× Ñ Õ"rcóL—|j«t|j«Sr")rUÚiterrSras rÚ__iter__zLazyFile.__iter__½s€Ø � ‰ Œ Ü�D—G‘G‹}Ðr)rPNÚstrictF©rN)rrH)Ú__name__Ú
__module__Ú __qualname__Ú__doc__r&ÚUnionr3r'ÚboolrXÚAnyr\rbÚIOrUrVrnrqÚTypeÚ
BaseExceptionrrxÚIteratorÚAnyStrr{rprrrHrHjs„ñðØ$(Ø"*Øñ
%à—'‘'˜#Ð1Ð1Ñ2ð%ðð%ð—*‘*˜S‘/ð %ð
—
‘
˜3‘ð %ð ó
%ð6* ð*¨¯©ó*ðM˜#óMð
�a—d‘d˜1Ÿ5™5‘kóó$ó
óð#à—*‘*˜QŸV™V MÑ2Ñ3ð#ð—:‘:˜mÑ,ð#ð
�J‰J�}Ñ %ð #ð
ó #ð˜!Ÿ*™* Q§X¡XÑ.ôrrHcó<—eZdZdejej
ddfd„Zdedej
fd„Zdd„Z dejeje d eje d
eje
ddfd „Zdefd „Zdej ej"fd
„Zy)Ú KeepOpenFileÚfilerNcó—||_yr")Ú_file)rWrŒs rrXzKeepOpenFile.__init__Ãs €Ø"&ˆ�
rrcó.—t|j|«Sr")rZrŽr[s rr\zKeepOpenFile.__getattr__Æs€Ü�t—z‘z 4Ó(Ð(rcó—|Sr"rpras rrqzKeepOpenFile.__enter__Érrrrsrtrucó—yr"rprws rrxzKeepOpenFile.__exit__Ìs€ð
rcó,—t|j«Sr")r_rŽras rrbzKeepOpenFile.__repr__Ôó€Ü�D—J‘JÓÐrcó,—t|j«Sr")rzrŽras rr{zKeepOpenFile.__iter__×r“r)rr‹)r~rr€r&r…r„rXr3r\rqr'r†r‡rrxrbrˆr‰r{rprrr‹r‹Âs±„ð'˜QŸT™T !§%¡%™[ð'¨Tó'ð) ð)¨¯©ó)óð
à—*‘*˜QŸV™V MÑ2Ñ3ð
ð—:‘:˜mÑ,ð
ð
�J‰J�}Ñ %ð 
ð
ó 
ð ˜#ó ð ˜!Ÿ*™* Q§X¡XÑ.ô rr‹TÚmessagerŒÚnlÚerrÚcolorcó|—|€|r t«}n
t«}|€y|�'t|ttt
f«s t|«}n|}|r!|xsd}t|t«r|dz
}n|dz
}|s|j
«yt|tt
f«r?t|«}|�{|j
«|j|«|j
«yt|«}t||«r t|«}n&tr t�
t||«}n
|s t|«}|j|«|j
«y)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.
Nr9Ú
ó
)rrr-r3r.Ú bytearrayÚflushr Úwriterr
rrr
)r•rŒr–r—r˜ÚoutÚ binary_files rÚechor¡Ûs€ðZ €|Ù Ü'Ó)‰Dä'Ó)ˆDð ˆ<Ø ðФ:¨g¼¼UÄIÐ7NÔ#OÜ/2°7«|‰àˆá ØŠi�RˆÜ �cœ3Ô Ø �4‰K‰Cà �5‰LˆCá Ø �
‰
Œ Øô �#œœyÐ)Ô*Ü)¨$Ó/ˆ à Ð "Ø �J‰JŒLØ × Ñ ˜cÔ "Ø × Ñ Ô Ø ô
& eÓ,ˆä ˜T 5Ô )ܘS“/‰CÝ
Ü!Ð-Ü)¨$°Ó6‘ÙÜ  “o�à‡J�Jˆs„O؇J�J…Lrz'te.Literal['stdin', 'stdout', 'stderr']có\—tj|«}|€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'``
úUnknown standard stream 'Ú')r ÚgetÚ TypeError)rÚopeners rÚget_binary_streamr¨Bs5€ô ×
Ñ
 Ó
%€FØ
€~ÜÐ3°D°6¸Ð;Ó<Ð<Ù ‹8€OrrLrMcó`—tj|«}|€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.
r£r¤)rr¥r¦)rrLrMr§s rÚget_text_streamrªNs;€ô×
Ñ
˜dÓ
#€FØ
€~ÜÐ3°D°6¸Ð;Ó<Ð<Ù �(˜FÓ #Ð#rrIrJrKÚlazyrNc
ó6—|rCtjtjtjt |||||¬««St |||||¬«\}}|s>tjtjtjt
|««}|S)a^Open 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 or Path 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
rd)r&Úcastr…r„rHr r‹)rIrKrLrMr«rNÚfrTs rÚ open_filer¯csw€ñH Ü�v‰vÜ
�D‰D”—‘‰Kœ (¨D°(¸FÈ6ÔRó
ð
ô" (¨D°(¸FÈ6ÔR�O€A€|á Ü
�F‰F”1—4‘4œŸ™‘;¤ ¨Q£Ó 0ˆà €Hrz9t.Union[str, bytes, os.PathLike[str], os.PathLike[bytes]]Úshortencó$—|r tjj|«}ntj|«}t |t
«r&|j
tj«d«}|S|jdd«j
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)
rQÚpathÚbasenamerRr-r.r/r0r1Úencode)rIr°s rr`r`”s}€ñ6Ü—7‘7×#Ñ# HÓ-‰ä—9‘9˜XÓ&ˆä�(œEÔ"Ø—?‘?¤3×#<Ñ#<Ó#>À ÓJˆð €Oð —?‘? 7Ð,=Ó>×EÑEØ �Yó
ˆð €OrÚapp_nameÚroamingÚ force_posixcóÖ—trf|rdnd}tjj|«}|€tjj d«}tjj
||«S|rHtjj
tjj dt|«›�««Stjdk(r=tjj
tjj d«|«Stjj
tjjdtjj 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Ú LOCALAPPDATAÚ~z~/.Údarwinz~/Library/Application SupportÚXDG_CONFIG_HOMEz ~/.config)
rrQÚenvironr¥r³Ú
expanduserrrr0Úplatform)r¶r·r¸ÚkeyÚfolders rÚ get_app_dirrľsù€õ> Ù"‰i¨ˆÜ—‘—‘ Ó$ˆØ ˆ>Ü—W‘W×'Ñ'¨Ó,ˆFÜ�w‰w�|‰|˜F HÓ-Ð-ÙÜ�w‰w�|‰|œBŸG™G×.Ñ.°´Y¸xÓ5HÐ4IÐ/JÓKÓLÐLÜ
‡|�|�xÒÜ�w‰w�|‰|Ü �G‰G× Ñ Ð>Ó ?Àó
ð
ô �7‰7�<‰<Ü
�
‰
�‰Ð(¬"¯'©'×*<Ñ*<¸[Ó*IÓJÜ�(Óó ðrcóz—eZdZdZdej
ej ddfd„Zd d„Zde dej fd„Z
y)
Ú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.
ÚwrappedrNcó—||_yr")rÇ)rWrÇs rrXzPacifyFlushWrapper.__init__øs €Øˆ� rcó¢— |jj«y#t$r(}ddl}|j|jk7r‚Yd}~yd}~wwxYw)Nr)rÇr�rgÚerrnoÚEPIPE)rWrkrÊs rr�zPacifyFlushWrapper.flushûsB€ð Ø �L‰L× Ñ Õ øÜò Û à�w‰w˜%Ÿ+™+Ò%Øô&ûð ús‚� A¦A Á AÚattrcó.—t|j|«Sr")rZrÇ)rWrÌs rr\zPacifyFlushWrapper.__getattr__s€Ü�t—|‘| TÓ*Ð*rr}) r~rr€r�r&r…r„rXr�r3r\rprrrÆrÆïsB„ñð §¡ Q§U¡U¡ ð°óóð+ ð+¨¯©ô+rrÆr³Ú_maincó~—|€tjd}|stjd}t|dd«dvsctj
dk(ro|j dk(r`tjj|«sAtjj|›d�«rtjj|«Stjt|j «}tjjtjj|««d}|dk7r|›d |›�}d
|jd «›�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