HEX
Server: LiteSpeed
System: Linux my-kul-web2054.main-hosting.eu 5.14.0-611.13.1.el9_7.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Dec 11 04:57:59 EST 2025 x86_64
User: u665686179 (665686179)
PHP: 8.2.30
Disabled: system, exec, shell_exec, passthru, mysql_list_dbs, ini_alter, dl, symlink, link, chgrp, leak, popen, apache_child_terminate, virtual, mb_send_mail
Upload Files
File: //opt/alt/python311/lib/python3.11/site-packages/click/__pycache__/testing.cpython-311.pyc
�

D��h�J���ddlmZddlmZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddl
mZddlmZddlmZddlmZddlmZdd	lmZejrdd
lmZddlmZGd�d
��Zejd#d���ZGd�dej��ZGd�d��ZGd�dej ��Z!d$d�Z"Gd�d ��Z#Gd!�d"��Z$dS)%�)�annotationsN)�
TracebackType�)�_compat)�
formatting)�termui)�utils)�_find_binary_reader)�ReadableBuffer)�Commandc�\�eZdZdd�Zdd
�Zdd
�Zddd�Zddd�Zddd�Zdd�Z	d d�Z
d!d�ZdS)"�EchoingStdin�input�
t.BinaryIO�output�return�Nonec�0�||_||_d|_dS)NF)�_input�_output�_paused)�selfrrs   �@/opt/alt/python311/lib/python3.11/site-packages/click/testing.py�__init__zEchoingStdin.__init__s��������������x�str�t.Anyc�,�t|j|��S�N)�getattrr)rrs  r�__getattr__zEchoingStdin.__getattr__s���t�{�A�&�&�&r�rv�bytesc�H�|js|j�|��|Sr )rr�write)rr#s  r�_echozEchoingStdin._echo"s'���|�	#��L���r�"�"�"��	r����n�intc�\�|�|j�|����Sr )r'r�read�rr)s  rr,zEchoingStdin.read(s$���z�z�$�+�*�*�1�-�-�.�.�.rc�\�|�|j�|����Sr )r'r�read1r-s  rr/zEchoingStdin.read1+s$���z�z�$�+�+�+�A�.�.�/�/�/rc�\�|�|j�|����Sr )r'r�readliner-s  rr1zEchoingStdin.readline.s$���z�z�$�+�.�.�q�1�1�2�2�2r�list[bytes]c�N���fd��j���D��S)Nc�:��g|]}��|����S��r'��.0rrs  �r�
<listcomp>z*EchoingStdin.readlines.<locals>.<listcomp>2s#���?�?�?�!��
�
�1�
�
�?�?�?r)r�	readlines�rs`rr:zEchoingStdin.readlines1s+���?�?�?�?�t�{�'<�'<�'>�'>�?�?�?�?r�cabc.Iterator[bytes]c�D��t�fd��jD����S)Nc3�B�K�|]}��|��V��dSr r6r7s  �r�	<genexpr>z(EchoingStdin.__iter__.<locals>.<genexpr>5s-�����7�7�a�D�J�J�q�M�M�7�7�7�7�7�7r)�iterrr;s`r�__iter__zEchoingStdin.__iter__4s(����7�7�7�7�4�;�7�7�7�7�7�7rc�*�t|j��Sr )�reprrr;s r�__repr__zEchoingStdin.__repr__7s���D�K� � � rN)rrrrrr)rrrr)r#r$rr$)r()r)r*rr$)rr2)rr<�rr)�__name__�
__module__�__qualname__rr"r'r,r/r1r:rArDr5rrrrs�����������
'�'�'�'�����/�/�/�/�/�0�0�0�0�0�3�3�3�3�3�@�@�@�@�8�8�8�8�!�!�!�!�!�!rr�stream�EchoingStdin | Noner�cabc.Iterator[None]c#�>K�|�dV�dSd|_dV�d|_dS)NTF)r)rIs r�_pause_echorM;s3����
�~�
���������
��������rc�<��eZdZdZd�fd�Zd
�fd�Zd�fd�Z�xZS)�BytesIOCopyzdPatch ``io.BytesIO`` to let the written stream be copied to another.

    .. versionadded:: 8.2
    �copy_to�
io.BytesIOrrc�V��t�����||_dSr )�superrrP)rrP�	__class__s  �rrzBytesIOCopy.__init__Ks$���
������������rc�z��t�����|j���dSr )rS�flushrP)rrTs �rrVzBytesIOCopy.flushOs.���
���
�
������������r�brr*c�z��|j�|��t���|��Sr )rPr&rS)rrWrTs  �rr&zBytesIOCopy.writeSs/�������1�����w�w�}�}�Q���r)rPrQrr�rr)rWrrr*)rFrGrH�__doc__rrVr&�
__classcell__�rTs@rrOrOEs����������
������������ � � � � � � � � � rrOc�"�eZdZdZdd�Zdd�ZdS)�StreamMixerz�Mixes `<stdout>` and `<stderr>` streams.

    The result is available in the ``output`` attribute.

    .. versionadded:: 8.2
    rrc��tj��|_t|j���|_t|j���|_dS)N)rP)�io�BytesIOrrO�stdout�stderrr;s rrzStreamMixer.__init__`s;��"$�*�,�,���"-�d�k�"B�"B�"B���"-�d�k�"B�"B�"B����rc��|j���|j���|j���dS)z�
        Guarantee that embedded file-like objects are closed in a
        predictable order, protecting against races between
        self.output being closed and other streams being flushed on close

        .. versionadded:: 8.2.2
        N)rc�closerbrr;s r�__del__zStreamMixer.__del__esF��	
����������������������rNrY)rFrGrHrZrrfr5rrr^r^XsJ��������C�C�C�C�

�
�
�
�
�
rr^c�P��eZdZd
�fd
�Zedd���Zedd���Z�xZS)�_NamedTextIOWrapper�bufferr�namer�mode�kwargsrrrc�X��t��j|fi|��||_||_dSr )rSr�_name�_mode)rrirjrkrlrTs     �rrz_NamedTextIOWrapper.__init__ss6���	������*�*�6�*�*�*���
���
�
�
rc��|jSr )rnr;s rrjz_NamedTextIOWrapper.namez�
���z�rc��|jSr )ror;s rrkz_NamedTextIOWrapper.mode~rqr)
rirrjrrkrrlrrrrE)rFrGrHr�propertyrjrkr[r\s@rrhrhrs}������������������X�������X�����rrhr� str | bytes | t.IO[t.Any] | None�charsetrrc��t|d��r5ttjd|����}|�|St	d���|�d}n*t|t��r|�|��}tj	|��S)Nr,zt.IO[t.Any]z.Could not find binary reader for input stream.r)
�hasattrr
�t�cast�	TypeError�
isinstancer�encoder`ra)rrur#s   r�make_input_streamr}�s����u�f���J�
 ���
�u�!=�!=�
>�
>��
�>��I��H�I�I�I��}����	�E�3�	�	�&����W�%�%��
�:�e���rc�n�eZdZdZ	ddd�Zedd���Zedd���Zedd���Zdd�Z	dS)�ResultaCHolds the captured result of an invoked CLI script.

    :param runner: The runner that created the result
    :param stdout_bytes: The standard output as bytes.
    :param stderr_bytes: The standard error as bytes.
    :param output_bytes: A mix of ``stdout_bytes`` and ``stderr_bytes``, as the
        user would see  it in its terminal.
    :param return_value: The value returned from the invoked command.
    :param exit_code: The exit code as integer.
    :param exception: The exception that happened if one did.
    :param exc_info: Exception information (exception type, exception instance,
        traceback type).

    .. versionchanged:: 8.2
        ``stderr_bytes`` no longer optional, ``output_bytes`` introduced and
        ``mix_stderr`` has been removed.

    .. versionadded:: 8.0
        Added ``return_value``.
    N�runner�	CliRunner�stdout_bytesr$�stderr_bytes�output_bytes�return_valuer�	exit_coder*�	exception�BaseException | None�exc_info�?tuple[type[BaseException], BaseException, TracebackType] | Nonec	�v�||_||_||_||_||_||_||_||_dSr �r�r�r�r�r�r�r�r�)	rr�r�r�r�r�r�r�r�s	         rrzResult.__init__�sD�����(���(���(���(���"���"��� ��
�
�
rrrc�t�|j�|jjd���dd��S)aThe terminal output as unicode string, as the user would see it.

        .. versionchanged:: 8.2
            No longer a proxy for ``self.stdout``. Now has its own independent stream
            that is mixing `<stdout>` and `<stderr>`, in the order they were written.
        �replace�
�
)r��decoder�rur�r;s rrz
Result.output�s9��� �'�'���(;�Y�G�G�O�O��D�
�
�	
rc�t�|j�|jjd���dd��S)z&The standard output as unicode string.r�r�r�)r�r�r�rur�r;s rrbz
Result.stdout�s9��� �'�'���(;�Y�G�G�O�O��D�
�
�	
rc�t�|j�|jjd���dd��S)z�The standard error as unicode string.

        .. versionchanged:: 8.2
            No longer raise an exception, always returns the `<stderr>` string.
        r�r�r�)r�r�r�rur�r;s rrcz
Result.stderr�s9��� �'�'���(;�Y�G�G�O�O��D�
�
�	
rc�r�|jrt|j��nd}dt|��j�d|�d�S)N�okay�<� �>)r�rC�typerF)r�exc_strs  rrDzResult.__repr__�s?��*.�.�D�$�t�~�&�&�&�f��3�4��:�:�&�3�3��3�3�3�3rr )r�r�r�r$r�r$r�r$r�rr�r*r�r�r�r�rE)
rFrGrHrZrrsrrbrcrDr5rrrr�s���������>�!�!�!�!�!�*�	
�	
�	
��X�	
��
�
�
��X�
��
�
�
��X�
�4�4�4�4�4�4rrc��eZdZdZ				d&d'd�Zd(d�Z	d)d*d�Zej			d+d,d���Z						d-d.d!�Z
ej	d)d/d%���ZdS)0r�a�The CLI runner provides functionality to invoke a Click command line
    script for unittesting purposes in a isolated environment.  This only
    works in single-threaded systems without any concurrency as it changes the
    global interpreter state.

    :param charset: the character set for the input and output data.
    :param env: a dictionary with environment variables for overriding.
    :param echo_stdin: if this is set to `True`, then reading from `<stdin>` writes
                       to `<stdout>`.  This is useful for showing examples in
                       some circumstances.  Note that regular prompts
                       will automatically echo the input.
    :param catch_exceptions: Whether to catch any exceptions other than
                             ``SystemExit`` when running :meth:`~CliRunner.invoke`.

    .. versionchanged:: 8.2
        Added the ``catch_exceptions`` parameter.

    .. versionchanged:: 8.2
        ``mix_stderr`` parameter has been removed.
    �utf-8NFTrur�env�$cabc.Mapping[str, str | None] | None�
echo_stdin�bool�catch_exceptionsrrc�B�||_|pi|_||_||_dSr )rur�r�r�)rrur�r�r�s     rrzCliRunner.__init__�s+�����25�)����$��� 0����r�clirc��|jpdS)z�Given a command object it will return the default program name
        for it.  The default is the `name` attribute or ``"root"`` if not
        set.
        �root)rj)rr�s  r�get_default_prog_namezCliRunner.get_default_prog_names��
�x�!�6�!r�	overrides�cabc.Mapping[str, str | None]c�\�t|j��}|r|�|��|S)z8Returns the environment overrides for invoking a script.)�dictr��update)rr�r#s   r�make_envzCliRunner.make_envs0���$�(�^�^���	!��I�I�i� � � ��	rrrt�color�8cabc.Iterator[tuple[io.BytesIO, io.BytesIO, io.BytesIO]]c#���K�t||j��}d}tj}tj}tj}tj}	dt_|�|��}t��}
|j
r4tjtj
t||
j����x}}t||jdd���xt_�|j
rd�_t|
j|jdd���t_t|
j|jd	dd
���t_t#|��dd�fd�
��}t#|��dd�fd�
��}t#|��dd���}
|�	dd�fd�
}t$j}t$j}t$j}t,j}t0j}|t$_|t$_|
t$_|t,_|t0_i}	|���D]W\}}t4j�|��||<|�	t4j|=�8#t:$rY�DwxYw|t4j|<�X|
j|
j|
jfV�|���D]5\}}|�	t4j|=�#t:$rY�"wxYw|t4j|<�6|t_|t_|t_|t$_|t$_|t$_|t,_|t0_|	t_dS#|���D]5\}}|�	t4j|=�#t:$rY�"wxYw|t4j|<�6|t_|t_|t_|t$_|t$_|t$_|t,_|t0_|	t_wxYw)a\A context manager that sets up the isolation for invoking of a
        command line tool.  This sets up `<stdin>` with the given input data
        and `os.environ` with the overrides from the given dictionary.
        This also rebinds some internals in Click to be mocked (like the
        prompt functionality).

        This is automatically done in the :meth:`invoke` method.

        :param input: the input stream to put into `sys.stdin`.
        :param env: the environment overrides as dictionary.
        :param color: whether the output should contain color codes. The
                      application can still override this explicitly.

        .. versionadded:: 8.2
            An additional output stream is returned, which is a mix of
            `<stdout>` and `<stderr>` streams.

        .. versionchanged:: 8.2
            Always returns the `<stderr>` stream.

        .. versionchanged:: 8.0
            `<stderr>` is opened with ``errors="backslashreplace"``
            instead of the default ``"strict"``.

        .. versionchanged:: 4.0
            Added the ``color`` parameter.
        N�Pz<stdin>�r)�encodingrjrkrz<stdout>�wz<stderr>�backslashreplace)r�rjrk�errors�prompt�
str | Nonerrc�T��tj�|pd��	t����d��}n!#t
$r}t
��|�d}~wwxYwtj�|�d���tj���|S)N�r�r�)�sysrbr&�next�rstrip�
StopIteration�EOFErrorrV)r��val�e�
text_inputs   �r�
visible_inputz*CliRunner.isolation.<locals>.visible_input`s�����J���V�\�r�*�*�*�
(��:�&�&�-�-�f�5�5���� �
(�
(�
(��j�j�a�'�����
(�����J����Z�Z�Z�(�(�(��J�������Js�"A�
A%�A � A%c���tj�|pd�d���tj���	t	����d��S#t$r}t��|�d}~wwxYw)Nr�r�r�)r�rbr&rVr�r�r�r�)r�r�r�s  �r�hidden_inputz)CliRunner.isolation.<locals>.hidden_inputks�����J�����"�0�0�0�1�1�1��J������
(��J�'�'�.�.�v�6�6�6�� �
(�
(�
(��j�j�a�'�����
(���s�!A'�'
B�1B�B�echor�c���tj�d��}|rtj�|��tj���|S)Nr)r��stdinr,rbr&rV)r��chars  r�_getcharz%CliRunner.isolation.<locals>._getchartsL���9�>�>�!�$�$�D��
'��
� � ��&�&�&��J�������KrrI�t.IO[t.Any] | Noner��bool | Nonec���|��S|Sr r5)rIr��
default_colors  �r�should_strip_ansiz.CliRunner.isolation.<locals>.should_strip_ansi�s����}�(�(�(��9�rr )r�r�rr)r�r�rr)NN)rIr�r�r�rr�)r}rur�r�rbrcr�FORCED_WIDTHr�r^r�rxry�BinaryIOrrh�_CHUNK_SIZErMr�visible_prompt_func�hidden_prompt_funcr�r	r�r�items�os�environ�get�	Exceptionr)rrr�r��bytes_input�
echo_input�	old_stdin�
old_stdout�
old_stderr�old_forced_width�stream_mixerr�r�r�r��old_visible_prompt_func�old_hidden_prompt_func�old__getchar_func�old_should_strip_ansi�old__compat_should_strip_ansi�old_env�key�valuer�r�s                       @@r�	isolationzCliRunner.isolations=������D(��t�|�<�<���
��I�	��Z�
��Z�
�%�2��"$�
���m�m�C� � ��"�}�}���?�	�'(�v��
�L��l�6I�J�J�(�(�
�K�*�"5��$�,�Y�S�"
�"
�"
�	
��	�J��?�	'�&'�J�"�(���$�,�Z�c�
�
�
��
�)����\���%�
�
�
��
�
�Z�	 �	 �	�	�	�	�	�	�
!�	 �	�
�Z�	 �	 �	(�	(�	(�	(�	(�	(�
!�	 �	(�
�Z�	 �	 �	�	�	�
!�	 �	��
�EI�	�	�	�	�	�	�	�#)�"<��!'�!:��"�O�� %� 7��(/�(A�%�%2��"�$0��!�"���"3���$5��!���	7�!�i�i�k�k�
,�
,�
��U�!�z�~�~�c�2�2�����=���J�s�O�O��$����������',�B�J�s�O�O��&��(;�\�=P�Q�Q�Q�Q�%�m�m�o�o�
,�
,�
��U��=���J�s�O�O��$����������',�B�J�s�O�O�#�C�J�#�C�J�!�C�I�)@�F�&�(>�F�%�/�F�O�&;�E�#�(E�G�%�&6�J�#�#�#��!&�m�m�o�o�
,�
,�
��U��=���J�s�O�O��$����������',�B�J�s�O�O�#�C�J�#�C�J�!�C�I�)@�F�&�(>�F�%�/�F�O�&;�E�#�(E�G�%�&6�J�#�6�6�6�6sg�
=M�
I�M�
I&�#M�%I&�&)M�+
J9�9
K�K�O?�$
M2�1O?�2
M?	�<O?�>M?	�?BO?�args�str | cabc.Sequence[str] | Noner��extrarrc
��d}|�|j}|�|||���5}	d}
d}d}t|t��rt	j|��}	|�d��}
n%#t$r|�|��}
YnwxYw	|j	d|pd|
d�|��}
n�#t$r�}tj��}tjd|j��}|�d}|dkr|}t|t ��sMtj�t|����tj�d��d	}|}Yd}~n4d}~wt&$r$}|s�|}d	}tj��}Yd}~nd}~wwxYwtj���tj���|	d���}|	d	���}|	d
���}n�#tj���tj���|	d���}|	d	���}|	d
���}wxYw	ddd��n#1swxYwYt/|||||
|||���S)a{Invokes a command in an isolated environment.  The arguments are
        forwarded directly to the command line script, the `extra` keyword
        arguments are passed to the :meth:`~clickpkg.Command.main` function of
        the command.

        This returns a :class:`Result` object.

        :param cli: the command to invoke
        :param args: the arguments to invoke. It may be given as an iterable
                     or a string. When given as string it will be interpreted
                     as a Unix shell command. More details at
                     :func:`shlex.split`.
        :param input: the input data for `sys.stdin`.
        :param env: the environment overrides.
        :param catch_exceptions: Whether to catch any other exceptions than
                                 ``SystemExit``. If :data:`None`, the value
                                 from :class:`CliRunner` is used.
        :param extra: the keyword arguments to pass to :meth:`main`.
        :param color: whether the output should contain color codes. The
                      application can still override this explicitly.

        .. versionadded:: 8.2
            The result object has the ``output_bytes`` attribute with
            the mix of ``stdout_bytes`` and ``stderr_bytes``, as the user would
            see it in its terminal.

        .. versionchanged:: 8.2
            The result object always returns the ``stderr_bytes`` stream.

        .. versionchanged:: 8.0
            The result object has the ``return_value`` attribute with
            the value returned from the invoked command.

        .. versionchanged:: 4.0
            Added the ``color`` parameter.

        .. versionchanged:: 3.0
            Added the ``catch_exceptions`` parameter.

        .. versionchanged:: 3.0
            The result object has the ``exc_info`` attribute with the
            traceback if available.
        N)rr�r�r�	prog_namer5)r�r�zint | t.Any | Noner�r�r�)r�r�r{r�shlex�split�pop�KeyErrorr��main�
SystemExitr�r�rxry�coder*rbr&r�rVrc�getvaluer)rr�r�rr�r�r�r�r��
outstreamsr�r�r�r�r��e_coderbrcrs                   r�invokezCliRunner.invoke�s+��j���#�#�4��
�^�^�%�S��^�
>�
>�+	2�*��L�.2�I��I��$��$�$�
)��{�4�(�(��
<�!�I�I�k�2�2�	�	���
<�
<�
<� �6�6�s�;�;�	�	�	�
<����
2�'�s�x�V�T�Z�R�9�V�V�PU�V�V�����
#�
#�
#��<�>�>���� 4�a�f�=�=���>��F��Q�;�;� !�I�!�&�#�.�.���J�$�$�S��[�[�1�1�1��J�$�$�T�*�*�*��F�"�	�	�	�	�	�	������
*�
*�
*�'����	��	��<�>�>�����������
*�����
� � �"�"�"��
� � �"�"�"�#�A��/�/�1�1��#�A��/�/�1�1��#�A��/�/�1�1����	�
� � �"�"�"��
� � �"�"�"�#�A��/�/�1�1��#�A��/�/�1�1��#�A��/�/�1�1��1�1�1�1��W+	2�+	2�+	2�+	2�+	2�+	2�+	2�+	2�+	2�+	2�+	2����+	2�+	2�+	2�+	2�Z�����%����	
�	
�	
�		
s��0J+�A+�*J+�+B
�
J+�B
�
J+�B$�#H�$
F�.BE�H�
F�E<�7H�<F�H�BJ+�BJ�J+�+J/�2J/�temp_dir�str | os.PathLike[str] | None�cabc.Iterator[str]c#�K�tj��}tj|���}tj|��	|V�tj|��|�-ddl}	|�|��dS#t$rYdSwxYwdS#tj|��|�+ddl}	|�|��w#t$rYwwxYwwxYw)a�A context manager that creates a temporary directory and
        changes the current working directory to it. This isolates tests
        that affect the contents of the CWD to prevent them from
        interfering with each other.

        :param temp_dir: Create the temporary directory under this
            directory. If given, the created directory is not removed
            when exiting.

        .. versionchanged:: 8.0
            Added the ``temp_dir`` parameter.
        )�dirNr)r��getcwd�tempfile�mkdtemp�chdir�shutil�rmtree�OSError)rr��cwd�dtrs     r�isolated_filesystemzCliRunner.isolated_filesystem"s���� �i�k�k��
�
�(�
+�
+�
+��
������	��H�H�H��H�S�M�M�M����
�
�
���M�M�"�%�%�%�%�%�������D�D����� ���
�H�S�M�M�M����
�
�
���M�M�"�%�%�%�%�������D����� ���sB�B	�A6�6
B�B�	C�%B;�:C�;
C�C�C�C)r�NFT)
rurr�r�r�r�r�r�rr)r�rrrr )r�r�rr�)NNF)rrtr�r�r�r�rr�)NNNNF)r�rr�r�rrtr�r�r�r�r�r�r�rrr)r�r�rr�)rFrGrHrZrr�r��
contextlib�contextmanagerr�r�rr5rrr�r��s��������.�48� �!%�
1�
1�
1�
1�
1�"�"�"�"�AE��������37�48��	W7�W7�W7�W7���W7�x15�26�48�(,��o
�o
�o
�o
�o
�b��8<���������rr�)rIrJrrK)rrtrurrr)%�
__future__r�collections.abc�abc�cabcr	r`r�r�r�r�typingrx�typesrr�rrrr	r
�
TYPE_CHECKING�	_typeshedr�corerrr
rMrarOr^�
TextIOWrapperrhr}rr�r5rr�<module>rsW��"�"�"�"�"�"�����������	�	�	�	�	�	�	�	�����
�
�
�
���������������������������������������(�(�(�(�(�(��?��(�(�(�(�(�(�������!�!�!�!�!�!�!�!�D�������� � � � � �"�*� � � �&��������4�����"�*����"����(K4�K4�K4�K4�K4�K4�K4�K4�\\�\�\�\�\�\�\�\�\�\r