AlkantarClanX12

Your IP : 3.145.68.167


Current Path : /opt/imunify360/venv/lib/python3.11/site-packages/click/__pycache__/
Upload File :
Current File : //opt/imunify360/venv/lib/python3.11/site-packages/click/__pycache__/testing.cpython-311.pyc

�

j��f�>����ddlZddlZddlZddlZddlZddlZddlZddlZddl	m
Z
ddlmZddlm
Z
ddlmZddlmZejrddlmZGd	�d
��Zejdejedejdfd
���ZGd�dej��Zdejejeeejejfdedej fd�Z!Gd�d��Z"Gd�d��Z#dS)�N)�
TracebackType�)�
formatting)�termui)�utils)�_find_binary_reader)�BaseCommandc���eZdZdejdejddfd�Zdedejfd�Zde	de	fd	�Z
ddede	fd�Zddede	fd
�Z
ddede	fd�Zdeje	fd�Zdeje	fd�Zdefd�ZdS)�EchoingStdin�input�output�returnNc�0�||_||_d|_dS)NF)�_input�_output�_paused)�selfrr
s   �m/builddir/build/BUILD/imunify360-venv-2.3.5/opt/imunify360/venv/lib/python3.11/site-packages/click/testing.py�__init__zEchoingStdin.__init__s��������������xc�,�t|j|��S�N)�getattrr)rrs  r�__getattr__zEchoingStdin.__getattr__s���t�{�A�&�&�&r�rvc�H�|js|j�|��|Sr)rr�write)rrs  r�_echozEchoingStdin._echos'���|�	#��L���r�"�"�"��	r����nc�\�|�|j�|����Sr)rr�read�rr!s  rr#zEchoingStdin.read#s$���z�z�$�+�*�*�1�-�-�.�.�.rc�\�|�|j�|����Sr)rr�read1r$s  rr&zEchoingStdin.read1&s$���z�z�$�+�+�+�A�.�.�/�/�/rc�\�|�|j�|����Sr)rr�readliner$s  rr(zEchoingStdin.readline)s$���z�z�$�+�.�.�q�1�1�2�2�2rc�N���fd��j���D��S)Nc�:��g|]}��|����S��r��.0rrs  �r�
<listcomp>z*EchoingStdin.readlines.<locals>.<listcomp>-s#���?�?�?�!��
�
�1�
�
�?�?�?r)r�	readlines�rs`rr0zEchoingStdin.readlines,s+���?�?�?�?�t�{�'<�'<�'>�'>�?�?�?�?rc�D��t�fd��jD����S)Nc3�B�K�|]}��|��V��dSrr,r-s  �r�	<genexpr>z(EchoingStdin.__iter__.<locals>.<genexpr>0s-�����7�7�a�D�J�J�q�M�M�7�7�7�7�7�7r)�iterrr1s`r�__iter__zEchoingStdin.__iter__/s(����7�7�7�7�4�;�7�7�7�7�7�7rc�*�t|j��Sr)�reprrr1s r�__repr__zEchoingStdin.__repr__2s���D�K� � � r)r )�__name__�
__module__�__qualname__�t�BinaryIOr�str�Anyr�bytesr�intr#r&r(�Listr0�Iteratorr6r9r+rrrrs_�������a�j��!�*�������
'�S�'�Q�U�'�'�'�'����%�����/�/�c�/�5�/�/�/�/�0�0�s�0�E�0�0�0�0�3�3�#�3�u�3�3�3�3�@�1�6�%�=�@�@�@�@�8�!�*�U�+�8�8�8�8�!�#�!�!�!�!�!�!rr�streamrc#�>K�|�dV�dSd|_dV�d|_dS)NTF)r)rEs r�_pause_echorG6s3����
�~�
���������
��������rc
���eZdZdejdededejddf
�fd�Zedefd���Z	edefd	���Z
�xZS)
�_NamedTextIOWrapper�buffer�name�mode�kwargsrNc�X��t��j|fi|��||_||_dSr)�superr�_name�_mode)rrJrKrLrM�	__class__s     �rrz_NamedTextIOWrapper.__init__As6���	������*�*�6�*�*�*���
���
�
�
rc��|jSr)rPr1s rrKz_NamedTextIOWrapper.nameH�
���z�rc��|jSr)rQr1s rrLz_NamedTextIOWrapper.modeLrTr)r:r;r<r=r>r?r@r�propertyrKrL�
__classcell__)rRs@rrIrI@s����������j��(+��36��BC�%��	
���������c�����X����c�����X�����rrIr�charsetc�F�t|d��rOttjtjtj|����}|�|St
d���|�d}n*t|t��r|�	|��}tj|��S)Nr#z.Could not find binary reader for input stream.r)�hasattrrr=�cast�IOr@�	TypeError�
isinstancer?�encode�io�BytesIO)rrXrs   r�make_input_streamrbQs����u�f���J�
 �����Q�U��U�!;�!;�
<�
<��
�>��I��H�I�I�I��}����	�E�3�	�	�&����W�%�%��
�:�e���rc��eZdZdZ	ddddedejedejded	eje	d
ejej
eje	e	effd�Z
edefd
���Zedefd���Zedefd���Zdefd�ZdS)�Resultz3Holds the captured result of an invoked CLI script.N�runner�	CliRunner�stdout_bytes�stderr_bytes�return_value�	exit_code�	exception�exc_infoc�h�||_||_||_||_||_||_||_dSr�rergrhrirjrkrl)rrergrhrirjrkrls        rrzResult.__init__hs>�����(���(���)���"���"��� ��
�
�
rrc��|jS)z(The (standard) output as unicode string.)�stdoutr1s rr
z
Result.output�s���{�rc�t�|j�|jjd���dd��S)z&The standard output as unicode string.�replace�
�
)rg�decodererXrrr1s rrpz
Result.stdout�s9��� �'�'���(;�Y�G�G�O�O��D�
�
�	
rc��|j�td���|j�|jjd���dd��S)z%The standard error as unicode string.Nzstderr not separately capturedrrrsrt)rh�
ValueErrorrurerXrrr1s r�stderrz
Result.stderr�sQ����$��=�>�>�>�� �'�'���(;�Y�G�G�O�O��D�
�
�	
rc�r�|jrt|j��nd}dt|��j�d|�d�S)N�okay�<� �>)rkr8�typer:)r�exc_strs  rr9zResult.__repr__�s?��*.�.�D�$�t�~�&�&�&�f��3�4��:�:�&�3�3��3�3�3�3rr)r:r;r<�__doc__rAr=�Optionalr@rB�
BaseException�Tuple�TyperrrVr?r
rprxr9r+rrrdrdes;������=�=�
�!�!��!��!��j��'�	!�
�e�!��
!��:�m�,�!��*�
�G�A�F�=�)�=�-�G�H�
�!�!�!�!�:�������X���
��
�
�
��X�
��
��
�
�
��X�
�4�#�4�4�4�4�4�4rrdc���eZdZdZ				ddedejejeejefded	ed
df
d�Z	dd
d
efd�Z
	ddejejeejefd
ejeejeffd�Zej
			ddejejeeejejfdejejeejefded
ejejejejejffd���Z					ddd
dejejeejefdejejeeejejfdejejeejefdededejd
efd�Zej
	ddejejedfd
ejefd���ZdS)rfa�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 mix_stderr: if this is set to `False`, then stdout and stderr are
                       preserved as independent streams.  This is useful for
                       Unix-philosophy apps that have predictable stdout and
                       noisy stderr, such that each may be measured
                       independently
    �utf-8NFTrX�env�
echo_stdin�
mix_stderrrc�B�||_|pi|_||_||_dSr)rXr�r�r�)rrXr�r�r�s     rrzCliRunner.__init__�s(�����47�I�2���$���$����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)rK)rr�s  r�get_default_prog_namezCliRunner.get_default_prog_name�s��
�x�!�6�!r�	overridesc�\�t|j��}|r|�|��|S)z8Returns the environment overrides for invoking a script.)�dictr��update)rr�rs   r�make_envzCliRunner.make_env�s0���$�(�^�^���	!��I�I�i� � � ��	rr�colorc#���K�t||j��}d}tj}tj}tj}tj}	dt_|�|��}tj
��}
|jr/tj
tjt||
����x}}t!||jdd���xt_�|jrd�_t!|
|jdd���t_d}|jrtjt_n6tj
��}t!||jd	dd
���t_t'|��ddtjt*d
t*f�fd�
��}t'|��ddtjt*d
t*f�fd�
��}
t'|��dt,d
t*fd���}|�	ddtjtjtjdtjt,d
t,f�fd�
}t2j}t2j}t2j}t:j}|t2_|
t2_|t2_|t:_i}	|���D]W\}}t@j!�"|��||<|�	t@j!|=�8#tF$rY�DwxYw|t@j!|<�X|
|fV�|���D]5\}}|�	t@j!|=�#tF$rY�"wxYw|t@j!|<�6|t_|t_|t_|t2_|t2_|t2_|t:_|	t_dS#|���D]5\}}|�	t@j!|=�#tF$rY�"wxYw|t@j!|<�6|t_|t_|t_|t2_|t2_|t2_|t:_|	t_wxYw)anA 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.

        .. 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)�encodingrKrLrz<stdout>�wz<stderr>�backslashreplace)r�rKrL�errors�promptrc���tj�|pd�������d��}tj�|�d���tj���|S)N�rsrt)�sysrprr(�rstrip�flush)r��val�
text_inputs  �r�
visible_inputz*CliRunner.isolation.<locals>.visible_inputsq����J���V�\�r�*�*�*��%�%�'�'�.�.�v�6�6�C��J����Z�Z�Z�(�(�(��J�������Jrc����tj�|pd�d���tj��������d��S)Nr�rtrs)r�rprr�r(r�)r�r�s �r�hidden_inputz)CliRunner.isolation.<locals>.hidden_inputsZ����J�����"�0�0�0�1�1�1��J�������&�&�(�(�/�/��7�7�7r�echoc���tj�d��}|rtj�|��tj���|S)Nr)r��stdinr#rprr�)r��chars  r�_getcharz%CliRunner.isolation.<locals>._getchar#sL���9�>�>�!�$�$�D��
'��
� � ��&�&�&��J�������KrrEr�c���|��S|Srr+)rEr��
default_colors  �r�should_strip_ansiz.CliRunner.isolation.<locals>.should_strip_ansi/s����}�(�(�(��9�rr)NN)$rbrXr�r�rprxr�FORCED_WIDTHr�r`rar�r=r[r>rrI�_CHUNK_SIZEr�rGr�r?�boolr\r@r�visible_prompt_func�hidden_prompt_funcr�rr��items�os�environ�get�	Exception)rrr�r��bytes_input�
echo_input�	old_stdin�
old_stdout�
old_stderr�old_forced_width�bytes_output�bytes_errorr�r�r�r��old_visible_prompt_func�old_hidden_prompt_func�old__getchar_func�old_should_strip_ansi�old_env�key�valuer�r�s                       @@r�	isolationzCliRunner.isolation�s�������6(��t�|�<�<���
��I�	��Z�
��Z�
�%�2��"$�
���m�m�C� � ���z�|�|���?�	�'(�v��
�L��l�C�C�(�(�
�K�*�"5��$�,�Y�S�"
�"
�"
�	
��	�J��?�	'�&'�J�"�(��4�<�j�s�
�
�
��
����?�
	���C�J�J��*�,�,�K�,������)����C�J�
�Z�	 �	 �	�	�!�*�S�/�	�S�	�	�	�	�	�
!�	 �	�
�Z�	 �	 �	8�	8���C��	8�C�	8�	8�	8�	8�	8�
!�	 �	8�

�Z�	 �	 �	�4�	�C�	�	�	�
!�	 �	��
�OS�	�	��J�q�t�A�E�{�+�	�;<�:�d�;K�	�
�	�	�	�	�	�	�#)�"<��!'�!:��"�O�� %� 7��%2��"�$0��!�"���"3�����	7�!�i�i�k�k�
,�
,�
��U�!�z�~�~�c�2�2�����=���J�s�O�O��$����������',�B�J�s�O�O���-�-�-�-�%�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�#�&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�#�&6�J�#�6�6�6�6sg�2=O�0
K>�=O�>
L�O�
L�O�
M�
M�M�Q<�-
O;�:Q<�;
P	�Q<�P	�A4Q<�args�catch_exceptions�extrac	�0�d}|�|||���5}	d}
d}d}t|t��rtj|��}	|�d��}
n%#t$r|�|��}
YnwxYw	|jd|pd|
d�|��}
�n#t$r�}tj��}tj
tjtjt tjf|j��}|�d}|dkr|}t|t ��sMtj�t|����tj�d��d}|}Yd}~n4d}~wt*$r$}|s�|}d}tj��}Yd}~nd}~wwxYwtj���|	d���}|jrd}n||	d���}na#tj���|	d���}|jrd}n|	d���}wxYwddd��n#1swxYwYt3||||
|||�	��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``.
        :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.

        .. 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)rr�r�r�	prog_namer+)r�r�rtrrn)r�r^r?�shlex�split�pop�KeyErrorr��main�
SystemExitr�rlr=r[r��UnionrBr@�coderprr�r��getvaluer�rd)rr�r�rr�r�r�r�rl�
outstreamsrirkrjr��e�e_coderprxs                  r�invokezCliRunner.invoke]s���X��
�^�^�%�S��^�
>�
>�,	6�*��L�37�I��I��$��$�$�
)��{�4�(�(��
<�!�I�I�k�2�2�	�	���
<�
<�
<� �6�6�s�;�;�	�	�	�
<����
6�'�s�x�V�T�Z�R�9�V�V�PU�V�V�����
#�
#�
#��<�>�>�����
�1�7�3���:�+>� ?���H�H���>��F��Q�;�;� !�I�!�&�#�.�.���J�$�$�S��[�[�1�1�1��J�$�$�T�*�*�*��F�"�	�	�	�	�	�	������
*�
*�
*�'����	��	��<�>�>�����������
*�����
� � �"�"�"�#�A��/�/�1�1���?�6�!�F�F�'��]�3�3�5�5�F�F���
� � �"�"�"�#�A��/�/�1�1���?�6�!�F�F�'��]�3�3�5�5�F�5�5�5�5�Y,	6�,	6�,	6�,	6�,	6�,	6�,	6�,	6�,	6�,	6�,	6����,	6�,	6�,	6�,	6�\����%����
�
�
�	
s��0I7�A"�!I7�"B�I7�B�I7�B�H
�
F*�&CE9�4H
�9
F*�F%� H
�%F*�*H
�-AI7�
AI(�(I7�7I;�>I;�temp_dirzos.PathLike[str]c#�K�tj��}tj|���}tj|��	|V�tj|��|�(	tj|��dS#t$rYdSwxYwdS#tj|��|�&	tj|��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.
        )�dirN)r��getcwd�tempfile�mkdtemp�chdir�shutil�rmtree�OSError)rr��cwd�dts    r�isolated_filesystemzCliRunner.isolated_filesystem�s����� �i�k�k��
�
�(�
+�
+�
+��
������		��H�H�H��H�S�M�M�M�����M�"�%�%�%�%�%�������D�D����� ���
�H�S�M�M�M�����M�"�%�%�%�%�������D����� ���sB�B�A1�1
A?�>A?�C�B1�0C�1
B>�;C�=B>�>C)r�NFTr)NNF)NNNTF)r:r;r<r�r?r=r��Mappingr�rr�r��
contextlib�contextmanagerr�rAr\r@rDr�r`rar��Sequencerdr�r�r+rrrfrf�s���������(�;?� ��
%�
%��
%��Z��	�#�q�z�#��"6�7�
8�
%��	
%�
�
%�
�
%�
%�
%�
%�"��"�3�"�"�"�"�HL�����A�I�c�1�:�c�?�.B�$C�D��	
��3��
�3��'�	(�������?C�;?��	L7�L7��z�!�'�#�u�a�d�1�5�k�"9�:�;�L7��Z��	�#�q�z�#��"6�7�
8�L7��	L7�

��A�G�B�J��
�2�:�(>�>�?�	@�L7�L7�L7���L7�b;?�>B�;?�!%��c
�c
�
�c
��j����a�j��o�!5�6�7�c
��z�!�'�#�u�a�d�1�5�k�"9�:�;�	c
�
�Z��	�#�q�z�#��"6�7�
8�c
��
c
��c
���c
�
�c
�c
�c
�c
�J��GK����
�1�7�3�0B�+B�#C�D��	
��C���������rrf)$r�r`r�r�r�r�r��typingr=�typesrr�rrr�_compatr�
TYPE_CHECKING�corer	rr�r�rDrG�
TextIOWrapperrIr�r?rAr\r@r>rbrdrfr+rr�<module>r�s������	�	�	�	�	�	�	�	�����
�
�
�
�
�
�
�
���������������������������������(�(�(�(�(�(��?�"�!�!�!�!�!�!�!�!�!�!�!�!�!�!�D����
�<�0��Q�Z��5E������������"�*����"��:�a�g�c�5�!�$�q�u�+�5�6�7��BE���Z�����(74�74�74�74�74�74�74�74�t@�@�@�@�@�@�@�@�@�@r