o
    ßý°jÀk  ã                   @  s’  U d dl mZ d dlmZ d dlZd dlZd dlZd dlZd dl	Z	d dl
Z
d dlZd dlZd dlmZ ddlmZ ddlmZ ddlmZ ddlmZ dd	lmZ ejr`d d
lmZ ddlmZ e
jdkroejd Zded< n	ejd Zded< ee e! e!ef Z"ded< G dd„ dƒZ#ej$d-dd„ƒZ%G dd„ dƒZ&G dd„ dej'ƒZ(G dd„ dƒZ)G d d!„ d!ej*ƒZ+d.d'd(„Z,G d)d*„ d*ƒZ-G d+d,„ d,ƒZ.dS )/é    )ÚannotationsN)ÚTracebackTypeé   )Ú_compat)Ú
formatting)Útermui)Úutils)Ú_find_binary_reader)ÚReadableBuffer)ÚCommandÚwin32Úsyszt.TypeAliasÚCaptureMode)r   ÚfdÚExceptionInfoc                   @  s†   e Zd ZU ded< ded< ded< d'd
d„Zd(dd„Zd)dd„Zd*d+dd„Zd*d+dd„Zd*d+dd„Z	d,dd „Z
d-d"d#„Zd.d$d%„Zd&S )/ÚEchoingStdinú
t.BinaryIOÚ_inputÚ_outputÚboolÚ_pausedÚinputÚoutputÚreturnÚNonec                 C  s   || _ || _d| _d S )NF)r   r   r   )Úselfr   r   © r   ú€/root/aizidognhua/tmp/workspace/projects/ec89d86c-575f-41c9-af57-ac45cbdbf775/venv/lib/python3.10/site-packages/click/testing.pyÚ__init__%   ó   
zEchoingStdin.__init__ÚxÚstrút.Anyc                 C  s   t | j|ƒS ©N)Úgetattrr   )r   r    r   r   r   Ú__getattr__*   s   zEchoingStdin.__getattr__ÚrvÚbytesc                 C  s   | j s	| j |¡ |S r#   )r   r   Úwrite)r   r&   r   r   r   Ú_echo-   s   zEchoingStdin._echoéÿÿÿÿÚnÚintc                 C  ó   |   | j |¡¡S r#   )r)   r   Úread©r   r+   r   r   r   r.   3   ó   zEchoingStdin.readc                 C  r-   r#   )r)   r   Úread1r/   r   r   r   r1   6   r0   zEchoingStdin.read1c                 C  r-   r#   )r)   r   Úreadliner/   r   r   r   r2   9   r0   zEchoingStdin.readlineúlist[bytes]c                   s   ‡ fdd„ˆ j  ¡ D ƒS )Nc                   s   g | ]}ˆ   |¡‘qS r   ©r)   ©Ú.0r    ©r   r   r   Ú
<listcomp>=   s    z*EchoingStdin.readlines.<locals>.<listcomp>)r   Ú	readlinesr7   r   r7   r   r9   <   ó   zEchoingStdin.readlinesúcabc.Iterator[bytes]c                   s   t ‡ fdd„ˆ jD ƒƒS )Nc                 3  s   � | ]}ˆ   |¡V  qd S r#   r4   r5   r7   r   r   Ú	<genexpr>@   s   € z(EchoingStdin.__iter__.<locals>.<genexpr>)Úiterr   r7   r   r7   r   Ú__iter__?   r:   zEchoingStdin.__iter__c                 C  s
   t | jƒS r#   )Úreprr   r7   r   r   r   Ú__repr__B   s   
zEchoingStdin.__repr__N)r   r   r   r   r   r   )r    r!   r   r"   )r&   r'   r   r'   )r*   )r+   r,   r   r'   )r   r3   )r   r;   ©r   r!   )Ú__name__Ú
__module__Ú__qualname__Ú__annotations__r   r%   r)   r.   r1   r2   r9   r>   r@   r   r   r   r   r       s   
 




r   ÚstreamúEchoingStdin | Noner   úcabc.Generator[None]c                 c  s*   � | d u r
d V  d S d| _ d V  d| _ d S )NTF)r   )rF   r   r   r   Ú_pause_echoF   s   €

rI   c                   @  sH   e Zd ZU dZded< ded< ded< dd
d„Zddd„Zddd„ZdS )Ú
_FDCaptureaV  Redirect a file descriptor to a temporary file for capture.

    Saves the current target of *targetfd* via :func:`os.dup`, then
    redirects it to a temporary file via :func:`os.dup2`. On
    :meth:`stop`, restores the original ``fd`` and returns the captured
    bytes. Inspired by Pytest's ``FDCapture``.

    .. versionadded:: 8.4.0
    r,   Ú	_targetfdÚsaved_fdzt.BinaryIO | NoneÚ_tmpfileÚtargetfdr   r   c                 C  s   || _ d| _d | _d S ©Nr*   )rK   rL   rM   )r   rN   r   r   r   r   _   r   z_FDCapture.__init__c                 C  s4   t  | j¡| _tjdd�| _t  | j ¡ | j¡ d S )Nr   )Ú	buffering)	ÚosÚduprK   rL   ÚtempfileÚTemporaryFilerM   Údup2Úfilenor7   r   r   r   Ústartd   s   z_FDCapture.startr'   c                 C  s^   | j d us	J dƒ‚t | j| j¡ t | j¡ d| _| j  d¡ | j  ¡ }| j  ¡  d | _ |S )Nz!_FDCapture.start() was not calledr*   r   )rM   rQ   rU   rL   rK   ÚcloseÚseekr.   )r   Údatar   r   r   Ústopi   s   

z_FDCapture.stopN)rN   r,   r   r   ©r   r   )r   r'   )rB   rC   rD   Ú__doc__rE   r   rW   r[   r   r   r   r   rJ   P   s   
 


rJ   c                      sH   e Zd ZU dZded< d‡ fdd„Zd‡ fdd	„Zd‡ fdd„Z‡  ZS )ÚBytesIOCopyzdPatch ``io.BytesIO`` to let the written stream be copied to another.

    .. versionadded:: 8.2
    ú
io.BytesIOÚcopy_tor   r   c                   s   t ƒ  ¡  || _d S r#   )Úsuperr   r`   )r   r`   ©Ú	__class__r   r   r   }   s   

zBytesIOCopy.__init__c                   s   t ƒ  ¡  | j ¡  d S r#   )ra   Úflushr`   r7   rb   r   r   rd   �   s   
zBytesIOCopy.flushÚbr
   r,   c                   s   | j  |¡ tƒ  |¡S r#   )r`   r(   ra   )r   re   rb   r   r   r(   …   s   zBytesIOCopy.write)r`   r_   r   r   r\   )re   r
   r   r,   )	rB   rC   rD   r]   rE   r   rd   r(   Ú__classcell__r   r   rb   r   r^   u   s   
 r^   c                   @  s4   e Zd ZU dZded< ded< ded< dd	d
„ZdS )ÚStreamMixerz‚Mixes `<stdout>` and `<stderr>` streams.

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

    .. versionadded:: 8.2
    r_   r   r^   ÚstdoutÚstderrr   r   c                 C  s*   t  ¡ | _t| jd�| _t| jd�| _d S )N)r`   )ÚioÚBytesIOr   r^   rh   ri   r7   r   r   r   r   –   s   
zStreamMixer.__init__Nr\   )rB   rC   rD   r]   rE   r   r   r   r   r   rg   Š   s   
 rg   c                      sp   e Zd ZU dZded< ded< ded< d‡ fdd„Zddd„Zd‡ fdd„Zeddd„ƒZ	eddd„ƒZ
‡  ZS )Ú_NamedTextIOWrappera  A :class:`~io.TextIOWrapper` with custom ``name`` and ``mode``
    that does not close its underlying buffer.

    When ``CliRunner`` runs in ``fd`` mode, ``_original_fd`` is patched to
    point at the saved (pre-redirection) ``fd``, so C-level consumers that call
    :meth:`fileno` (like ``faulthandler`` or ``subprocess``) keep working. In
    the default ``sys`` mode ``_original_fd`` stays at ``-1`` and
    :meth:`fileno` raises :exc:`io.UnsupportedOperation`, matching the
    pre-``8.3.3`` behavior.
    r!   Ú_nameÚ_moder,   Ú_original_fdÚbufferr   ÚnameÚmodeÚkwargsr"   r   r   c                   s*   t ƒ j|fi |¤Ž || _|| _d| _d S rO   )ra   r   rm   rn   ro   )r   rp   rq   rr   rs   rb   r   r   r   ¬   s   
z_NamedTextIOWrapper.__init__c                 C  s   dS )zÃThe buffer this object contains belongs to some other object,
        so prevent the default ``__del__`` implementation from closing
        that buffer.

        .. versionadded:: 8.3.2
        Nr   r7   r   r   r   rX   ¸   s    z_NamedTextIOWrapper.closec                   s   | j dkr| j S tƒ  ¡ S )zÿReturn the file descriptor of the saved original stream when
        ``CliRunner`` runs in ``fd`` mode. Otherwise delegate to
        :class:`~io.TextIOWrapper`, which raises
        :exc:`io.UnsupportedOperation` for a ``BytesIO``-backed buffer.
        r   )ro   ra   rV   r7   rb   r   r   rV   À   s   

z_NamedTextIOWrapper.filenoc                 C  ó   | j S r#   )rm   r7   r   r   r   rq   Ê   ó   z_NamedTextIOWrapper.namec                 C  rt   r#   )rn   r7   r   r   r   rr   Î   ru   z_NamedTextIOWrapper.mode)
rp   r   rq   r!   rr   r!   rs   r"   r   r   r\   )r   r,   rA   )rB   rC   rD   r]   rE   r   rX   rV   Úpropertyrq   rr   rf   r   r   rb   r   rl   œ   s   
 

rl   r   ú str | bytes | t.IO[t.Any] | NoneÚcharsetr!   r   c                 C  sZ   t | dƒrtt d| ¡ƒ}|d ur|S tdƒ‚| d u rd} n
t| tƒr(|  |¡} t 	| ¡S )Nr.   zt.IO[t.Any]z.Could not find binary reader for input stream.ó    )
Úhasattrr	   ÚtÚcastÚ	TypeErrorÚ
isinstancer!   Úencoderj   rk   )r   rx   r&   r   r   r   Úmake_input_streamÓ   s   



r€   c                   @  s”   e Zd ZU dZded< ded< ded< ded< ded	< d
ed< ded< ded< 	dddd„Zed dd„ƒZed dd„ƒZed dd„ƒZ	d dd„Z
dS )!ÚResultaC  Holds 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``.
    Ú	CliRunnerÚrunnerr'   Ústdout_bytesÚstderr_bytesÚoutput_bytesr"   Úreturn_valuer,   Ú	exit_codeúBaseException | NoneÚ	exceptionúExceptionInfo | NoneÚexc_infoNr   r   c	           	      C  s4   || _ || _|| _|| _|| _|| _|| _|| _d S r#   ©rƒ   r„   r…   r†   r‡   rˆ   rŠ   rŒ   )	r   rƒ   r„   r…   r†   r‡   rˆ   rŠ   rŒ   r   r   r   r     s   
zResult.__init__r!   c                 C  ó   | j  | jjd¡ dd¡S )a  The 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ƒ   rx   r�   r7   r   r   r   r     s   ÿzResult.outputc                 C  rŽ   )z&The standard output as unicode string.r�   r�   r‘   )r„   r’   rƒ   rx   r�   r7   r   r   r   rh   &  s   ÿzResult.stdoutc                 C  rŽ   )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ƒ   rx   r�   r7   r   r   r   ri   -  s   ÿzResult.stderrc                 C  s,   | j rt| j ƒnd}dt| ƒj› d|› d�S )NÚokayú<ú ú>)rŠ   r?   ÚtyperB   )r   Úexc_strr   r   r   r@   8  s   zResult.__repr__r#   )rƒ   r‚   r„   r'   r…   r'   r†   r'   r‡   r"   rˆ   r,   rŠ   r‰   rŒ   r‹   r   r   rA   )rB   rC   rD   r]   rE   r   rv   r   rh   ri   r@   r   r   r   r   r�   ç   s&   
 ÷
r�   c                   @  sª   e Zd ZU dZded< ded< ded< ded< d	ed
< 					d/d0dd„Zd1dd„Z	d2d3dd„Zej				d4d5d d!„ƒZ
					d6d7d(d)„Zej		d2d8d-d.„ƒZdS )9r‚   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`.
    :param capture: Selects the output capture strategy. ``sys`` (default)
        captures Python-level writes only and leaves
        :meth:`sys.stdout.fileno` raising :exc:`io.UnsupportedOperation`, so
        user code that calls :func:`os.dup2` on ``sys.stdout.fileno()`` cannot
        clobber the host runner's stdout. ``fd`` redirects file descriptors
        ``1`` and ``2`` via :func:`os.dup2` to a temporary file, also catching
        output from stale stream references, C extensions, and subprocesses.
        ``fd`` is not supported on Windows.

    .. versionchanged:: 8.4.0
        Added the ``capture`` parameter. The default ``sys`` mode no longer
        exposes the original fd through :meth:`fileno`, reverting the change
        introduced in ``8.3.3`` that broke Pytest's ``fd``-level capture
        teardown. Use ``capture="fd"`` to restore that behavior with proper
        isolation. :issue:`3384`

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

    .. versionchanged:: 8.2
        ``mix_stderr`` parameter has been removed.
    r!   rx   úcabc.Mapping[str, str | None]Úenvr   Ú
echo_stdinÚcatch_exceptionsr   Úcaptureúutf-8NFTr   ú$cabc.Mapping[str, str | None] | Noner   r   c                 C  s`   |dvrt d|›d�ƒ‚|dkrtjdkrt d|›d�ƒ‚|| _|p#i | _|| _|| _|| _d S )N>   r   r   zcapture=z) is not valid. Choose from 'sys' or 'fd'.r   r   z( is not supported on Windows. Use 'sys'.)Ú
ValueErrorr   Úplatformrx   rš   r›   rœ   r�   )r   rx   rš   r›   rœ   r�   r   r   r   r   h  s   
ÿ
ÿ

zCliRunner.__init__Úclir   c                 C  s
   |j pdS )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)rq   )r   r¢   r   r   r   Úget_default_prog_name~  s   
zCliRunner.get_default_prog_nameÚ	overridesc                 C  s   t | jƒ}|r| |¡ |S )z8Returns the environment overrides for invoking a script.)Údictrš   Úupdate)r   r¥   r&   r   r   r   Úmake_env…  s   

zCliRunner.make_envr   rw   Úcolorú9cabc.Generator[tuple[io.BytesIO, io.BytesIO, io.BytesIO]]c                 #  sò  � t || jƒ}d}tj}tj}tj}tj}	dt_|  |¡}t	ƒ }
| j
r0t tjt||
jƒ¡ }}t|| jddd� t_‰| j
rBdˆ_t|
j| jddd�t_t|
j| jd	dd
d�t_t|ƒd*d+‡fdd„ƒ}t|ƒd*d+‡fdd„ƒ}t|ƒd,dd„ƒ}|‰ 	d-d.‡ fdd„}tj}tj}tj}tj}tj}tjj‰|t_|t_|t_|t_|t_			d/d0‡fd(d)„}|tj_i }zy| ¡ D ]%\}}tj |¡||< |du rÝztj|= W q½ t yÜ   Y q½w |tj|< q½|
j|
j|
j!fV  W | ¡ D ]\}}|du �rztj|= W qñ t �y
   Y qñw |tj|< qñ|t_|t_|t_|t_|t_|t_|t_|t_|	t_ˆtj_dS | ¡ D ]"\}}|du �rRztj|= W �q6 t �yQ   Y �q6w |tj|< �q6|t_|t_|t_|t_|t_|t_|t_|t_|	t_ˆtj_w )1a\  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éP   z<stdin>Úr)Úencodingrq   rr   r   z<stdout>Úwz<stderr>Úbackslashreplace)r­   rq   rr   ÚerrorsÚpromptú
str | Noner   r!   c              
     sd   t j | pd¡ z	tˆ ƒ d¡}W n ty! } ztƒ |‚d }~ww t j |› d�¡ t j ¡  |S )NÚ r�   r‘   )r   rh   r(   ÚnextÚrstripÚStopIterationÚEOFErrorrd   )r±   ÚvalÚe©Ú
text_inputr   r   Úvisible_inputÚ  s   €ÿ
z*CliRunner.isolation.<locals>.visible_inputc              
     sR   t j | pd› d�¡ t j ¡  ztˆ ƒ d¡W S  ty( } ztƒ |‚d }~ww )Nr³   r‘   r�   )r   rh   r(   rd   r´   rµ   r¶   r·   )r±   r¹   rº   r   r   Úhidden_inputå  s   
€ÿz)CliRunner.isolation.<locals>.hidden_inputÚechor   c                 S  s*   t j d¡}| rt j |¡ t j ¡  |S )Nr   )r   Ústdinr.   rh   r(   rd   )r¾   Úcharr   r   r   Ú_getcharî  s
   
z%CliRunner.isolation.<locals>._getcharrF   út.IO[t.Any] | Noner©   úbool | Nonec                   s   |d u rˆ  S | S r#   r   )rF   r©   )Údefault_colorr   r   Úshould_strip_ansiú  s   z.CliRunner.isolation.<locals>.should_strip_ansiÚtabr   úpdb.PdbÚcompletekeyr¿   út.IO[str] | Nonerh   rs   r"   r   c                   s8   |du rt j}|du rt j}ˆ | f|||dœ|¤Ž dS )ab  Default ``pdb.Pdb`` to real terminal streams during
            ``CliRunner`` isolation.

            Without this patch, ``pdb.Pdb.__init__`` inherits from
            ``cmd.Cmd`` which falls back to ``sys.stdin``/``sys.stdout``
            when no explicit streams are provided. During isolation
            those are ``BytesIO``-backed wrappers, so the debugger
            reads from an empty buffer and writes to captured output,
            making interactive debugging impossible.

            By defaulting to ``sys.__stdin__``/``sys.__stdout__`` (the
            original terminal streams Python preserves regardless of
            redirection), debuggers can interact with the user while
            ``click.echo`` output is still captured normally.

            This covers ``pdb.set_trace()``, ``breakpoint()``,
            ``pdb.post_mortem()``, and debuggers that subclass
            ``pdb.Pdb`` (ipdb, pdbpp). Explicit ``stdin``/``stdout``
            arguments are honored and not overridden. Debuggers that
            do not subclass ``pdb.Pdb`` (pudb, debugpy) are not
            covered.
            N)rÈ   r¿   rh   )r   Ú	__stdin__Ú
__stdout__)r   rÈ   r¿   rh   rs   )Úold_pdb_initr   r   Ú_patched_pdb_init  s   ÿÿ
ÿz.CliRunner.isolation.<locals>._patched_pdb_initr#   )r±   r²   r   r!   )r¾   r   r   r!   )NN)rF   rÂ   r©   rÃ   r   r   )rÆ   NN)r   rÇ   rÈ   r!   r¿   rÉ   rh   rÉ   rs   r"   r   r   )"r€   rx   r   r¿   rh   ri   r   ÚFORCED_WIDTHr¨   rg   r›   r{   r|   ÚBinaryIOr   rl   Ú_CHUNK_SIZErI   r   Úvisible_prompt_funcÚhidden_prompt_funcrÁ   r   rÅ   r   ÚpdbÚPdbr   ÚitemsrQ   ÚenvironÚgetÚ	Exceptionr   )r   r   rš   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_ansirÍ   Úold_envÚkeyÚvaluer   )rÄ   rÌ   r»   r   Ú	isolationŽ  sÒ   €"
ÿ
ÿüû
	ÿü%ÿ
ÿï
ÿ
zCliRunner.isolationÚargsústr | cabc.Sequence[str] | NonerÃ   Úextrar"   r�   c                 K  s  d}|du r	| j }d}	d}
| jdkr2tdƒ}	tdƒ}
z
|	 ¡  |
 ¡  W n ty1   d }	}
Y nw | j|||d���4}|	durN|
durN|	jtj_	|
jtj
_	d}d}d}t|tƒr^t |¡}z| d¡}W n tys   |  |¡}Y nw z°z|jd|p|d|d	œ|¤Ž}W n\ tyÄ } z4t ¡ }t d
|j¡}|du r�d}|dkr£|}t|tƒs¸tj t|ƒ¡ tj d¡ d}|}W Y d}~n!d}~w tyà } z|sÎ‚ |}d}t ¡ }W Y d}~nd}~ww W tj ¡  tj
 ¡  |	du�r|
du�r|	 ¡ }|
 ¡ }|�r|d  |¡ |�r|d  |¡ |d  ¡ }|d  ¡ }|d  ¡ }nCtj ¡  tj
 ¡  |	du�rU|
du�rU|	 ¡ }|
 ¡ }|�rK|d  |¡ |�rU|d  |¡ |d  ¡ }|d  ¡ }|d  ¡ }w W d  ƒ n	1 �ssw   Y  t| |||||||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``. 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.
        Nr   r   é   )r   rš   r©   r   Ú	prog_namer   )ré   rí   zint | t.Any | Noner‘   r�   )rœ   r�   rJ   rW   ÚOSErrorrè   rL   r   rh   ro   ri   r~   r!   ÚshlexÚsplitÚpopÚKeyErrorr¤   ÚmainÚ
SystemExitrŒ   r{   r|   Úcoder,   r(   rØ   rd   r[   Úgetvaluer�   )r   r¢   ré   r   rš   rœ   r©   rë   rŒ   Úcap_outÚcap_errÚ
outstreamsr‡   rŠ   rˆ   rí   r¹   Úe_codeÚfd_outÚfd_errrh   ri   r   r   r   r   ÚinvokeT  s®   5
ÿ



ÿ
€€û€


ð
Â@øzCliRunner.invokeÚtemp_dirústr | os.PathLike[str] | Noneúcabc.Generator[str]c                 c  sÄ   � ddl }|jdtdd� t ¡ }tj|d�}t |¡ z&|V  W t |¡ |du rAddl}z| 	|¡ W dS  t
y@   Y dS w dS t |¡ |du raddl}z| 	|¡ W w  t
y`   Y w w 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.

        .. warning::
            This helper predates Python 3 and modern pytest, and is not
            thread-safe: it relies on :func:`os.chdir`, which mutates
            process-global state, and :meth:`invoke` swaps the
            process-global standard streams too. Parallelize tests with
            processes (``pytest-xdist``), not threads. Locking the
            runner (:pr:`3511`, :pr:`3520`, :pr:`3530`) and a
            ``set_filesystem()`` API (:issue:`3123`) were declined:
            neither removes the global-state mutation. See :issue:`3700`
            and :issue:`3501`.

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

        .. deprecated:: 8.5.0
            Will be removed in Click 9.0. Use
            :class:`tempfile.TemporaryDirectory` or pytest's
            ``tmp_path`` fixture with absolute paths instead.

        .. versionchanged:: 8.0
            Added the ``temp_dir`` parameter.
        r   Nz£'isolated_filesystem' is deprecated and will be removed in Click 9.0. Use 'tempfile.TemporaryDirectory' or pytest's 'tmp_path' fixture with absolute paths instead.é   )Ú
stacklevel)Údir)ÚwarningsÚwarnÚDeprecationWarningrQ   ÚgetcwdrS   ÚmkdtempÚchdirÚshutilÚrmtreerî   )r   rþ   r  ÚcwdÚdtr
  r   r   r   Úisolated_filesystemå  s<   € û

ÿû
þÿûzCliRunner.isolated_filesystem)rž   NFTr   )rx   r!   rš   rŸ   r›   r   rœ   r   r�   r   r   r   )r¢   r   r   r!   r#   )r¥   rŸ   r   r™   )NNF)r   rw   rš   rŸ   r©   r   r   rª   )NNNNF)r¢   r   ré   rê   r   rw   rš   rŸ   rœ   rÃ   r©   r   rë   r"   r   r�   )rþ   rÿ   r   r   )rB   rC   rD   r]   rE   r   r¤   r¨   Ú
contextlibÚcontextmanagerrè   rý   r  r   r   r   r   r‚   =  s@   
 $ú
ÿ	ü Iù ÿr‚   )rF   rG   r   rH   )r   rw   rx   r!   r   r   )/Ú
__future__r   Úcollections.abcÚabcÚcabcr  rj   rQ   rÓ   rï   r   rS   Útypingr{   Útypesr   r³   r   r   r   r   r	   ÚTYPE_CHECKINGÚ	_typeshedr
   Úcorer   r¡   ÚLiteralr   rE   Útupler—   ÚBaseExceptionr   r   r  rI   rJ   rk   r^   rg   ÚTextIOWrapperrl   r€   r�   r‚   r   r   r   r   Ú<module>   sB    
&	%
7V