L iJddlmZddlmZddlZddlZddlZddlZddl Z ddl Z ddl Z ddl mZddlmZddlmZddlmZddlmZdd lmZe j*r dd lmZdd lmZGd d Zej6ddZGddej:ZGddZGddej@Z! ddZ"GddZ#GddZ$y)) annotationsN) TracebackType)_compat) formatting)termui)utils)_find_binary_reader)ReadableBuffer)CommandcZeZdZd dZd dZd dZdddZdddZdddZddZ ddZ dd Z y ) EchoingStdinc.||_||_d|_y)NF)_input_output_paused)selfinputoutputs S/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/click/testing.py__init__zEchoingStdin.__init__s   c.t|j|SN)getattrrrxs r __getattr__zEchoingStdin.__getattr__st{{A&&rcT|js|jj||Sr)rrwrite)rrvs r_echozEchoingStdin._echo"s || LL  r " rcV|j|jj|Sr)r"rreadrns rr$zEchoingStdin.read(s zz$++**1-..rcV|j|jj|Sr)r"rread1r%s rr(zEchoingStdin.read1+s zz$++++A.//rcV|j|jj|Sr)r"rreadliner%s rr*zEchoingStdin.readline.s zz$++..q122rcz|jjDcgc]}|j|c}Scc}wr)r readlinesr"rs rr,zEchoingStdin.readlines1s+'+{{'<'<'>?! 1 ???s8c@tfdjDS)Nc3@K|]}j|ywr)r").0rrs r z(EchoingStdin.__iter__..5s7aDJJqM7s)iterrrs`r__iter__zEchoingStdin.__iter__4s74;;777rc,t|jSr)reprrr2s r__repr__zEchoingStdin.__repr__7sDKK  rN)r t.BinaryIOrr7returnNone)rstrr8t.Any)r!bytesr8r<))r&intr8r<)r8z list[bytes])r8zcabc.Iterator[bytes]r8r:) __name__ __module__ __qualname__rrr"r$r(r*r,r3r6rrrrs0 ' /03@8!rrc#>K|dyd|_dd|_yw)NTF)r)streams r _pause_echorF;s ~  sc<eZdZdZdfd Zdfd Zdfd ZxZS) BytesIOCopyzdPatch ``io.BytesIO`` to let the written stream be copied to another. .. versionadded:: 8.2 c0t|||_yr)superrcopy_to)rrK __class__s rrzBytesIOCopy.__init__Ks  rcVt||jjyr)rJflushrK)rrLs rrNzBytesIOCopy.flushOs   rcX|jj|t||Sr)rKr rJ)rbrLs rr zBytesIOCopy.writeSs$ 1w}Qr)rKz io.BytesIOr8r9r8r9)rPr r8r>)r@rArB__doc__rrNr __classcell__rLs@rrHrHEs   rrHc eZdZdZddZddZy) StreamMixerzMixes `` and `` streams. The result is available in the ``output`` attribute. .. versionadded:: 8.2 ctj|_t|j|_t|j|_y)N)rK)ioBytesIOrrHstdoutstderrr2s rrzStreamMixer.__init__`s/"$**, "-dkk"B "-dkk"B rc|jj|jj|jjy)z Guarantee that embedded file-like objects are closed in a predictable order, protecting against races between self.output being closed and other streams being flushed on close .. versionadded:: 8.2.2 N)r[closerZrr2s r__del__zStreamMixer.__del__es4   rNrQ)r@rArBrRrr^rCrrrVrVXsC rrVcXeZdZ dfd ZeddZeddZxZS)_NamedTextIOWrapperc Bt||fi|||_||_yr)rJr_name_mode)rbuffernamemodekwargsrLs rrz_NamedTextIOWrapper.__init__ss% *6*  rc|jSr)rbr2s rrez_NamedTextIOWrapper.namez zzrc|jSr)rcr2s rrfz_NamedTextIOWrapper.mode~rir) rdr7rer:rfr:rgr;r8r9r?)r@rArBrpropertyrerfrSrTs@rr`r`rsX (+36BG rr`ct|dr.ttjd|}||St d|d}n!t |t r|j|}tj|S)Nr$z t.IO[t.Any]z.Could not find binary reader for input stream.r) hasattrr tcast TypeError isinstancer:encoderXrY)rcharsetr!s rmake_input_streamrtsjuf  u!= > >IHII } E3  W% ::e rcxeZdZdZ d d dZed dZed dZed dZd dZ y) ResultaCHolds 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 t||_||_||_||_||_||_||_||_yrrunner stdout_bytes stderr_bytes output_bytes return_value exit_code exceptionexc_info) rryrzr{r|r}r~rrs rrzResult.__init__s@ ((((""  rc|jj|jjdj ddS)aThe 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 `` and ``, in the order they were written. replace  )r|decoderyrsrr2s rrz Result.outputs9  '' (;(;YGOO D  rc|jj|jjdj ddS)z&The standard output as unicode string.rrr)rzrryrsrr2s rrZz Result.stdouts9  '' (;(;YGOO D  rc|jj|jjdj ddS)zThe standard error as unicode string. .. versionchanged:: 8.2 No longer raise an exception, always returns the `` string. rrr)r{rryrsrr2s rr[z Result.stderrs9  '' (;(;YGOO D  rc|jrt|jnd}dt|jd|dS)Nokay< >)rr5typer@)rexc_strs rr6zResult.__repr__s8*...$t~~&f4:&&'q 33rr)ry CliRunnerrzr<r{r<r|r<r}r;r~r>rzBaseException | Nonerz?tuple[type[BaseException], BaseException, TracebackType] | Noner?) r@rArBrRrrkrrZr[r6rCrrrvrvs>!!! !  !  !!(!!*        4rrvceZdZdZ d d dZd dZ d d dZej d ddZ d ddZ ej d ddZ y)raThe 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 `` writes to ``. 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. NcD||_|xsi|_||_||_yr)rsenv echo_stdincatch_exceptions)rrsrrrs rrzCliRunner.__init__s% 25)$ 0rc"|jxsdS)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)re)rclis rget_default_prog_namezCliRunner.get_default_prog_names xx!6!rcVt|j}|r|j||S)z8Returns the environment overrides for invoking a script.)dictrupdate)r overridesr!s rmake_envzCliRunner.make_envs%$((^  IIi  rc#bKt||j}d}tj}tj}tj }t j} dt _|j|}t} |jr:tjtjt|| jx}}t||jddxt_|jrd_t| j|jddt_t| j |jd dd t_t#|ddfd } t#|ddfd } t#|dd} | d dfd }t$j&}t$j(}t$j*}t,j.}t0j.}| t$_| t$_| t$_|t,_|t0_i} |j3D]O\}}t4j6j9|||<| t4j6|==|t4j6|<Q| j| j | j<f|j3D]-\}}| t4j6|=|t4j6|</|t_|t_|t_|t$_|t$_|t$_|t,_|t0_| t _y#t:$rY'wxYw#t:$rYwxYw#|j3D]<\}}|" t4j6|=#t:$rY&wxYw|t4j6|<>|t_|t_|t_|t$_|t$_|t$_|t,_|t0_| t _wxYww)a\A context manager that sets up the isolation for invoking of a command line tool. This sets up `` 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 `` and `` streams. .. versionchanged:: 8.2 Always returns the `` stream. .. versionchanged:: 8.0 `` is opened with ``errors="backslashreplace"`` instead of the default ``"strict"``. .. versionchanged:: 4.0 Added the ``color`` parameter. NPzr)encodingrerfrzwzbackslashreplace)rrerferrorsc<tjj|xsd tj d}tjj|dtjj|S#t $r}t |d}~wwxYw)Nrr)sysrZr nextrstrip StopIterationEOFErrorrN)promptvale text_inputs r visible_inputz*CliRunner.isolation..visible_input`s~ JJ  V\r * (:&--f5 JJ  uBZ ( JJ   J ! (ja' (sB B BBctjj|xsddtjj t j dS#t $r}t|d}~wwxYw)Nrrr)rrZr rNrrrr)rrrs r hidden_inputz)CliRunner.isolation..hidden_inputkse JJ   "~R0 1 JJ    (J'..v66  (ja' (sA!! A:* A55A:ctjjd}|rtjj |tjj |S)Nr)rstdinr$rZr rN)echochars r_getcharz%CliRunner.isolation.._getcharts>99>>!$D   & JJ   Krc| S| SrrC)rEcolor default_colors rshould_strip_ansiz.CliRunner.isolation..should_strip_ansis}(((9 rr)rz str | Noner8r:)rboolr8r:)NN)rEzt.IO[t.Any] | Noner bool | Noner8r)rtrsrrrZr[r FORCED_WIDTHrrVrrnroBinaryIOrr` _CHUNK_SIZErFrvisible_prompt_funchidden_prompt_funcrr rritemsosenvironget Exceptionr)rrrr bytes_input echo_input old_stdin old_stdout old_stderrold_forced_width stream_mixerrrrrold_visible_prompt_funcold_hidden_prompt_funcold__getchar_funcold_should_strip_ansiold__compat_should_strip_ansiold_envkeyvaluerrs @@r isolationzCliRunner.isolationsD(t||<  II ZZ ZZ %22"$ mmC "} ??'(vv Ll6I6IJ( K*"5 $,,YS"   J ??&'J "(   $,,Zc  )   \\%    Z   !  Z  ( ! ( Z   !  EI & 6A   #)"<"<!'!:!:"OO % 7 7(/(A(A%%2"$0!""3$5! 7!iik , U!zz~~c2 =JJsO',BJJsO , && (;(;\=P=PQ 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 #sH)P/.:M8)M:;M85P/M)A:P/ M&"M8%M&&M8) M52P/4M55P/8P,N$#P,$ N0 -P,/N0 0ArZr rrNr[getvaluerv)rrrrrrrextrar outstreamsr}rr~rre_coderZr[rs rinvokezCliRunner.invokesGj  ##44  ^^%S^ >+ 2*L.2II$${{4( <!IIk2  2'sxxVTZR9VPUV 2   "   "#A//1#A//1#A//1W+ 2Z%  G < 66s;  <  #<<> 4aff=>FQ; !I!&#.JJ$$S[1JJ$$T*F"  *'  <<>  *   "   "#A//1#A//1#A//1W+ 2+ 2st,JD$D.=A5JD+(J*D++J. H 7BGH  H #H>H H  H  A7JJJc#Ktj}tj|}tj| |tj||ddl} |j |yy#t$rYywxYw#tj||&ddl} |j |w#t$rYwwxYwwxYww)aA 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)rgetcwdtempfilemkdtempchdirshutilrmtreeOSError)rtemp_dircwddtrs risolated_filesystemzCliRunner.isolated_filesystem"s iik   ( +   H HHSMMM"%   HHSMMM"%  sfACBC#A64C6 B?CBCC"B43C4 C=C?CCC)zutf-8NFT) rsr:r$cabc.Mapping[str, str | None] | Nonerrrrr8r9)rr r8r:r)rrr8zcabc.Mapping[str, str | None])NNF)r str | bytes | t.IO[t.Any] | Nonerrrrr8z8cabc.Iterator[tuple[io.BytesIO, io.BytesIO, io.BytesIO]])NNNNF)rr rzstr | cabc.Sequence[str] | Nonerrrrrrrrrr;r8rv)rzstr | os.PathLike[str] | Noner8zcabc.Iterator[str]) r@rArBrRrrr contextlibcontextmanagerrrrrCrrrrsY.48 !% 1 12 1 1  1  1"AE= &3748 W7/W72W7 W7 B W7W7x152648(,o o .o 0 o 2 o & o o o  o b8<5 rr)rEzEchoingStdin | Noner8zcabc.Iterator[None])rrrsr:r8r7)% __future__rcollections.abcabccabcrrXrrrrtypingrntypesrrrrrr r TYPE_CHECKING _typeshedr corer rrrFrYrHrV TextIOWrapperr`rtrvrrCrrrs" (??(!!D  "** &4"**" +69(K4K4\\\r