
    EjZg                    R   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    re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          Z#ej$        d+d            Z% G d d          Z& G d dej'                  Z( G d d          Z) G d d ej*                  Z+d,d&Z, G d' d(          Z- G d) d*          Z.dS )-    )annotationsN)TracebackType   )_compat)
formatting)termui)utils)_find_binary_reader)ReadableBuffer)Commandwin32syszt.TypeAliasCaptureMode)r   fdExceptionInfoc                  |    e Zd ZU ded<   ded<   ded<   dd
ZddZd dZd!d"dZd!d"dZd!d"dZ	d#dZ
d$dZd%dZdS )&EchoingStdin
t.BinaryIO_input_outputbool_pausedinputoutputreturnNonec                0    || _         || _        d| _        d S )NF)r   r   r   )selfr   r   s      G/wd/license_services/venv/lib/python3.11/site-packages/click/testing.py__init__zEchoingStdin.__init__%   s        xstrt.Anyc                ,    t          | j        |          S N)getattrr   )r   r"   s     r   __getattr__zEchoingStdin.__getattr__*   s    t{A&&&r!   rvbytesc                H    | j         s| j                            |           |S r&   )r   r   write)r   r)   s     r   _echozEchoingStdin._echo-   s'    | 	#Lr"""	r!   nintc                \    |                      | j                            |                    S r&   )r-   r   readr   r/   s     r   r2   zEchoingStdin.read3   s$    zz$+**1--...r!   c                \    |                      | j                            |                    S r&   )r-   r   read1r3   s     r   r5   zEchoingStdin.read16   s$    zz$+++A..///r!   c                \    |                      | j                            |                    S r&   )r-   r   readliner3   s     r   r7   zEchoingStdin.readline9   s$    zz$+..q11222r!   list[bytes]c                N      fd j                                         D             S )Nc                :    g | ]}                     |          S  r-   .0r"   r   s     r   
<listcomp>z*EchoingStdin.readlines.<locals>.<listcomp>=   s#    ???!

1???r!   )r   	readlinesr   s   `r   r@   zEchoingStdin.readlines<   s+    ????t{'<'<'>'>????r!   cabc.Iterator[bytes]c                D     t           fd j        D                       S )Nc              3  B   K   | ]}                     |          V  d S r&   r<   r=   s     r   	<genexpr>z(EchoingStdin.__iter__.<locals>.<genexpr>@   s-      77aDJJqMM777777r!   )iterr   rA   s   `r   __iter__zEchoingStdin.__iter__?   s(    77774;777777r!   c                *    t          | j                  S r&   )reprr   rA   s    r   __repr__zEchoingStdin.__repr__B   s    DK   r!   N)r   r   r   r   r   r   )r"   r#   r   r$   )r)   r*   r   r*   )r.   )r/   r0   r   r*   )r   r8   )r   rB   r   r#   )__name__
__module____qualname____annotations__r    r(   r-   r2   r5   r7   r@   rG   rJ   r;   r!   r   r   r       s         MMM   
' ' ' '   / / / / /0 0 0 0 03 3 3 3 3@ @ @ @8 8 8 8! ! ! ! ! !r!   r   streamEchoingStdin | Noner   cabc.Generator[None]c              #  >   K   | d V  d S d| _         d V  d| _         d S )NTF)r   )rP   s    r   _pause_echorT   F   s3      ~r!   c                  J    e Zd ZU dZded<   ded<   ded<   dd
ZddZ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
    r0   	_targetfdsaved_fdzt.BinaryIO | None_tmpfiletargetfdr   r   c                0    || _         d| _        d | _        d S Nr.   )rW   rX   rY   )r   rZ   s     r   r    z_FDCapture.__init___   s    !r!   c                    t          j        | j                  | _        t	          j        d          | _        t          j        | j                                        | j                   d S )Nr   )	buffering)	osduprW   rX   tempfileTemporaryFilerY   dup2filenorA   s    r   startz_FDCapture.startd   sR    t~.. .;;;
$$&&77777r!   r*   c                L   | j         
J d            t          j        | j        | j                   t          j        | j                   d| _        | j                             d           | j                                         }| j                                          d | _         |S )Nz!_FDCapture.start() was not calledr.   r   )rY   r_   rc   rX   rW   closeseekr2   )r   datas     r   stopz_FDCapture.stopi   s    }((*M(((
t~...
1}!!##r!   N)rZ   r0   r   r   r   r   )r   r*   )rL   rM   rN   __doc__rO   r    re   rj   r;   r!   r   rV   rV   P   s|           NNNMMM   
8 8 8 8
	 	 	 	 	 	r!   rV   c                  H     e Zd ZU dZded<   d fdZd fdZd fdZ xZS )BytesIOCopyzdPatch ``io.BytesIO`` to let the written stream be copied to another.

    .. versionadded:: 8.2
    
io.BytesIOcopy_tor   r   c                V    t                                                       || _        d S r&   )superr    rp   )r   rp   	__class__s     r   r    zBytesIOCopy.__init__}   s$    r!   c                z    t                                                       | j                                         d S r&   )rr   flushrp   r   rs   s    r   ru   zBytesIOCopy.flush   s.    r!   br   r0   c                z    | j                             |           t                                          |          S r&   )rp   r,   rr   )r   rw   rs   s     r   r,   zBytesIOCopy.write   s/    1ww}}Qr!   )rp   ro   r   r   rk   )rw   r   r   r0   )	rL   rM   rN   rl   rO   r    ru   r,   __classcell__rs   s   @r   rn   rn   u   s          
                              r!   rn   c                  :    e Zd ZU dZded<   ded<   ded<   dd	Zd
S )StreamMixerzMixes `<stdout>` and `<stderr>` streams.

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

    .. versionadded:: 8.2
    ro   r   rn   stdoutstderrr   r   c                    t          j                    | _        t          | j                  | _        t          | j                  | _        d S )N)rp   )ioBytesIOr   rn   r}   r~   rA   s    r   r    zStreamMixer.__init__   s;    jll!$+666!$+666r!   Nrk   )rL   rM   rN   rl   rO   r    r;   r!   r   r|   r|      sZ           7 7 7 7 7 7r!   r|   c                       e Zd ZU dZded<   ded<   ded<   d fdZddZd fdZedd            Z	edd            Z
 x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_moder0   _original_fdbufferr   namemodekwargsr$   r   r   c                f     t                      j        |fi | || _        || _        d| _        d S r\   )rr   r    r   r   r   )r   r   r   r   r   rs   s        r   r    z_NamedTextIOWrapper.__init__   s@     	**6***

r!   c                    dS )zThe buffer this object contains belongs to some other object,
        so prevent the default ``__del__`` implementation from closing
        that buffer.

        .. versionadded:: 8.3.2
        Nr;   rA   s    r   rg   z_NamedTextIOWrapper.close   s      r!   c                h    | j         dk    r| j         S t                                                      S )zReturn 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   )r   rr   rd   rv   s    r   rd   z_NamedTextIOWrapper.fileno   s0     !!$$ww~~r!   c                    | j         S r&   )r   rA   s    r   r   z_NamedTextIOWrapper.name   
    zr!   c                    | j         S r&   )r   rA   s    r   r   z_NamedTextIOWrapper.mode   r   r!   )
r   r   r   r#   r   r#   r   r$   r   r   rk   )r   r0   rK   )rL   rM   rN   rl   rO   r    rg   rd   propertyr   r   ry   rz   s   @r   r   r      s         	 	 JJJJJJ
 
 
 
 
 
                  X    X    r!   r   r    str | bytes | t.IO[t.Any] | Nonecharsetr#   r   c                   t          | d          r5t          t          j        d|                     }||S t	          d          | d} n*t          | t                    r|                     |          } t          j	        |           S )Nr2   zt.IO[t.Any]z.Could not find binary reader for input stream.r!   )
hasattrr
   tcast	TypeError
isinstancer#   encoder   r   )r   r   r)   s      r   make_input_streamr      s     uf J u!=!=>>>IHIII}	E3		 &W%%:er!   c                      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Zedd            Zedd            Zedd            Z	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_valuer0   	exit_codeBaseException | None	exceptionExceptionInfo | Noneexc_infoNr   r   c	                v    || _         || _        || _        || _        || _        || _        || _        || _        d S r&   r   r   r   r   r   r   r   r   )	r   r   r   r   r   r   r   r   r   s	            r   r    zResult.__init__  sD     (((("" r!   r#   c                t    | 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   r   r   rA   s    r   r   zResult.output  s9      ''(;YGGOOD
 
 	
r!   c                t    | j                             | j        j        d                              dd          S )z&The standard output as unicode string.r   r   r   )r   r   r   r   r   rA   s    r   r}   zResult.stdout&  s9      ''(;YGGOOD
 
 	
r!   c                t    | j                             | j        j        d                              dd          S )zThe standard error as unicode string.

        .. versionchanged:: 8.2
            No longer raise an exception, always returns the `<stderr>` string.
        r   r   r   )r   r   r   r   r   rA   s    r   r~   zResult.stderr-  s9      ''(;YGGOOD
 
 	
r!   c                r    | j         rt          | j                   nd}dt          |           j         d| dS )Nokay< >)r   rI   typerL   )r   exc_strs     r   rJ   zResult.__repr__8  s?    *..D$t~&&&f34::&333333r!   r&   )r   r   r   r*   r   r*   r   r*   r   r$   r   r0   r   r   r   r   r   r   rK   )rL   rM   rN   rl   rO   r    r   r   r}   r~   rJ   r;   r!   r   r   r      s         * NNN####"""" *.! ! ! ! !( 	
 	
 	
 X	
 
 
 
 X
 
 
 
 X
4 4 4 4 4 4r!   r   c                      e Zd ZU dZded<   ded<   ded<   ded<   d	ed
<   	 	 	 	 	 d)d*dZd+dZ	 d,d-dZej	        	 	 	 d.d/d            Z
	 	 	 	 	 d0d1d$Zej	        	 d,d2d(            ZdS )3r   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#   r   cabc.Mapping[str, str | None]envr   
echo_stdincatch_exceptionsr   captureutf-8NFTr   $cabc.Mapping[str, str | None] | Noner   r   c                    |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   platformr   r   r   r   r   )r   r   r   r   r   r   s         r   r    zCliRunner.__init__h  s     -''O7OOO   d??s|w66N7NNN   9"$ 0r!   clir   c                    |j         pdS )zGiven 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   )r   r   s     r   get_default_prog_namezCliRunner.get_default_prog_name~  s    
 x!6!r!   	overridesc                \    t          | j                  }|r|                    |           |S )z8Returns the environment overrides for invoking a script.)dictr   update)r   r   r)   s      r   make_envzCliRunner.make_env  s0     $(^^ 	!IIi   	r!   r   r   color9cabc.Generator[tuple[io.BytesIO, io.BytesIO, io.BytesIO]]c              #    K   t          || j                  }d}t          j        }t          j        }t          j        }t          j        }	dt          _        |                     |          }t                      }
| j
        r4t          j        t          j        t          ||
j                            x}}t          || j        dd          xt          _        | j
        rd_        t          |
j        | j        dd          t          _        t          |
j        | j        d	dd
          t          _        t#          |          d%d&fd            }t#          |          d%d&fd            }t#          |          d'd            }|	 d(d)fd}t$          j        }t$          j        }t$          j        }t,          j        }t0          j        }t2          j        j        |t$          _        |t$          _        |t$          _        |t,          _        |t0          _        	 	 	 d*d+fd$}|t2          j        _        i }	 |                                D ]W\  }}t:          j                            |          ||<   |	 t:          j        |= 8# t@          $ r Y Dw xY w|t:          j        |<   X|
j        |
j        |
j!        fV  |                                D ]5\  }}|	 t:          j        |= # t@          $ r Y "w xY w|t:          j        |<   6|t          _        |t          _        |t          _        |t$          _        |t$          _        |t$          _        |t,          _        |t0          _        |	t          _        t2          j        _        dS # |                                D ]5\  }}|	 t:          j        |= # t@          $ r Y "w xY w|t:          j        |<   6|t          _        |t          _        |t          _        |t$          _        |t$          _        |t$          _        |t,          _        |t0          _        |	t          _        t2          j        _        w xY w),a\  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.
        NP   z<stdin>r)encodingr   r   r   z<stdout>wz<stderr>backslashreplace)r   r   r   errorsprompt
str | Noner   r#   c                T   t           j                            | pd           	 t                                        d          }n!# t
          $ r}t                      |d }~ww xY wt           j                            | d           t           j                                         |S )N r   r   )r   r}   r,   nextrstripStopIterationEOFErrorru   )r   vale
text_inputs      r   visible_inputz*CliRunner.isolation.<locals>.visible_input  s    JV\r***(:&&--f55  ( ( (jja'(JZZZ(((JJs   "A 
A%A  A%c                   t           j                            | pd d           t           j                                         	 t	                                        d          S # t          $ r}t                      |d }~ww xY w)Nr   r   r   )r   r}   r,   ru   r   r   r   r   )r   r   r   s     r   hidden_inputz)CliRunner.isolation.<locals>.hidden_input  s    J"000111J(J''..v666  ( ( (jja'(s   !A' '
B1B  Bechor   c                    t           j                            d          }| rt           j                            |           t           j                                         |S )Nr   )r   stdinr2   r}   r,   ru   )r   chars     r   _getcharz%CliRunner.isolation.<locals>._getchar  sL    9>>!$$D '
  &&&JKr!   rP   t.IO[t.Any] | Noner   bool | Nonec                    | S | S r&   r;   )rP   r   default_colors     r   should_strip_ansiz.CliRunner.isolation.<locals>.should_strip_ansi  s     }(((9r!   tabr   pdb.Pdbcompletekeyr   t.IO[str] | Noner}   r   r$   r   c                Z    |t           j        }|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   r}   )r   	__stdin__
__stdout__)r   r   r   r}   r   old_pdb_inits        r   _patched_pdb_initz.CliRunner.isolation.<locals>._patched_pdb_init  sW    : }~L"-U6 MS    r!   r&   )r   r   r   r#   )r   r   r   r#   )NN)rP   r   r   r   r   r   )r   NN)r   r   r   r#   r   r   r}   r   r   r$   r   r   )"r   r   r   r   r}   r~   r   FORCED_WIDTHr   r|   r   r   r   BinaryIOr   r   _CHUNK_SIZErT   r   visible_prompt_funchidden_prompt_funcr   r	   r   r   pdbPdbr    itemsr_   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   s                           @@@r   	isolationzCliRunner.isolation  s     D (t|<<
I	Z
Z
%2"$
mmC  "}}? 	'(v
Ll6IJJ( ( K* "5$,YS"
 "
 "
 	
	J ? 	' &'J"(\	
 
 

 )\%
 
 

 
Z	 	 	 	 	 	 	 	 
!	 	 
Z	 	 	( 	( 	( 	( 	( 	( 
!	 	( 
Z	 	 	 	 	 
!	 	  EI	 	 	 	 	 	 	 #)"<!'!:"O % 7(/(A%w'%2"$0!""3$5!  %&*'+	#	 #	 #	 #	 #	 #	 #	J -	,!iikk , ,
U!z~~c22=JsOO$    ',BJsOO&(;\=PQQQQ%mmoo , ,
U=JsOO$    ',BJsOO#CJ#CJ!CI)@F&(>F%/FO&;E#(EG%&6J#+CG# &mmoo , ,
U=JsOO$    ',BJsOO#CJ#CJ!CI)@F&(>F%/FO&;E#(EG%&6J#+CG++++sg   :=N 8JN 
JN J)N K&&
K32K3Q"N0/Q0
N=	:Q<N=	=BQargsstr | cabc.Sequence[str] | Noner   extrar$   r   c           
     h   d}|| j         }d}	d}
| j        dk    r\t          d          }	t          d          }
	 |	                                 |
                                 n# t          $ r dx}	}
Y nw xY w|                     |||          5 }|	.|
,|	j        t          j        _	        |
j        t          j
        _	        d}d}d}t          |t                    rt          j        |          }	 |                    d          }n%# t           $ r |                     |          }Y nw xY w	  |j        d|pd|d	|}n# t&          $ r}t          j                    }t+          j        d
|j                  }|d}|dk    r|}t          |t0                    sMt          j                            t          |                     t          j                            d           d}|}Y d}~n4d}~wt4          $ r$}|s |}d}t          j                    }Y d}~nd}~ww xY wt          j                                         t          j
                                         |	d|
b|	                                }|
                                }|r|d                             |           |r|d                             |           |d                                         }|d                                         }|d                                         }n# t          j                                         t          j
                                         |	d|
b|	                                }|
                                }|r|d                             |           |r|d                             |           |d                                         }|d                                         }|d                                         }w xY w	 ddd           n# 1 swxY w Y   t=          | |||||||          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   rV   re   OSErrorr  rX   r   r}   r   r~   r   r#   shlexsplitpopKeyErrorr   main
SystemExitr   r   r   coder0   r,   r  ru   rj   getvaluer   )r   r   r  r   r   r   r   r  r   cap_outcap_err
outstreamsr   r   r   r  r   e_codefd_outfd_errr}   r~   r   s                          r   invokezCliRunner.invokeT  s   j ##4 &*%)<4 mmG mmG) ) ) )$((''') ^^%S^>> >	2* "w':*1*:
'*1*:
'L.2II$$$ ){4((<!IIk22		 < < < 66s;;			<*2'sxVTZR9VVPUVV # # #<>> 4af==>FQ;; !I!&#.. J$$S[[111J$$T***F"						 * * *' 		<>>* 
  """
  """
 &7+>$\\^^F$\\^^F 4"1++F333 4"1++F333#A//11#A//11#A//11! 
  """
  """
 &7+>$\\^^F$\\^^F 4"1++F333 4"1++F333#A//11#A//11#A//111111}>	2 >	2 >	2 >	2 >	2 >	2 >	2 >	2 >	2 >	2 >	2 >	2 >	2 >	2 >	2@ %	
 	
 	
 		
s   (A# #A43A4A P0DPD(%P'D((P,D?>L?
H	BG+&L+H8HLHLC1PC2PPPPtemp_dirstr | os.PathLike[str] | Nonecabc.Generator[str]c              #    K   t          j                    }t          j        |          }t          j        |           	 |V  t          j        |           |-ddl}	 |                    |           dS # t          $ r Y dS w xY wdS # t          j        |           |+ddl}	 |                    |           w # t          $ r Y w w xY ww xY 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.
        )dirNr   )r_   getcwdra   mkdtempchdirshutilrmtreer  )r   r(  cwddtr0  s        r   isolated_filesystemzCliRunner.isolated_filesystem  s       ikk(+++
	HHHHSMMMMM"%%%%%   DD   HSMMMMM"%%%%   D  sB    B	 A6 6
BB	C%B;:C;
CCCC)r   NFTr   )r   r#   r   r   r   r   r   r   r   r   r   r   )r   r   r   r#   r&   )r   r   r   r   )NNF)r   r   r   r   r   r   r   r   )NNNNF)r   r   r  r  r   r   r   r   r   r   r   r   r  r$   r   r   )r(  r)  r   r*  )rL   rM   rN   rl   rO   r    r   r   
contextlibcontextmanagerr  r'  r4  r;   r!   r   r   r   =  sP        " "H LLL&&&& 48 !%$    ," " " " AE      3748	C, C, C, C, C,P 152648(,O
 O
 O
 O
 O
b 8<      r!   r   )rP   rQ   r   rR   )r   r   r   r#   r   r   )/
__future__r   collections.abcabccabcr5  r   r_   r   r  r   ra   typingr   typesr   r   r   r   r   r	   r
   TYPE_CHECKING	_typeshedr   corer   r   Literalr   rO   tupler   BaseExceptionr   r   r6  rT   rV   r   rn   r|   TextIOWrapperr   r   r   r   r;   r!   r   <module>rD     s   " " " " " " "           				 				 



  



                                    ( ( ( ( ( (? ((((((<7 y/K///// y5K5555"4#6}#TU U U U U#! #! #! #! #! #! #! #!L    " " " " " " " "J         "*      *7 7 7 7 7 7 7 7$4 4 4 4 4"* 4 4 4n   (S4 S4 S4 S4 S4 S4 S4 S4lG G G G G G G G G Gr!   