
    [h?                        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  G d
 d          Ze j        dej        e         dej        d         fd            Z G d dej                  Zdej        ej        eeej        ej                 f                  dedej         fdZ! G d d          Z" G d d          Z#dS )    N)TracebackType   )_compat)
formatting)termui)utils)_find_binary_reader)BaseCommandc                       e Zd Zdej        dej        ddfdZdedej        fdZde	de	fd	Z
ddede	fdZddede	fdZddede	fdZdej        e	         fdZdej        e	         fdZdefdZdS )EchoingStdininputoutputreturnNc                 0    || _         || _        d| _        d S )NF)_input_output_paused)selfr   r   s      \/var/www/api.easyaligner.net/htdocs/venv_linux/lib/python3.11/site-packages/click/testing.py__init__zEchoingStdin.__init__   s        xc                 ,    t          | j        |          S N)getattrr   )r   r   s     r   __getattr__zEchoingStdin.__getattr__   s    t{A&&&r   rvc                 H    | j         s| j                            |           |S r   )r   r   write)r   r   s     r   _echozEchoingStdin._echo   s'    | 	#Lr"""	r   nc                 \    |                      | j                            |                    S r   )r    r   readr   r"   s     r   r$   zEchoingStdin.read$   s$    zz$+**1--...r   c                 \    |                      | j                            |                    S r   )r    r   read1r%   s     r   r'   zEchoingStdin.read1'   s$    zz$+++A..///r   c                 \    |                      | j                            |                    S r   )r    r   readliner%   s     r   r)   zEchoingStdin.readline*   s$    zz$+..q11222r   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   r1   zEchoingStdin.readlines-   s+    ????t{'<'<'>'>????r   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>1   s-      77aDJJqMM777777r   )iterr   r2   s   `r   __iter__zEchoingStdin.__iter__0   s(    77774;777777r   c                 *    t          | j                  S r   )reprr   r2   s    r   __repr__zEchoingStdin.__repr__3   s    DK   r   )r!   )__name__
__module____qualname__tBinaryIOr   strAnyr   bytesr    intr$   r'   r)   Listr1   Iteratorr7   r:   r,   r   r   r   r      s_       aj !*     
'S 'QU ' ' ' ' %    / /c /5 / / / /0 0s 0E 0 0 0 03 3# 3u 3 3 3 3@16%= @ @ @ @8!*U+ 8 8 8 8!# ! ! ! ! ! !r   r   streamr   c              #   >   K   | d V  d S d| _         d V  d| _         d S )NTF)r   )rF   s    r   _pause_echorH   7   s3      ~r   c            
            e Zd Zdej        dededej        ddf
 fdZedefd            Z	edefd	            Z
 xZS )
_NamedTextIOWrapperbuffernamemodekwargsr   Nc                 X     t                      j        |fi | || _        || _        d S r   )superr   _name_mode)r   rK   rL   rM   rN   	__class__s        r   r   z_NamedTextIOWrapper.__init__B   s6     	**6***



r   c                     | j         S r   )rQ   r2   s    r   rL   z_NamedTextIOWrapper.nameI   
    zr   c                     | j         S r   )rR   r2   s    r   rM   z_NamedTextIOWrapper.modeM   rU   r   )r;   r<   r=   r>   r?   r@   rA   r   propertyrL   rM   __classcell__)rS   s   @r   rJ   rJ   A   s        j(+36BC%	      c    X c    X    r   rJ   r   charsetc                 F   t          | d          rOt          t          j        t          j        t          j                 |                     }||S t          d          | d} n*t          | t                    r| 	                    |          } t          j        |           S )Nr$   z.Could not find binary reader for input stream.r   )hasattrr	   r>   castIOrA   	TypeError
isinstancer@   encodeioBytesIO)r   rY   r   s      r   make_input_streamrc   R   s     uf J QUU!;!;<<>IHIII}	E3		 &W%%:er   c                      e Zd ZdZ	 ddddedej        e         dej        ded	ej        e	         d
ej        ej
        ej        e	         e	ef                  fdZedefd            Zedefd            Zedefd            ZdefdZdS )Resultz3Holds the captured result of an invoked CLI script.Nrunner	CliRunnerstdout_bytesstderr_bytesreturn_value	exit_code	exceptionexc_infoc                 h    || _         || _        || _        || _        || _        || _        || _        d S r   rf   rh   ri   rj   rk   rl   rm   )r   rf   rh   ri   rj   rk   rl   rm   s           r   r   zResult.__init__i   s>     (( )"" r   r   c                     | j         S )z(The (standard) output as unicode string.)stdoutr2   s    r   r   zResult.output   s     {r   c                 t    | j                             | j        j        d                              dd          S )z&The standard output as unicode string.replace

)rh   decoderf   rY   rs   r2   s    r   rq   zResult.stdout   s9      ''(;YGGOOD
 
 	
r   c                     | j         t          d          | j                             | j        j        d                              dd          S )z%The standard error as unicode string.Nzstderr not separately capturedrs   rt   ru   )ri   
ValueErrorrv   rf   rY   rs   r2   s    r   stderrzResult.stderr   sQ     $=>>> ''(;YGGOOD
 
 	
r   c                 r    | j         rt          | j                   nd}dt          |           j         d| dS )Nokay< >)rl   r9   typer;   )r   exc_strs     r   r:   zResult.__repr__   s?    *..D$t~&&&f34::&333333r   r   )r;   r<   r=   __doc__rB   r>   OptionalrA   rC   BaseExceptionTupleTyper   r   rW   r@   r   rq   ry   r:   r,   r   r   re   re   f   s;       == ! !! ! j'	!
 e! ! :m,! *GAF=)=-GH
! ! ! !:     X 
 
 
 
 X
 
 
 
 
 X
4# 4 4 4 4 4 4r   re   c                      e Zd ZdZ	 	 	 	 ddedej        ej        eej        e         f                  ded	ed
df
dZ	ddd
efdZ
	 ddej        ej        eej        e         f                  d
ej        eej        e         f         fdZej        	 	 	 ddej        ej        eeej        ej                 f                  dej        ej        eej        e         f                  ded
ej        ej        ej        ej        ej                 f                  fd            Z	 	 	 	 	 ddddej        ej        eej        e         f                  dej        ej        eeej        ej                 f                  dej        ej        eej        e         f                  dededej        d
efdZej        	 ddej        ej        edf                  d
ej        e         fd            ZdS )rg   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 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-8NFTrY   env
echo_stdin
mix_stderrr   c                 B    || _         |pi | _        || _        || _        d S r   )rY   r   r   r   )r   rY   r   r   r   s        r   r   zCliRunner.__init__   s(     47I2$$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)rL   )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   colorc              #   ^	  K   t          || j                  }d}t          j        }t          j        }t          j        }t          j        }	dt          _        |                     |          }t          j
                    }
| j        r/t          j        t          j        t          ||
                    x}}t!          || j        dd          xt          _        | j        rd_        t!          |
| j        dd          t          _        d}| j        rt          j        t          _        n6t          j
                    }t!          || j        d	dd
          t          _        t'          |          ddt          j        t*                   dt*          ffd            }t'          |          ddt          j        t*                   dt*          ffd            }t'          |          dt,          dt*          fd            }|	 ddt          j        t          j        t          j                          dt          j        t,                   dt,          ffd}t2          j        }t2          j        }t2          j        }t:          j        }t>          j        }|t2          _        |t2          _        |t2          _        |t:          _        |t>          _        i }	 |                                 D ]W\  }}tB          j"        #                    |          ||<   |	 tB          j"        |= 8# tH          $ r Y Dw xY w|tB          j"        |<   X|
|fV  |                                 D ]5\  }}|	 tB          j"        |= # tH          $ r Y "w xY w|tB          j"        |<   6|t          _        |t          _        |t          _        |t2          _        |t2          _        |t2          _        |t:          _        |t>          _        |	t          _        dS # |                                 D ]5\  }}|	 tB          j"        |= # tH          $ r Y "w xY w|tB          j"        |<   6|t          _        |t          _        |t          _        |t2          _        |t2          _        |t2          _        |t:          _        |t>          _        |	t          _        w xY w)an  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.

        .. 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)encodingrL   rM   r   z<stdout>wz<stderr>backslashreplace)r   rL   rM   errorspromptr   c                    t           j                            | pd                                                               d          }t           j                            | d           t           j                                         |S )N rt   ru   )sysrq   r   r)   rstripflush)r   val
text_inputs     r   visible_inputz*CliRunner.isolation.<locals>.visible_input  sq    JV\r***%%''..v66CJZZZ(((JJr   c                     t           j                            | pd d           t           j                                                                                             d          S )Nr   ru   rt   )r   rq   r   r   r)   r   )r   r   s    r   hidden_inputz)CliRunner.isolation.<locals>.hidden_input  sZ    J"000111J&&((//777r   echoc                     t           j                            d          }| rt           j                            |           t           j                                         |S )Nr   )r   stdinr$   rq   r   r   )r   chars     r   _getcharz%CliRunner.isolation.<locals>._getchar$  sL    9>>!$$D '
  &&&JKr   rF   r   c                     | S | S r   r,   )rF   r   default_colors     r   should_strip_ansiz.CliRunner.isolation.<locals>.should_strip_ansi0  s     }(((9r   r   )NN)%rc   rY   r   r   rq   ry   r   FORCED_WIDTHr   ra   rb   r   r>   r\   r?   r   rJ   _CHUNK_SIZEr   rH   r   r@   boolr]   rA   r   visible_prompt_funchidden_prompt_funcr   r   r   r   itemsosenvironget	Exception)r   r   r   r   bytes_input
echo_input	old_stdin
old_stdout
old_stderrold_forced_widthbytes_outputbytes_errorr   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   	isolationzCliRunner.isolation   s     6 (t|<<
I	Z
Z
%2"$
mmC  z||? 	'(v
LlCC( ( K* "5$,YS"
 "
 "
 	
	J ? 	' &'J"(4<js
 
 

 ? 
	CJJ*,,K,)  CJ 
Z	 	 	 	!*S/ 	S 	 	 	 	 	 
!	 	 
Z	 	 	8 	8C 	8C 	8 	8 	8 	8 	8 
!	 	8
 
Z	 	 	4 	C 	 	 	 
!	 	  OS	 	JqtAE{+	;<:d;K		 	 	 	 	 	 #)"<!'!:"O % 7(/(A%%2"$0!""3$5!	7!iikk , ,
U!z~~c22=JsOO$    ',BJsOO----%mmoo , ,
U=JsOO$    ',BJsOO#CJ#CJ!CI)@F&(>F%/FO&;E#(EG%&6J###! &mmoo , ,
U=JsOO$    ',BJsOO#CJ#CJ!CI)@F&(>F%/FO&;E#(EG%&6J#6666sg   
=O4 LO4 
L# O4 "L##O4 M&&
M32M34R,PR,
P,	)R,+P,	,B R,argscatch_exceptionsextrac           	      0   d}|                      |||          5 }	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        t          j        t          j        t           t          j        f                  |j                  }|d}|dk    r|}t          |t                     sMt          j                            t          |                     t          j                            d           d}|}Y d}~n4d}~wt*          $ r$}|s |}d}t          j                    }Y d}~nd}~ww xY wt          j                                         |	d                                         }| j        rd}n||	d                                         }na# t          j                                         |	d                                         }| j        rd}n|	d                                         }w xY wddd           n# 1 swxY w Y   t3          | |||
|||	          S )
a  Invokes a command in an isolated environment.  The arguments are
        forwarded directly to the command line script, the `extra` keyword
        arguments are passed to the :meth:`~clickpkg.Command.main` function of
        the command.

        This returns a :class:`Result` object.

        :param cli: the command to invoke
        :param args: the arguments to invoke. It may be given as an iterable
                     or a string. When given as string it will be interpreted
                     as a Unix shell command. More details at
                     :func:`shlex.split`.
        :param input: the input data for `sys.stdin`.
        :param env: the environment overrides.
        :param catch_exceptions: Whether to catch any other exceptions than
                                 ``SystemExit``.
        :param extra: the keyword arguments to pass to :meth:`main`.
        :param color: whether the output should contain color codes. The
                      application can still override this explicitly.

        .. versionchanged:: 8.0
            The result object has the ``return_value`` attribute with
            the value returned from the invoked command.

        .. versionchanged:: 4.0
            Added the ``color`` parameter.

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

        .. versionchanged:: 3.0
            The result object has the ``exc_info`` attribute with the
            traceback if available.
        N)r   r   r   r   	prog_namer,   )r   r   ru   r   ro   )r   r_   r@   shlexsplitpopKeyErrorr   main
SystemExitr   rm   r>   r\   r   UnionrC   rA   coderq   r   r   r   getvaluer   re   )r   r   r   r   r   r   r   r   rm   
outstreamsrj   rl   rk   r   ee_coderq   ry   s                     r   invokezCliRunner.invokea  s   X ^^%S^>> ,	6*L37II$$$ ){4((<!IIk22		 < < < 66s;;			<6'sxVTZR9VVPUVV # # #<>>
173:+> ?HH>FQ;; !I!&#.. J$$S[[111J$$T***F"						 * * *' 		<>>* 
  """#A//11? 6!FF']3355FF 
  """#A//11? 6!FF']3355F5555Y,	6 ,	6 ,	6 ,	6 ,	6 ,	6 ,	6 ,	6 ,	6 ,	6 ,	6 ,	6 ,	6 ,	6 ,	6\ %
 
 
 	
s   0I7A"!I7"BI7BI7BH

F*&CE94H
9F*F% H
%F**H
-AI7
AI((I77I;>I;temp_dirzos.PathLike[str]c              #     K   t          j                    }t          j        |          }t          j        |           	 |V  t          j        |           |(	 t          j        |           dS # t          $ r Y dS w xY wdS # t          j        |           |&	 t          j        |           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.
        )dirN)r   getcwdtempfilemkdtempchdirshutilrmtreeOSError)r   r   cwddts       r   isolated_filesystemzCliRunner.isolated_filesystem  s        ikk(+++
		HHHHSMMMM"%%%%%   DD   HSMMMM"%%%%   D  sB    B A1 1
A?>A?CB10C1
B>;C=B>>C)r   NFTr   )NNF)NNNTF)r;   r<   r=   r   r@   r>   r   Mappingr   r   r   r   
contextlibcontextmanagerr   rB   r]   rA   rE   r   ra   rb   r   Sequencere   r   r   r,   r   r   rg   rg      s        ( ;? 
% 
%
% Z	#qz#"678
% 	
%
 
% 

% 
% 
% 
%" "3 " " " " HL AIc1:c?.B$CD	
3
3'	(     ?C;?	O7 O7z!'#uad15k"9:;O7 Z	#qz#"678O7 	O7
 
AGBJ
2:(>>?	@O7 O7 O7 O7h ;?>B;?!%c
 c
c
 jajo!567c
 z!'#uad15k"9:;	c

 Z	#qz#"678c
 c
 c
 c
 
c
 c
 c
 c
J GK 
1730B+B#CD	
C     r   rg   )$r   ra   r   r   r   r   r   typingr>   typesr   r   r   r   r   r   r	   TYPE_CHECKINGcorer
   r   r   r   rE   rH   TextIOWrapperrJ   r   r@   rB   r]   rA   r?   rc   re   rg   r,   r   r   <module>r      s!       				 				   



                                    ( ( ( ( ( (? "!!!!!!! ! ! ! ! ! ! !D 
<0 QZ5E        "*   ":agc5!$qu+567BEZ   (74 74 74 74 74 74 74 74tC C C C C C C C C Cr   