HEX
Server: LiteSpeed
System: Linux us-phx-web1284.main-hosting.eu 4.18.0-553.109.1.lve.el8.x86_64 #1 SMP Thu Mar 5 20:23:46 UTC 2026 x86_64
User: u300739242 (300739242)
PHP: 8.2.30
Disabled: system, 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/python37/lib/python3.7/site-packages/click/__pycache__/testing.cpython-37.pyc
B

�P�e�>�@sddlZddlZddlZddlZddlZddlZddlZddlZddl	m
Z
ddlmZddlm
Z
ddlmZddlmZejr�ddlmZGd	d
�d
�Zejejeejdd�dd
��ZGdd�dej�Zejejeeejejfeej d�dd�Z!Gdd�d�Z"Gdd�d�Z#dS)�N)�
TracebackType�)�
formatting)�termui)�utils)�_find_binary_reader)�BaseCommandc@s�eZdZejejdd�dd�Zeejd�dd�Ze	e	d�d	d
�Z
dee	d�d
d�Zdee	d�dd�Z
dee	d�dd�Zeje	d�dd�Zeje	d�dd�Zed�dd�ZdS)�EchoingStdinN)�input�output�returncCs||_||_d|_dS)NF)�_input�_output�_paused)�selfr
r�r�>/opt/alt/python37/lib/python3.7/site-packages/click/testing.py�__init__szEchoingStdin.__init__)�xrcCst|j|�S)N)�getattrr
)rrrrr�__getattr__szEchoingStdin.__getattr__)�rvrcCs|js|j�|�|S)N)rr�write)rrrrr�_echoszEchoingStdin._echo���)�nrcCs|�|j�|��S)N)rr
�read)rrrrrr#szEchoingStdin.readcCs|�|j�|��S)N)rr
�read1)rrrrrr&szEchoingStdin.read1cCs|�|j�|��S)N)rr
�readline)rrrrrr)szEchoingStdin.readline)rcs�fdd��j��D�S)Ncsg|]}��|��qSr)r)�.0r)rrr�
<listcomp>-sz*EchoingStdin.readlines.<locals>.<listcomp>)r
�	readlines)rr)rrr!,szEchoingStdin.readlinescst�fdd��jD��S)Nc3s|]}��|�VqdS)N)r)rr)rrr�	<genexpr>0sz(EchoingStdin.__iter__.<locals>.<genexpr>)�iterr
)rr)rr�__iter__/szEchoingStdin.__iter__cCs
t|j�S)N)�reprr
)rrrr�__repr__2szEchoingStdin.__repr__)r)r)r)�__name__�
__module__�__qualname__�t�BinaryIOr�str�Anyr�bytesr�intrrr�Listr!�Iteratorr$r&rrrrr	sr	)�streamrccs&|dkrdVnd|_dVd|_dS)NTF)r)r2rrr�_pause_echo6s
r3csReZdZejeeejdd��fdd�Zeed�dd��Z	eed�dd	��Z
�ZS)
�_NamedTextIOWrapperN)�buffer�name�mode�kwargsrcs t�j|f|�||_||_dS)N)�superr�_name�_mode)rr5r6r7r8)�	__class__rrrAsz_NamedTextIOWrapper.__init__)rcCs|jS)N)r:)rrrrr6Hsz_NamedTextIOWrapper.namecCs|jS)N)r;)rrrrr7Lsz_NamedTextIOWrapper.mode)r'r(r)r*r+r,r-r�propertyr6r7�
__classcell__rr)r<rr4@sr4)r
�charsetrcCsbt|d�r6tt�tjtj|��}|dk	r.|Std��|dkrDd}nt|t�rX|�	|�}t
�|�S)Nrz.Could not find binary reader for input stream.�)�hasattrrr*�cast�IOr-�	TypeError�
isinstancer,�encode�io�BytesIO)r
r?rrrr�make_input_streamQs


rIc@s�eZdZdZddeejeejeeje	ejej
eje	e	efd�dd�Z
eed�dd	��Zeed�d
d��Zeed�dd
��Zed�dd�ZdS)�Resultz3Holds the captured result of an invoked CLI script.N�	CliRunner)�runner�stdout_bytes�stderr_bytes�return_value�	exit_code�	exception�exc_infocCs.||_||_||_||_||_||_||_dS)N)rLrMrNrOrPrQrR)rrLrMrNrOrPrQrRrrrrhs
zResult.__init__)rcCs|jS)z(The (standard) output as unicode string.)�stdout)rrrrr�sz
Result.outputcCs|j�|jjd��dd�S)z&The standard output as unicode string.�replacez
�
)rM�decoderLr?rT)rrrrrS�sz
Result.stdoutcCs,|jdkrtd��|j�|jjd��dd�S)z%The standard error as unicode string.Nzstderr not separately capturedrTz
rU)rN�
ValueErrorrVrLr?rT)rrrr�stderr�s
z
Result.stderrcCs,|jrt|j�nd}dt|�j�d|�d�S)N�okay�<� �>)rQr%�typer')rZexc_strrrrr&�szResult.__repr__)N)r'r(r)�__doc__r.r*�Optionalr-r/�
BaseException�Tuple�Typerrr=r,rrSrXr&rrrrrJesBrJc
@s�eZdZdZdeejejeejefeedd�dd�Z	d	ed
�dd�Z
dejejeejefejeejefd
�dd�Zej
dejejeeejejfejejeejefeejejejejejfd�dd��Zdd	ejejeejefejejeeejejfejejeejefeeejed�dd�Zej
dejejedfejed�dd��ZdS)rKa�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-8NFT)r?�env�
echo_stdin�
mix_stderrrcCs ||_|pi|_||_||_dS)N)r?rdrerf)rr?rdrerfrrrr�s
zCliRunner.__init__r)�clircCs
|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)r6)rrgrrr�get_default_prog_name�szCliRunner.get_default_prog_name)�	overridesrcCst|j�}|r|�|�|S)z8Returns the environment overrides for invoking a script.)�dictrd�update)rrjrrrr�make_env�s

zCliRunner.make_env)r
rd�colorrc#s�t||j�}d}tj}tj}tj}tj}	dt_|�|�}t	�
�}
|jr^t�
tjt||
��}}t||jddd�t_�|jr�d�_t|
|jddd�t_d}|jr�tjt_nt	�
�}t||jd	dd
d�t_t|�dtjttd��fd
d�
�}t|�dtjttd��fdd�
�}
t|�ttd�dd��}|�dtjtjtjtjttd��fdd�
}tj}tj}tj}tj}|t_|
t_|t_|t_i}zpx`|��D]T\}}t j!�"|�||<|dk�r�yt j!|=Wnt#k
�r�YnXn
|t j!|<�q�W|
|fVWdxP|��D]D\}}|dk�r@yt j!|=Wnt#k
�r<YnXn
|t j!|<�qW|t_|t_|t_|t_|t_|t_|t_|	t_XdS)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)�encodingr6r7rz<stdout>�wz<stderr>�backslashreplace)rqr6r7�errors)�promptrcs>tj�|pd�����d�}tj�|�d��tj��|S)N�z
rU)�sysrSrr�rstrip�flush)ru�val)�
text_inputrr�
visible_inputs

z*CliRunner.isolation.<locals>.visible_inputcs.tj�|pd�d��tj������d�S)NrvrUz
)rwrSrryrrx)ru)r{rr�hidden_inputs
z)CliRunner.isolation.<locals>.hidden_input)�echorcSs*tj�d�}|rtj�|�tj��|S)Nr)rw�stdinrrSrry)r~�charrrr�_getchar#s

z%CliRunner.isolation.<locals>._getchar)r2rnrcs|dkr�S|S)Nr)r2rn)�
default_colorrr�should_strip_ansi/sz.CliRunner.isolation.<locals>.should_strip_ansi)N)N)NN)$rIr?rwrrSrXrZFORCED_WIDTHrmrGrHrer*rBr+r	r4�_CHUNK_SIZErfr3r_r,�boolrCr-rZvisible_prompt_funcZhidden_prompt_funcr�rr��items�os�environ�get�	Exception)rr
rdrnZbytes_inputZ
echo_inputZ	old_stdinZ
old_stdoutZ
old_stderrZold_forced_widthZbytes_outputZbytes_errorr|r}r�r�Zold_visible_prompt_funcZold_hidden_prompt_funcZold__getchar_funcZold_should_strip_ansiZold_env�key�valuer)r�r{r�	isolation�s�


	

zCliRunner.isolation)rg�argsr
rd�catch_exceptionsrn�extrarcKs�d}|j|||d���z}	d}
d}d}t|t�r8t�|�}y|�d�}
Wntk
rd|�|�}
YnXz�y|jf|pvd|
d�|��}
Wn�t	k
�r}ztt
��}t�
tjtjttjf|j�}|dkr�d}|dkr�|}t|t��st
j�t|��t
j�d�d}|}Wdd}~XYn<tk
�rT}z|�s4�|}d}t
��}Wdd}~XYnXWdt
j��|	d��}|j�r~d}n|	d��}XWdQRXt||||
|||d	�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
rdrnr�	prog_namer)r�r�rUr)rLrMrNrOrPrQrR)r�rEr,�shlex�split�pop�KeyErrorri�main�
SystemExitrwrRr*rBr_�Unionr/r-�coderSrr�ry�getvaluerfrJ)rrgr�r
rdr�rnr�rRZ
outstreamsrOrQrPr��eZe_coderSrXrrr�invoke]sX,

 
zCliRunner.invokezos.PathLike[str])�temp_dirrccsft��}tj|d�}t�|�z
|VWdt�|�|dkr`yt�|�Wntk
r^YnXXdS)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�dtrrr�isolated_filesystem�s


zCliRunner.isolated_filesystem)rcNFT)N)NNF)NNNTF)N)r'r(r)r^r,r*r_�Mappingr�rrirm�
contextlib�contextmanagerr�r.rCr-r1rarGrHr��SequencerJr�r�rrrrrK�s2 8*
T\rK)$r�rGr�r�r�rwr��typingr*�typesrrvrrr�_compatr�
TYPE_CHECKING�corerr	r�r_r1r3�
TextIOWrapperr4r�r,r.rCr-r+rIrJrKrrrr�<module>s,"	: