%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__/testing.cpython-312.pyc

�

D�d�>���ddlZddlZddlZddlZddlZddlZddlZddlZddl	m
Z
ddlmZddlm
Z
ddlmZddlmZej"rddlmZGd	�d
�Zej*dej,edej.dfd
��ZGd�dej2�Zdej,ej6eeej<ej>fdedej@fd�Z!Gd�d�Z"Gd�d�Z#y)�N)�
TracebackType�)�
formatting)�termui)�utils)�_find_binary_reader)�BaseCommandc�
�eZdZdejdejddfd�Zdedejfd�Zde	de	fd	�Z
dd
ede	fd�Zdd
ede	fd�Z
dd
ede	fd
�Zdeje	fd�Zdej"e	fd�Zdefd�Zy)�EchoingStdin�input�output�returnNc�.�||_||_d|_y)NF)�_input�_output�_paused)�selfrr
s   �//usr/lib/python3/dist-packages/click/testing.py�__init__zEchoingStdin.__init__s������������xc�.�t|j|�S�N)�getattrr�rrs  r�__getattr__zEchoingStdin.__getattr__s���t�{�{�A�&�&r�rvc�T�|js|jj|�|Sr)rr�write)rrs  r�_echozEchoingStdin._echos ���|�|��L�L���r�"��	r�nc�V�|j|jj|��Sr)r r�read�rr!s  rr#zEchoingStdin.read#s ���z�z�$�+�+�*�*�1�-�.�.rc�V�|j|jj|��Sr)r r�read1r$s  rr&zEchoingStdin.read1&s ���z�z�$�+�+�+�+�A�.�/�/rc�V�|j|jj|��Sr)r r�readliner$s  rr(zEchoingStdin.readline)s ���z�z�$�+�+�.�.�q�1�2�2rc�z�|jj�D�cgc]}|j|���c}Scc}wr)r�	readlinesr rs  rr*zEchoingStdin.readlines,s+��'+�{�{�'<�'<�'>�?�!��
�
�1�
�?�?��?s�8c�@��t�fd��jD��S)Nc3�@�K�|]}�j|����y�wr)r )�.0rrs  �r�	<genexpr>z(EchoingStdin.__iter__.<locals>.<genexpr>0s�����7�a�D�J�J�q�M�7�s�)�iterr�rs`r�__iter__zEchoingStdin.__iter__/s����7�4�;�;�7�7�7rc�,�t|j�Sr)�reprrr0s r�__repr__zEchoingStdin.__repr__2s���D�K�K� � r)���)�__name__�
__module__�__qualname__�t�BinaryIOr�str�Anyr�bytesr �intr#r&r(�Listr*�Iteratorr1r4�rrrrs����a�j�j��!�*�*����
'�S�'�Q�U�U�'����%��/�c�/�5�/�0�s�0�E�0�3�#�3�u�3�@�1�6�6�%�=�@�8�!�*�*�U�+�8�!�#�!rr�streamrc#�>K�|�d��yd|_d��d|_y�w)NTF)r)rBs r�_pause_echorD6s����
�~�
����
����s�c
���eZdZdejdededejddf
�fd�Zedefd��Z	edefd	��Z
�xZS)
�_NamedTextIOWrapper�buffer�name�mode�kwargsrNc�B��t�|�|fi|��||_||_yr)�superr�_name�_mode)rrGrHrIrJ�	__class__s     �rrz_NamedTextIOWrapper.__init__As%���	����*�6�*���
���
rc��|jSr)rMr0s rrHz_NamedTextIOWrapper.nameH����z�z�rc��|jSr)rNr0s rrIz_NamedTextIOWrapper.modeLrQr)r6r7r8r9r:r;r<r�propertyrHrI�
__classcell__)rOs@rrFrF@sn�����j�j��(+��36��BC�%�%��	
����c������c���rrFr�charsetc�*�t|d�rMttjtjtj
|��}|�|St
d��|�d}n!t|t�r|j|�}tj|�S)Nr#z.Could not find binary reader for input stream.r)�hasattrrr9�cast�IOr<�	TypeError�
isinstancer;�encode�io�BytesIO)rrUrs   r�make_input_streamr_Qsv���u�f��
 �������Q�U�U��U�!;�
<��
�>��I��H�I�I��}���	�E�3�	����W�%��
�:�:�e��rc�"�eZdZdZ	ddddedejedejded	eje	d
ejejeje	e	effd�Z
edefd
��Zedefd��Zedefd��Zdefd�Zy)�Resultz3Holds the captured result of an invoked CLI script.N�runner�	CliRunner�stdout_bytes�stderr_bytes�return_value�	exit_code�	exception�exc_infoc�f�||_||_||_||_||_||_||_yr�rbrdrerfrgrhri)rrbrdrerfrgrhris        rrzResult.__init__hs:�����(���(���)���"���"��� ��
rrc��|jS)z(The (standard) output as unicode string.)�stdoutr0s rr
z
Result.output�s���{�{�rc��|jj|jjd�j	dd�S)z&The standard output as unicode string.�replace�
�
)rd�decoderbrUror0s rrmz
Result.stdout�s9��� � �'�'����(;�(;�Y�G�O�O��D�
�	
rc��|j�td��|jj|jjd�jdd�S)z%The standard error as unicode string.zstderr not separately capturedrorprq)re�
ValueErrorrrrbrUror0s r�stderrz
Result.stderr�sQ�����$��=�>�>�� � �'�'����(;�(;�Y�G�O�O��D�
�	
rc��|jrt|j�nd}dt|�j�d|�d�S)N�okay�<� �>)rhr3�typer6)r�exc_strs  rr4zResult.__repr__�s8��*.�.�.�$�t�~�~�&�f���4��:�&�&�'�q��	��3�3rr)r6r7r8�__doc__r=r9�Optionalr<r>�
BaseException�Tuple�TyperrrSr;r
rmrur4rArrraraes���=�
�!��!��!��j�j��'�	!�
�e�e�!��
!��:�:�m�,�!��*�*�
�G�G�A�F�F�=�)�=�-�G�H�
�!�:�������
��
��
��
��
��
�4�#�4rrac��eZdZdZ				ddedejejeejefdededdf
d�Z	d	d
defd�Z
	ddejejeejefdejeejeffd
�Zej			ddejejeeej ej"fdejejeejefdedej$ej&ej*ejej*ffd��Z					dd	d
dejejeej.efdejejeeej ej"fdejejeejefdededej"defd�Zej	ddejejedfdej$efd��Zy)rca�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
    NrU�env�
echo_stdin�
mix_stderrrc�D�||_|xsi|_||_||_yr)rUr�r�r�)rrUr�r�r�s     rrzCliRunner.__init__�s$�����47�I�2���$���$��r�clir	c�"�|jxsdS)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)rH)rr�s  r�get_default_prog_namezCliRunner.get_default_prog_name�s��
�x�x�!�6�!r�	overridesc�V�t|j�}|r|j|�|S)z8Returns the environment overrides for invoking a script.)�dictr��update)rr�rs   r�make_envzCliRunner.make_env�s%���$�(�(�^����I�I�i� ��	rr�colorc#�0	��K�t||j�}d}tj}tj}tj
}tj}	dt_|j|�}tj�}
|jr0tjtjt||
��x}}t!||jdd��xt_�|jrd�_t!|
|jdd��t_d}|j$rtjt_n7tj�}t!||jd	dd
��t_t'|�ddtj(t*d
t*f�fd�
�}t'|�ddtj(t*d
t*f�fd�
�}
t'|�dt,d
t*fd��}|�	ddtj(tj.tj0dtj(t,d
t,f�fd�
}t2j4}t2j6}t2j8}t:j<}|t2_|
t2_|t2_|t:_i}	|j?�D]O\}}t@jBjE|�||<|�	t@jB|=�=|t@jB|<�Q|
|f��|j?�D]-\}}|�	t@jB|=�|t@jB|<�/|t_|t_|t_|t2_|t2_|t2_|t:_|	t_y#tF$rY��wxYw#tF$rY��wxYw#|j?�D]<\}}|�"	t@jB|=�#tF$rY�&wxYw|t@jB|<�>|t_|t_|t_|t2_|t2_|t2_|t:_|	t_wxYw�w)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)�encodingrHrIrz<stdout>�wz<stderr>�backslashreplace)r�rHrI�errors�promptrc���tjj|xsd��j�j	d�}tjj|�d��tjj�|S)N�rprq)�sysrmrr(�rstrip�flush)r��val�
text_inputs  �r�
visible_inputz*CliRunner.isolation.<locals>.visible_inputs_����J�J���V�\�r�*��%�%�'�.�.�v�6�C��J�J����u�B�Z�(��J�J�����Jrc����tjj|xsd�d��tjj��j	�jd�S)Nr�rqrp)r�rmrr�r(r�)r�r�s �r�hidden_inputz)CliRunner.isolation.<locals>.hidden_inputsJ����J�J�����"�~�R�0�1��J�J�����&�&�(�/�/��7�7r�echoc���tjjd�}|rtjj	|�tjj�|S)Nr)r��stdinr#rmrr�)r��chars  r�_getcharz%CliRunner.isolation.<locals>._getchar#s>���9�9�>�>�!�$�D���
�
� � ��&��J�J�����KrrBr�c���|��S|SrrA)rBr��
default_colors  �r�should_strip_ansiz.CliRunner.isolation.<locals>.should_strip_ansi/s����}�(�(�(��9�rr)NN)$r_rUr�r�rmrur�FORCED_WIDTHr�r]r^r�r9rXr:rrF�_CHUNK_SIZEr�rDr~r;�boolrYr<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�I�	��Z�Z�
��Z�Z�
�%�2�2��"$�
���m�m�C� ���z�z�|���?�?�'(�v�v��
�
�L��l�C�(�
�K�*�"5��$�,�,�Y�S�"
�	
��	�J��?�?�&'�J�"�(��4�<�<�j�s�
��
����?�?����C�J��*�*�,�K�,�������)��C�J�
�Z�	 �	�!�*�*�S�/�	�S�	�
!�	�
�Z�	 �	8����C��	8�C�	8�
!�	8�

�Z�	 �	�4�	�C�	�
!�	��
�OS�	��J�J�q�t�t�A�E�E�{�+�	�;<�:�:�d�;K�	�
�	�#)�"<�"<��!'�!:�!:��"�O�O�� %� 7� 7��%2��"�$0��!�"���"3�����	7�!�i�i�k�
,�
��U�!�z�z�~�~�c�2�����=���J�J�s�O�',�B�J�J�s�O�
,� ��-�-�%�m�m�o�
,�
��U��=���J�J�s�O�',�B�J�J�s�O�
,�$�C�J�#�C�J�!�C�I�)@�F�&�(>�F�%�/�F�O�&;�E�#�&6�J�#��+%�����%�����	&�m�m�o�
,�
��U��=���J�J�s�O��$�����',�B�J�J�s�O�
,�$�C�J�#�C�J�!�C�I�)@�F�&�(>�F�%�/�F�O�&;�E�#�&6�J�#�s��KR�:O*�O�O*�3R�O�A/R�	O�O*�O�O*�	O'�$R�&O'�'R�*R�P�R�	P"	�R�!P"	�"A1R�R�args�catch_exceptions�extrac	���d}|j|||��5}	d}
d}d}t|t�rtj|�}	|jd�}
	|jd|xsd|
d�|��}
tj&j-�|	dj/�}|j0rd}n|	dj/�}	ddd�t3|
|�	�S#t$r|j|�}
Y��wxYw#t$r�}tj�}tjtjtjt tj"f|j$�}|�d}|dk7r|}t|t �sItj&j)t|��tj&j)d�d}|}Yd}~��md}~wt*$r&}|s�|}d}tj�}Yd}~���d}~wwxYw#tj&j-�|	dj/�}|j0rd}w|	dj/�}wxYw#1swY���xYw)
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_namerA)r�r�rqrrk)r�r[r;�shlex�split�pop�KeyErrorr��main�
SystemExitr�rir9rXr~�Unionr>r<�codermrr�r��getvaluer�ra)rr�r�rr�r�r�r�ri�
outstreamsrfrhrgr��e�e_codermrus                  r�invokezCliRunner.invoke]s��X��
�^�^�%�S��^�
>�,	6�*��L�37�I��I��$��$��{�{�4�(��
<�!�I�I�k�2�	�
6�'�s�x�x�V�T�Z�R�9�V�PU�V��2�
�
� � �"�#�A��/�/�1���?�?�!�F�'��]�3�3�5�F�Y,	6�\����%����
�	
��I�
<� �6�6�s�;�	�
<��
�
#��<�<�>������
�
�1�7�7�3����:�+>� ?����H���>��F��Q�;� !�I�!�&�#�.��J�J�$�$�S��[�1��J�J�$�$�T�*��F�"�	���
*�'���	��	��<�<�>���
*���
�
� � �"�#�A��/�/�1���?�?�!�F�'��]�3�3�5�F��Y,	6�,	6�st�,I)�C�C=�/AI)�C:�7I)�9C:�:I)�=	H�CG�H�H�(H	�H�	H�H�AI&�&I)�)I3�temp_dirzos.PathLike[str]c#�K�tj�}tj|��}tj|�	|��tj|�|�	tj|�yy#t$rYywxYw#tj|�|�&	tj|�w#t$rYwwxYwwxYw�w)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�i�k��
�
�
�(�
+��
�����		��H��H�H�S�M�����M�M�"�%� �������
�H�H�S�M�����M�M�"�%������� �sf�AC�B�C�A6�4C�6	B�?C�B�C�C�B4�3C�4	C�=C�?C�C�C)zutf-8NFTr)NNF)NNNTF)r6r7r8r}r;r9r~�Mappingr�rr�r��
contextlib�contextmanagerr�r=rYr<r@r�r]r^r��Sequencerar�r�rArrrcrc�s����(�;?� ��
%��
%��Z�Z��	�	�#�q�z�z�#��"6�7�
8�
%��	
%�
�
%�
�
%�"��"�3�"�HL�����A�I�I�c�1�:�:�c�?�.B�$C�D��	
���3��
�
�3��'�	(�����?C�;?��	L7��z�z�!�'�'�#�u�a�d�d�1�5�5�k�"9�:�;�L7��Z�Z��	�	�#�q�z�z�#��"6�7�
8�L7��	L7�

���A�G�G�B�J�J��
�
�2�:�:�(>�>�?�	@�L7��L7�b;?�>B�;?�!%��c
�
�c
��j�j�����a�j�j��o�!5�6�7�c
��z�z�!�'�'�#�u�a�d�d�1�5�5�k�"9�:�;�	c
�
�Z�Z��	�	�#�q�z�z�#��"6�7�
8�c
��
c
��c
����c
�
�c
�J���GK���
�
�1�7�7�3�0B�+B�#C�D��	
���C����rrc)$r�r]r�r�r�r�r��typingr9�typesrr�rrr�_compatr�
TYPE_CHECKING�corer	rr�r~r@rD�
TextIOWrapperrFr�r;r=rYr<r:r_rarcrArr�<module>r�s����	�	��
�
�������(��?�?�!�!�!�D�����
�
�<�0��Q�Z�Z��5E�����"�*�*��"��:�:�a�g�g�c�5�!�$�$�q�u�u�+�5�6�7��BE���Z�Z��(74�74�t@�@r

Zerion Mini Shell 1.0