
    ]hI                       S SK Jr  S SKJr  S SKrS SKrS SKrS SKrS SK	r	S SK
r
S SKrS SKrS SKJr  SSKJr  SSKJr  SSKJr  SSKJr  SS	KJr  \R,                  (       a  S S
KJr  SSKJr   " S S5      r\R8                  SS j5       r " S S\R<                  5      r " S S5      r  " S S\RB                  5      r"      SS jr# " S S5      r$ " S S5      r%g)    )annotationsN)TracebackType   )_compat)
formatting)termui)utils)_find_binary_reader)ReadableBuffer)Commandc                  z    \ rS rSrSS jrSS jrSS jrSSS jjrSSS jjrSSS jjr	SS jr
SS	 jrSS
 jrSrg)EchoingStdin   c                *    Xl         X l        SU l        g )NF_input_output_paused)selfinputoutputs      ?/var/www/html/env/lib/python3.13/site-packages/click/testing.py__init__EchoingStdin.__init__   s        c                .    [        U R                  U5      $ N)getattrr   r   xs     r   __getattr__EchoingStdin.__getattr__    s    t{{A&&r   c                ^    U R                   (       d  U R                  R                  U5        U$ r   )r   r   write)r   rvs     r   _echoEchoingStdin._echo#   s     ||LLr"	r   c                V    U R                  U R                  R                  U5      5      $ r   )r&   r   readr   ns     r   r)   EchoingStdin.read)   s     zz$++**1-..r   c                V    U R                  U R                  R                  U5      5      $ r   )r&   r   read1r*   s     r   r.   EchoingStdin.read1,   s     zz$++++A.//r   c                V    U R                  U R                  R                  U5      5      $ r   )r&   r   readliner*   s     r   r1   EchoingStdin.readline/   s     zz$++..q122r   c                ~    U R                   R                  5        Vs/ s H  oR                  U5      PM     sn$ s  snf r   )r   	readlinesr&   r   s     r   r4   EchoingStdin.readlines2   s/    '+{{'<'<'>?'>!

1'>???s   :c                B   ^  [        U 4S jT R                   5       5      $ )Nc              3  F   >#    U  H  nTR                  U5      v   M     g 7fr   )r&   ).0r    r   s     r   	<genexpr>(EchoingStdin.__iter__.<locals>.<genexpr>6   s     7;aDJJqMM;s   !)iterr   r   s   `r   __iter__EchoingStdin.__iter__5   s    74;;777r   c                ,    [        U R                  5      $ r   )reprr   r<   s    r   __repr__EchoingStdin.__repr__8   s    DKK  r   r   N)r   
t.BinaryIOr   rC   returnNone)r    strrD   t.Any)r%   bytesrD   rH   ))r+   intrD   rH   )rD   zlist[bytes])rD   zcabc.Iterator[bytes]rD   rF   )__name__
__module____qualname____firstlineno__r   r!   r&   r)   r.   r1   r4   r=   rA   __static_attributes__ r   r   r   r      s0    
'/03@8!r   r   c              #  @   #    U c  S v   g SU l         S v   SU l         g 7f)NTF)r   )streams    r   _pause_echorT   <   s     ~s   c                  P   ^  \ rS rSrSrSU 4S jjrSU 4S jjrS	U 4S jjrSrU =r	$ )
BytesIOCopyF   z\Patch ``io.BytesIO`` to let the written stream be copied to another.

.. versionadded:: 8.2
c                .   > [         TU ]  5         Xl        g r   )superr   copy_to)r   rZ   	__class__s     r   r   BytesIOCopy.__init__L   s    r   c                V   > [         TU ]  5         U R                  R                  5         g r   )rY   flushrZ   )r   r[   s    r   r^   BytesIOCopy.flushP   s    r   c                X   > U R                   R                  U5        [        TU ]  U5      $ r   )rZ   r$   rY   )r   br[   s     r   r$   BytesIOCopy.writeT   s$    1w}Qr   rZ   )rZ   z
io.BytesIOrD   rE   rD   rE   )ra   r   rD   rJ   )
rL   rM   rN   rO   __doc__r   r^   r$   rP   __classcell__r[   s   @r   rV   rV   F   s    
   r   rV   c                  "    \ rS rSrSrSS jrSrg)StreamMixerY   zvMixes `<stdout>` and `<stderr>` streams.

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

.. versionadded:: 8.2
c                    [         R                  " 5       U l        [        U R                  S9U l        [        U R                  S9U l        g )Nrc   )ioBytesIOr   rV   stdoutstderrr<   s    r   r   StreamMixer.__init__a   s/    "$**,"-dkk"B"-dkk"Br   )r   ro   rn   Nrd   )rL   rM   rN   rO   re   r   rP   rQ   r   r   ri   ri   Y   s    Cr   ri   c                  x   ^  \ rS rSr          SU 4S jjr\SS j5       r\SS j5       rSU 4S jjrSr	U =r
$ )	_NamedTextIOWrapperg   c                @   > [         TU ]  " U40 UD6  X l        X0l        g r   )rY   r   _name_mode)r   buffernamemodekwargsr[   s        r   r   _NamedTextIOWrapper.__init__h   s!     	*6*

r   c                    U R                   $ r   )ru   r<   s    r   rx   _NamedTextIOWrapper.nameo       zzr   c                    U R                   $ r   )rv   r<   s    r   ry   _NamedTextIOWrapper.modes   r~   r   c                `   >  [         TU ]  5       nU$ ! [         a  n[        5       UeS nAff = fr   )rY   __next__StopIterationEOFError)r   lineer[   s      r   r   _NamedTextIOWrapper.__next__w   s8    	$7#%D   	$*!#	$s    
-(-)rv   ru   )
rw   rC   rx   rF   ry   rF   rz   rG   rD   rE   rK   )rL   rM   rN   rO   r   propertyrx   ry   r   rP   rf   rg   s   @r   rr   rr   g   sb     (+36BG	     r   rr   c                   [        U S5      (       a0  [        [        R                  " SU 5      5      nUb  U$ [	        S5      eU c  Sn O&[        U [        5      (       a  U R                  U5      n [        R                  " U 5      $ )Nr)   zt.IO[t.Any]z.Could not find binary reader for input stream.r   )
hasattrr
   tcast	TypeError
isinstancerF   encoderl   rm   )r   charsetr%   s      r   make_input_streamr      sp     uf u!=>>IHII}	E3		W%::er   c                      \ rS rSrSr S
               SS jjr\SS j5       r\SS j5       r\SS j5       r	SS jr
S	rg)Result   a  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``.
Nc	                d    Xl         X l        X0l        X@l        XPl        X`l        Xpl        Xl        g r   runnerstdout_bytesstderr_bytesoutput_bytesreturn_value	exit_code	exceptionexc_info)	r   r   r   r   r   r   r   r   r   s	            r   r   Result.__init__   s0     (((("" r   c                    U R                   R                  U R                  R                  S5      R	                  SS5      $ )zThe 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   r<   s    r   r   Result.output   s9       ''(;(;YGOOD
 	
r   c                    U R                   R                  U R                  R                  S5      R	                  SS5      $ )z&The standard output as unicode string.r   r   r   )r   r   r   r   r   r<   s    r   rn   Result.stdout   s9       ''(;(;YGOOD
 	
r   c                    U R                   R                  U R                  R                  S5      R	                  SS5      $ )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   r<   s    r   ro   Result.stderr   s9       ''(;(;YGOOD
 	
r   c                    U R                   (       a  [        U R                   5      OSnS[        U 5      R                   SU S3$ )Nokay< >)r   r@   typerL   )r   exc_strs     r   rA   Result.__repr__   s8    *...$t~~&f4:&&'q	33r   )r   r   r   r   r   r   r   r   r   )r   	CliRunnerr   rH   r   rH   r   rH   r   rG   r   rJ   r   zBaseException | Noner   z?tuple[type[BaseException], BaseException, TracebackType] | NonerK   )rL   rM   rN   rO   re   r   r   r   rn   ro   rA   rP   rQ   r   r   r   r      s    > !! ! 	!
 ! ! ! (!!* 	
 	
 
 
 
 
4r   r   c                  
   \ rS rSrSr    S         SS jjrSS jr S   SS jjr\R                     S       SS jj5       r
     S               SS jjr\R                   S   SS	 jj5       rS
rg)r      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`.

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

.. versionchanged:: 8.2
    ``mix_stderr`` parameter has been removed.
Nc                H    Xl         U=(       d    0 U l        X0l        X@l        g r   )r   env
echo_stdincatch_exceptions)r   r   r   r   r   s        r   r   CliRunner.__init__   s     25)$ 0r   c                ,    UR                   =(       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)rx   )r   clis     r   get_default_prog_nameCliRunner.get_default_prog_name  s    
 xx!6!r   c                `    [        U R                  5      nU(       a  UR                  U5        U$ )z8Returns the environment overrides for invoking a script.)dictr   update)r   	overridesr%   s      r   make_envCliRunner.make_env
  s%     $((^IIi 	r   c              #    ^^#    [        XR                  5      nSn[        R                  n[        R                  n[        R
                  n[        R                  n	S[        l        U R                  U5      n[        5       n
U R                  (       a9  [        R                  " [        R                  [        XJR                  5      5      =pE[        X@R                  SSS9=[        l        mU R                  (       a  STl        [        U
R                  U R                  SSS9[        l        [        U
R
                  U R                  S	SS
S9[        l        [#        U5      SSU4S jjj5       n[#        U5      SSU4S jjj5       n[#        U5      SS j5       nUm S     SU4S jjjn[$        R&                  n[$        R(                  n[$        R*                  n[,        R.                  n[0        R.                  nU[$        l        U[$        l        U[$        l        U[,        l        U[0        l        0 n UR3                  5        HR  u  nn[4        R6                  R9                  U5      UU'   Uc   [4        R6                  U	 M?  U[4        R6                  U'   MT     U
R                  U
R
                  U
R<                  4v   UR3                  5        H0  u  nnUc   [4        R6                  U	 M  U[4        R6                  U'   M2     U[        l        U[        l        U[        l        U[$        l        U[$        l        U[$        l        U[,        l        U[0        l        U	[        l        g! [:         a     GM1  f = f! [:         a     M  f = f! UR3                  5        HA  u  nnUc%   [4        R6                  U	 M  ! [:         a     M*  f = fU[4        R6                  U'   MC     U[        l        U[        l        U[        l        U[$        l        U[$        l        U[$        l        U[,        l        U[0        l        U	[        l        f = f7f)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)encodingrx   ry   r   z<stdout>wz<stderr>backslashreplace)r   rx   ry   errorsc                  > [         R                  R                  U =(       d    S5        [        T5      R	                  S5      n[         R                  R                  U S35        [         R                  R                  5         U$ )N r   r   )sysrn   r$   nextrstripr^   )promptval
text_inputs     r   visible_input*CliRunner.isolation.<locals>.visible_input\  s[    JJV\r*z"))&1CJJuBZ(JJJr   c                   > [         R                  R                  U =(       d    S S35        [         R                  R                  5         [	        T5      R                  S5      $ )Nr   r   r   )r   rn   r$   r^   r   r   )r   r   s    r   hidden_input)CliRunner.isolation.<locals>.hidden_inputd  sF    JJ"~R01JJ
#**622r   c                    [         R                  R                  S5      nU (       a  [         R                  R	                  U5        [         R                  R                  5         U$ )Nr   )r   stdinr)   rn   r$   r^   )echochars     r   _getchar%CliRunner.isolation.<locals>._getcharj  s>    99>>!$D

  &JJKr   c                &   > Uc  T(       + $ U(       + $ r   rQ   )rS   colordefault_colors     r   should_strip_ansi.CliRunner.isolation.<locals>.should_strip_ansiv  s     }(((9r   r   )r   z
str | NonerD   rF   )r   boolrD   rF   )NN)rS   zt.IO[t.Any] | Noner   bool | NonerD   r   )r   r   r   r   rn   ro   r   FORCED_WIDTHr   ri   r   r   r   BinaryIOr   rr   _CHUNK_SIZErT   r   visible_prompt_funchidden_prompt_funcr   r	   r   r   itemsos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_ansiold_envkeyvaluer   r   s                          @@r   	isolationCliRunner.isolation  s    D (||<
II	ZZ
ZZ
%22"$
mmC "}??'(vv

L6I6IJ( K "5,,YS"
 	
	J ?? &'J"($,,Zc

 )\\%

 
Z	 	 	 
!	 
Z	 	3 	3 
!	3
 
Z	 	 
!	  EI	&	6A		 	 #)"<"<!'!:!:"OO % 7 7(/(A(A%%2"$0!""3$5!	7!iik
U!zz~~c2=JJsO ',BJJsO *  &&(;(;\=P=PQQ%mmo
U=JJsO ',BJJsO . $CJ#CJ!CI)@F&(>F%/FO&;E#(EG%&6J#- %  % 	 &mmo
U=JJsO$  ',BJJsO . $CJ#CJ!CI)@F&(>F%/FO&;E#(EG%&6J#s   H1Q	6;N 2M)>N Q	M;,A=Q	)
M83N 7M88N ;
N	Q	N		Q	Q'N:8Q:
O	QO	A>QQ	c                ^   SnUc  U R                   nU R                  X4US9 n	Sn
SnSn[        U[        5      (       a  [        R
                  " U5      n UR                  S5      n UR                  " SU=(       d    SUS.UD6n
[        R"                  R)                  5         [        R*                  R)                  5         U	S   R-                  5       nU	S	   R-                  5       nU	S
   R-                  5       n SSS5        [/        U WWWW
WWUS9$ ! [         a    U R                  U5      n Nf = f! [         a  n[        R                  " 5       n[        R                  " SUR                  5      nUc  SnUS:w  a  Un[        U[         5      (       dI  [        R"                  R%                  [        U5      5        [        R"                  R%                  S5        S	nUn SnAGNbSnAf[&         a,  nU(       d  e UnS	n[        R                  " 5       n SnAGNSnAff = f! [        R"                  R)                  5         [        R*                  R)                  5         U	S   R-                  5       nU	S	   R-                  5       nU	S
   R-                  5       nf = f! , (       d  f       GN= f)ak  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.
N)r   r   r   r   	prog_namerQ   )argsr  zint | t.Any | Noner   r      r   )r   r   r   rF   shlexsplitpopKeyErrorr   main
SystemExitr   r   r   r   coderJ   rn   r$   r   r^   ro   getvaluer   )r   r   r  r   r   r   r   extrar   
outstreamsr   r   r   r  r   e_codern   ro   r   s                      r   invokeCliRunner.invoke  sB   j ##44^^%^>*L.2II$$${{4(<!IIk2	2"xxVTZR9VPUV2 

  "

  "#A//1#A//1#A//1W ?Z %	
 		
G  < 66s;	<
  #<<> 4aff=>FQ; !I!&#..JJ$$S[1JJ$$T*F"	 *'		<<>* 

  "

  "#A//1#A//1#A//1W ?>st   2JD'D4A5JD1.J0D11J4
H >B#G'!H#'H 4!HH#H  H##A7JJ
J,c              #    #    [         R                  " 5       n[        R                  " US9n[         R                  " U5         Uv   [         R                  " U5        Uc   [
        R                  " U5        gg! [         a     gf = f! [         R                  " U5        Uc(   [
        R                  " U5        f ! [         a     f f = ff = f7f)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)r   temp_dircwddts       r   isolated_filesystemCliRunner.isolated_filesystem  s       iik(+
		HHHSMMM"%     HHSMMM"%   sf   A CB	 C!A9 7C9
BCBC	C$B;:C;
CCCCC)r   r   r   r   )zutf-8NFT)
r   rF   r   $cabc.Mapping[str, str | None] | Noner   r   r   r   rD   rE   )r   r   rD   rF   r   )r   r   rD   zcabc.Mapping[str, str | None])NNF)r    str | bytes | t.IO[t.Any] | Noner   r   r   r   rD   z8cabc.Iterator[tuple[io.BytesIO, io.BytesIO, io.BytesIO]])NNNNF)r   r   r  zstr | cabc.Sequence[str] | Noner   r!  r   r   r   r   r   r   r  rG   rD   r   )r  zstr | os.PathLike[str] | NonerD   zcabc.Iterator[str])rL   rM   rN   rO   re   r   r   r   
contextlibcontextmanagerr   r  r  rP   rQ   r   r   r   r      sY   . 48 !%
1
1 2
1 	
1
 
1 

1" AE=	&  3748	Q7/Q7 2Q7 	Q7
 
BQ7 Q7l 152648(,o
o
 .o
 0	o

 2o
 &o
 o
 o
 
o
b 8<5	 r   r   )rS   zEchoingStdin | NonerD   zcabc.Iterator[None])r   r!  r   rF   rD   rC   )&
__future__r   collections.abcabccabcr"  rl   r   r  r  r   r  typingr   typesr   r   r   r   r   r	   r
   TYPE_CHECKING	_typeshedr   corer   r   r#  rT   rm   rV   ri   TextIOWrapperrr   r   r   r   rQ   r   r   <module>r.     s    "   	 	   
        (??(! !D   "**  &C C"** 0+69(K4 K4\T Tr   