HEX
Server: LiteSpeed
System: Linux kapuas.iixcp.rumahweb.net 5.14.0-427.42.1.el9_4.x86_64 #1 SMP PREEMPT_DYNAMIC Fri Nov 1 14:58:02 EDT 2024 x86_64
User: mirz4654 (1666)
PHP: 8.1.33
Disabled: system,exec,escapeshellarg,escapeshellcmd,passthru,proc_close,proc_get_status,proc_nice,proc_open,proc_terminate,shell_exec,popen,pclose,dl,pfsockopen,leak,apache_child_terminate,posix_kill,posix_mkfifo,posix_setsid,posix_setuid,posix_setpgid,ini_alter,show_source,define_syslog_variables,symlink,syslog,openlog,openlog,closelog,ocinumcols,listen,chgrp,apache_note,apache_setenv,debugger_on,debugger_off,ftp_exec,dll,ftp,myshellexec,socket_bind,mail,posix_getwpuid
Upload Files
File: //usr/local/lib/python3.9/site-packages/click/__pycache__/testing.cpython-39.pyc
a

X>h�?�@s*ddlZddlZddlZddlZddlZddlZddlZddlZddl	m
Z
ddlmZddlm
Z
ddlmZddlmZddlmZejr�dd	lmZGd
d�d�Zejejeejdd�d
d��ZGdd�dej�Zejejeeejejfeej d�dd�Z!Gdd�d�Z"Gdd�d�Z#dS)�N)�
TracebackType�)�_compat)�
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)�selfrr�r�7/usr/local/lib/python3.9/site-packages/click/testing.py�__init__szEchoingStdin.__init__)�xr
cCst|j|�S�N)�getattrr)rrrrr�__getattr__szEchoingStdin.__getattr__)�rvr
cCs|js|j�|�|Sr)rr�write)rrrrr�_echoszEchoingStdin._echo���)�nr
cCs|�|j�|��Sr)rr�read�rrrrrr$szEchoingStdin.readcCs|�|j�|��Sr)rr�read1rrrrr 'szEchoingStdin.read1cCs|�|j�|��Sr)rr�readlinerrrrr!*szEchoingStdin.readline�r
cs�fdd��j��D�S)Ncsg|]}��|��qSr�r��.0r�rrr�
<listcomp>.�z*EchoingStdin.readlines.<locals>.<listcomp>)r�	readlinesr&rr&rr)-szEchoingStdin.readlinescst�fdd��jD��S)Nc3s|]}��|�VqdSrr#r$r&rr�	<genexpr>1r(z(EchoingStdin.__iter__.<locals>.<genexpr>)�iterrr&rr&r�__iter__0szEchoingStdin.__iter__cCs
t|j�Sr)�reprrr&rrr�__repr__3szEchoingStdin.__repr__)r)r)r)�__name__�
__module__�__qualname__�t�BinaryIOr�str�Anyr�bytesr�intrr r!�Listr)�Iteratorr,r.rrrrr
sr
)�streamr
ccs&|durdVnd|_dVd|_dS)NTF)r)r:rrr�_pause_echo7s
r;csReZdZejeeejdd��fdd�Zeed�dd��Z	eed�dd	��Z
�ZS)
�_NamedTextIOWrapperN)�buffer�name�mode�kwargsr
cs$t�j|fi|��||_||_dSr)�superr�_name�_mode)rr=r>r?r@��	__class__rrrBsz_NamedTextIOWrapper.__init__r"cCs|jSr)rBr&rrrr>Isz_NamedTextIOWrapper.namecCs|jSr)rCr&rrrr?Msz_NamedTextIOWrapper.mode)r/r0r1r2r3r4r5r�propertyr>r?�
__classcell__rrrDrr<As�r<)r�charsetr
cCsbt|d�r6tt�tjtj|��}|dur.|Std��|durDd}nt|t�rX|�	|�}t
�|�S)Nrz.Could not find binary reader for input stream.r()�hasattrrr2�cast�IOr5�	TypeError�
isinstancer4�encode�io�BytesIO)rrHrrrr�make_input_streamRs


rQc@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.||_||_||_||_||_||_||_dSrrT)rrUrVrWrXrYrZr[rrrris
zResult.__init__r"cCs|jS)z(The (standard) output as unicode string.)�stdoutr&rrrr�sz
Result.outputcCs|j�|jjd��dd�S)z&The standard output as unicode string.�replace�
�
)rV�decoderUrHr]r&rrrr\�s�z
Result.stdoutcCs,|jdurtd��|j�|jjd��dd�S)z%The standard error as unicode string.Nzstderr not separately capturedr]r^r_)rW�
ValueErrorr`rUrHr]r&rrr�stderr�s

�z
Result.stderrcCs,|jrt|j�nd}dt|�j�d|�d�S)N�okay�<� �>)rZr-�typer/)rZexc_strrrrr.�szResult.__repr__)N)r/r0r1�__doc__r6r2�Optionalr5r7�
BaseException�Tuple�TyperrrFr4rr\rbr.rrrrrRfs(���rRc
@s�eZdZdZdeejejeejefeedd�dd�Z	d	ed
�dd�Z
dejejeejefejeejefd
�dd�Zej
dejejeeejejfejejeejefeejejejejejfd�dd��Zdd	ejejeejefejejeeejejfejejeejefeeejed�dd�Zej
dejejedfejed�dd��ZdS)rSa�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)rH�env�
echo_stdin�
mix_stderrr
cCs ||_|pi|_||_||_dSr)rHrnrorp)rrHrnrorprrrr�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)r>)rrqrrr�get_default_prog_name�szCliRunner.get_default_prog_name)�	overridesr
cCst|j�}|r|�|�|S)z8Returns the environment overrides for invoking a script.)�dictrn�update)rrtrrrr�make_env�s

zCliRunner.make_env)rrn�colorr
c#st||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}tj}|t_|
t_|t_|t_|t_i}z�|� �D]R\}}t!j"�#|�||<|du�r�zt!j"|=Wnt$�y�Yn0n
|t!j"|<�q�|
|fVW|� �D]B\}}|du�r@zt!j"|=Wnt$�y<Yn0n
|t!j"|<�q
|t_|t_|t_|t_|t_|t_|t_|t_|	t_n�|� �D]B\}}|du�r�zt!j"|=Wnt$�y�Yn0n
|t!j"|<�q�|t_|t_|t_|t_|t_|t_|t_|t_|	t_0dS)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)�encodingr>r?rz<stdout>�wz<stderr>�backslashreplace)r{r>r?�errors)�promptr
cs>tj�|pd�����d�}tj�|�d��tj��|S)N�r^r_)�sysr\rr!�rstrip�flush)r�val��
text_inputrr�
visible_inputs

z*CliRunner.isolation.<locals>.visible_inputcs.tj�|pd�d��tj������d�S)Nr�r_r^)r�r\rr�r!r�)rr�rr�hidden_inputs
z)CliRunner.isolation.<locals>.hidden_input)�echor
cSs*tj�d�}|rtj�|�tj��|S)Nr)r��stdinrr\rr�)r��charrrr�_getchar$s

z%CliRunner.isolation.<locals>._getchar)r:rxr
cs|dur�S|Srr)r:rx)�
default_colorrr�should_strip_ansi0sz.CliRunner.isolation.<locals>.should_strip_ansi)N)N)NN)%rQrHr�r�r\rbrZFORCED_WIDTHrwrOrPror2rJr3r
r<�_CHUNK_SIZErpr;rir4�boolrKr5rZvisible_prompt_funcZhidden_prompt_funcr�rr�r�items�os�environ�get�	Exception)rrrnrxZbytes_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__compat_should_strip_ansiZold_env�key�valuer)r�r�r�	isolation�s�
�
�
�
�	��

�
zCliRunner.isolation)rq�argsrrn�catch_exceptionsrx�extrar
cKs�d}|j|||d����}	d}
d}d}t|t�r8t�|�}z|�d�}
Wntyb|�|�}
Yn0�z&z|jf|pvd|
d�|��}
Wn�t	�y}z|t
��}t�
tjtjttjf|j�}|dur�d}|dkr�|}t|t��st
j�t|��t
j�d�d}|}WYd}~nFd}~0t�yX}z$|�s4�|}d}t
��}WYd}~n
d}~00Wt
j��|	d��}|j�r�d}n|	d��}n2t
j��|	d��}|j�r�d}n|	d��}0Wd�n1�s�0Yt||||
|||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)rrnrxr�	prog_namer)r�r�r_rrT)r�rMr4�shlex�split�pop�KeyErrorrs�main�
SystemExitr�r[r2rJri�Unionr7r5�coder\rr�r��getvaluerprR)rrqr�rrnr�rxr�r[Z
outstreamsrXrZrYr��eZe_coder\rbrrr�invokeasd,

  
�
.�zCliRunner.invokezos.PathLike[str])�temp_dirr
ccs�t��}tj|d�}t�|�z>|VWt�|�|dur�zt�|�Wq�tyZYq�0n6t�|�|dur�zt�|�Wnty�Yn00dS)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)rmNFT)N)NNF)NNNTF)N)r/r0r1rhr4r2ri�Mappingr�rrsrw�
contextlib�contextmanagerr�r6rKr5r9rkrOrPr��SequencerRr�r�rrrrrS�sd����	����e��rS)$r�rOr�r�r�r�r��typingr2�typesrr�rrrrr�
TYPE_CHECKING�corer	r
r�rir9r;�
TextIOWrapperr<r�r4r6rKr5r3rQrRrSrrrr�<module>s0"	�: