%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/click/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/click/__pycache__/utils.cpython-312.pyc

�

D�dJO��r�ddlZddlZddlZddlZddlmZddlmZddlm	Z	ddl
mZddl
mZddl
m
Z
dd	l
mZdd
l
mZddl
mZddl
mZdd
l
mZddl
mZddl
mZddlmZej.rddlZej4d�Zej8d�Zdedefd�ZdCd�Z dejBdefd�Z"dDdede#defd�Z$Gd�d�Z%Gd�d�Z&					dEd!ejNejBd"ejNejPejBd#e)d$e)d%ejNe)ddfd&�Z*dd'dejVfd(�Z,		dFdd'd)ejNed*ejNedejZfd+�Z.					dGd,ed-ed)ejNed*ejNed.e)d/e)dejPejBfd0�Z/	dHd,d1d2e)defd3�Z0dId4ed5e)d6e)defd7�Z1Gd8�d9�Z2	dJd:ejNed;ejNedefd<�Z3d d d d=�d>ejhed?e)d@e)dAe)dejjef
dB�Z6y)K�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 �-/usr/lib/python3/dist-packages/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_helprF8sP���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
edejfd�Zdefd
�Zdejejfd�Zdd�Zdd�Zdd�Zdejej$edejedejeddfd�Zdej,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�filenamezos.PathLike[str]�mode�encoding�errors�atomicc�&�tj|�|_||_||_||_||_|||jdk(rt||||�\|_|_	yd|vrt||�j�d|_d|_	y)Nr�rT)�os�fspathrrJrKrLrMr�_f�should_close�open�close)�selfrIrJrKrLrMs      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")�getattrrT�rVrs  r�__getattr__zLazyFile.__getattr__�s���t�y�y�{�D�)�)rc��|j�t|j�Sdt|j��d|j�d�S)Nz<unopened file 'z' �>)rR�repr�format_filenamerrJ�rVs 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�rMr)�	FileError)�hint)rRrrrJrKrLrMrS�OSError�
exceptionsrd�strerror)rV�rv�erds    rrTz
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)rRrUr`s rrUzLazyFile.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)rSrUr`s r�close_intelligentlyzLazyFile.close_intelligently�s������J�J�L�rc��|Sr"�r`s r�	__enter__zLazyFile.__enter__�����r�exc_type�	exc_value�tbc�$�|j�yr")rm�rVrrrsrts    r�__exit__zLazyFile.__exit__�s��	
� � �"rc�L�|j�t|j�Sr")rT�iterrRr`s r�__iter__zLazyFile.__iter__�s���	�	���D�G�G�}�r)rON�strictF�rN)rrH)�__name__�
__module__�__qualname__�__doc__r&�Unionr3r'�boolrW�Anyr[ra�IOrTrUrmrp�Type�
BaseExceptionrrw�Iterator�AnyStrrzrorrrHrHjs����$(�"*��
%��'�'�#�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)rVr�s  rrWzKeepOpenFile.__init__�s	��"&��
rrc�.�t|j|�Sr")rYr�rZs  rr[zKeepOpenFile.__getattr__�s���t�z�z�4�(�(rc��|Sr"ror`s rrpzKeepOpenFile.__enter__�rqrrrrsrtc��yr"rorvs    rrwzKeepOpenFile.__exit__�s��	
rc�,�t|j�Sr")r^r�r`s rrazKeepOpenFile.__repr__�����D�J�J��rc�,�t|j�Sr")ryr�r`s rrzzKeepOpenFile.__iter__�r�r)rr�)r}r~rr&r�r�rWr3r[rpr'r�r�rrwrar�r�rzrorrr�r��s���'�Q�T�T�!�%�%�[�'�T�'�)��)����)��
��*�*�Q�V�V�M�2�3�
��:�:�m�,�
�
�J�J�}�%�	
�

�
� �#� � �!�*�*�Q�X�X�.� rr�T�messager��nl�err�colorc�z�|�|rt�}n
t�}|�y|�'t|ttt
f�st|�}n|}|r!|xsd}t|t�r|dz
}n|dz
}|s|j
�yt|tt
f�r?t|�}|�z|j
�|j|�|j
�yt|�}t||�rt|�}n%trt�t|�}n
|st|�}|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�
�!�-�)�$�/��� ��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�OrrKrLc�`�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�)rrKrLr�s    r�get_text_streamr�Ns;���
�
�d�
#�F�
�~��3�D�6��;�<�<��(�F�#�#rrIrJ�lazyrMc
�6�|rCtjtjtjt	|||||���St|||||��\}}|s>tjtjtjt
|��}|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
    rc)r&�castr�r�rHrr�)rIrJrKrLr�rM�frSs        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)
rP�path�basenamerQr-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|�}|�tjjd�}tjj
||�S|rHtjj
tjjdt|�����Stjdk(r=tjj
tjjd�|�Stjj
tjjdtjjd��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)
rrP�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�)rVr�s  rrWzPacifyFlushWrapper.__init__�s	����rc��	|jj�y#t$r(}ddl}|j|jk7r�Yd}~yd}~wwxYw)Nr)r�r�rf�errno�EPIPE)rVrjr�s   rr�zPacifyFlushWrapper.flush�sB��	��L�L��� ���	���w�w�%�+�+�%��&��	�s��	A�A	�	A�attrc�.�t|j|�Sr")rYr�)rVr�s  rr[zPacifyFlushWrapper.__getattr__s���t�|�|�T�*�*rr|)r}r~rr�r&r�r�rWr�r3r[rorrr�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
    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__>Nr9�ntr9z.exer;z
python -m )r0�modules�argvrYrPrr�r��existsr�r&r�r3�splitext�lstrip)r�r��	py_modulers    r�_detect_program_namer�s��.
�}����J�'����x�x��{���u�m�T�*�j�8�
���4������#������t�$��G�G�N�N�d�V�4�=�)��w�w����%�%�
���s�E�-�-�.�I�
�7�7���B�G�G�,�,�T�2�3�A�6�D��z�� �k��4�&�)�	�
�	�(�(��-�.�/�/r)�user�env�glob_recursiverr�r�r�c�>�ddlm}g}|D]t}|rtjj|�}|rtjj	|�}	|||��}|s|j|��d|j|��v|S#t
j$rg}Y�@wxYw)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�rPr�r��
expandvars�re�error�append�extend)rr�r�r�r�r��arg�matchess        r�_expand_argsr�?s���8�
�C�� ����'�'�$�$�S�)�C���'�'�$�$�S�)�C�	��3�.�9�G���J�J�s�O��J�J�w�� �"�J���x�x�	��G�	�s�
B�B�B)r$zt.Callable[P, R]rzt.Callable[P, t.Optional[R]])�-)NNTFN)Nr{)rONr{FF)F)TF)NN)7rPr�r0�typingr&�	functoolsr�typesrr�_compatrrr	r
rrr
rrr�globalsr�
TYPE_CHECKING�typing_extensions�te�	ParamSpecr�TypeVarrr3rr(r�r4�intrFrHr�r'r�r�r��BinaryIOr��TextIOr�r�r_r�r�r��Iterable�Listr�rorr�<module>r�s���	�	�
��$���)�)�(�'�#� �&��!��*��?�?�"�����S��A�
�A�I�I�c�N��*�C�*�C�*�
)��A�E�E��c��/'�#�/'�3�/'��/'�dU�U�p � �4"&�$(���"�d�
�Z�Z����
�d�
�*�*�Q�T�T�!�%�%�[�
!�d�	
�d�
�	d�

�:�:�d��d�
�
d�N	�E�	�!�*�*�	�!%�&�$�
3�$��j�j��o�$�
�J�J�s�O�$��X�X�	$�.� $�&���
.
��.
�

�.
��j�j��o�.
�
�J�J�s�O�	.
�
�.
�
�
.
��T�T�!�%�%�[�.
�f�'�I�'�
�'�	�'�T.�#�.��.�$�.�SV�.�b+�+�4CG�40�
�*�*�S�/�40�)*���J�)?�40��40�t���1�
�*�*�S�/�1��1�
�	1�
�1��V�V�C�[�
1r

Zerion Mini Shell 1.0