jf>ddlZddlZddlZddlZddlZddlZddlZddlZddl m Z ddl m Z ddl m Z ddl mZddlmZejrddlmZGd d Zejd ejed ejdfd ZGddejZdejejeeejejfded ej fdZ!GddZ"GddZ#dS)N) TracebackType) formatting)termui)utils)_find_binary_reader) BaseCommandceZdZdejdejddfdZdedejfdZde de fd Z dd e de fd Z dd e de fd Z dd e de fdZdeje fdZdeje fdZdefdZdS) EchoingStdininputoutputreturnNc0||_||_d|_dS)NF)_input_output_paused)selfr r s m/builddir/build/BUILD/imunify360-venv-2.3.5/opt/imunify360/venv/lib/python3.11/site-packages/click/testing.py__init__zEchoingStdin.__init__s   xc,t|j|SN)getattrr)rrs r __getattr__zEchoingStdin.__getattr__st{A&&&rrvcH|js|j||Sr)rrwrite)rrs r_echozEchoingStdin._echos'| # L  r " " " rnc\||j|Sr)rrreadrr!s rr#zEchoingStdin.read#s$zz$+**1--...rc\||j|Sr)rrread1r$s rr&zEchoingStdin.read1&s$zz$+++A..///rc\||j|Sr)rrreadliner$s rr(zEchoingStdin.readline)s$zz$+..q11222rcNfdjDS)Nc:g|]}|Sr.0rrs r z*EchoingStdin.readlines..-s#???! 1 ???r)r readlinesrs`rr0zEchoingStdin.readlines,s+????t{'<'<'>'>????rcDtfdjDS)Nc3BK|]}|VdSrr,r-s r z(EchoingStdin.__iter__..0s-77aDJJqMM777777r)iterrr1s`r__iter__zEchoingStdin.__iter__/s(77774;777777rc*t|jSr)reprrr1s r__repr__zEchoingStdin.__repr__2sDK   r)r )__name__ __module__ __qualname__tBinaryIOrstrAnyrbytesrintr#r&r(Listr0Iteratorr6r9r+rrr r s_aj!* 'S'QU''''% //c/5////00s0E000033#3u3333@16%=@@@@8!*U+8888!#!!!!!!rr streamrc#>K|dVdSd|_dVd|_dS)NTF)r)rEs r _pause_echorG6s3 ~  rc eZdZdejdededejddf fd ZedefdZ edefd Z xZ S) _NamedTextIOWrapperbuffernamemodekwargsrNc Xtj|fi|||_||_dSr)superr_name_mode)rrJrKrLrM __class__s rrz_NamedTextIOWrapper.__init__As6 **6***  rc|jSr)rPr1s rrKz_NamedTextIOWrapper.nameH zrc|jSr)rQr1s rrLz_NamedTextIOWrapper.modeLrTr) r:r;r<r=r>r?r@rpropertyrKrL __classcell__)rRs@rrIrI@sj(+36BC% cXcXrrIr charsetcFt|drOttjtjtj|}||St d|d}n*t|tr| |}tj |S)Nr#z.Could not find binary reader for input stream.r) hasattrrr=castIOr@ TypeError isinstancer?encodeioBytesIO)r rXrs rmake_input_streamrbQsufJ QU U!;!; < < >IHIII } E3  & W%% :e  rceZdZdZ ddddedejedejded eje d ejej ej e e e ffd Z ed efd Zed efdZed efdZd efdZdS)Resultz3Holds the captured result of an invoked CLI script.Nrunner CliRunner stdout_bytes stderr_bytes return_value exit_code exceptionexc_infoch||_||_||_||_||_||_||_dSrrergrhrirjrkrl)rrergrhrirjrkrls rrzResult.__init__hs> (()""  rrc|jS)z(The (standard) output as unicode string.)stdoutr1s rr z Result.outputs {rct|j|jjdddS)z&The standard output as unicode string.replace  )rgdecodererXrrr1s rrpz Result.stdouts9 '' (;YGGOO D   rc|jtd|j|jjdddS)z%The standard error as unicode string.Nzstderr not separately capturedrrrsrt)rh ValueErrorrurerXrrr1s rstderrz Result.stderrsQ   $=>> > '' (;YGGOO D   rcr|jrt|jnd}dt|jd|dS)Nokay< >)rkr8typer:)rexc_strs rr9zResult.__repr__s?*..D$t~&&&f34::&333333rr)r:r;r<__doc__rAr=Optionalr@rB BaseExceptionTupleTyperrrVr?r rprxr9r+rrrdrdes;== !!!!j' ! e !  !:m,!* GAF=)=-G H !!!!:X    X     X 4#444444rrdceZdZdZ ddedejejeejefded ed df d Z d d d efdZ ddejejeejefd ejeejeffdZ e j ddejejeeejejfdejejeejefded ejejejejejffdZ dd d dejejeejefdejejeeejejfdejejeejefdededejd efdZe j ddejejedfd ejefdZdS)rfaThe 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-8NFTrXenv echo_stdin mix_stderrrcB||_|pi|_||_||_dSr)rXrrr)rrXrrrs rrzCliRunner.__init__s( 47I2$$rclir c|jpdS)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)rK)rrs rget_default_prog_namezCliRunner.get_default_prog_names x!6!r overridesc\t|j}|r|||S)z8Returns the environment overrides for invoking a script.)dictrupdate)rrrs rmake_envzCliRunner.make_envs0$(^^  ! IIi  rr colorc#Kt||j}d}tj}tj}tj}t j} dt _||}tj } |j r/tj tjt|| x}}t!||jddxt_|j rd_t!| |jddt_d} |jrtjt_n6tj } t!| |jd dd t_t'|dd tjt*d t*ffd } t'|dd tjt*d t*ffd } t'|dt,d t*fd}| ddtjtjtjdtjt,d t,ffd }t2j}t2j}t2j}t:j}| t2_| t2_|t2_|t:_i} |D]W\}}t@j!"|||<| t@j!|=8#tF$rYDwxYw|t@j!|<X| | fV|D]5\}}| t@j!|=#tF$rY"wxYw|t@j!|<6|t_|t_|t_|t2_|t2_|t2_|t:_| t _dS#|D]5\}}| t@j!|=#tF$rY"wxYw|t@j!|<6|t_|t_|t_|t2_|t2_|t2_|t:_| t _wxYw)anA 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. NPzr)encodingrKrLrzwzbackslashreplace)rrKrLerrorspromptrctj|pdd}tj|dtj|S)Nrsrt)sysrprr(rstripflush)rval text_inputs r visible_inputz*CliRunner.isolation..visible_inputsq J  V\r * * *%%''..v66C J  ZZZ ( ( ( J     Jrctj|pddtjdS)Nrrtrs)rrprrr(r)rrs r hidden_inputz)CliRunner.isolation..hidden_inputsZ J   "000 1 1 1 J     &&((//77 7rechoctjd}|rtj|tj|S)Nr)rstdinr#rprr)rchars r_getcharz%CliRunner.isolation.._getchar#sL9>>!$$D '   &&& J     KrrErc| S| Srr+)rEr default_colors rshould_strip_ansiz.CliRunner.isolation..should_strip_ansi/s}(((9 rr)NN)$rbrXrrrprxr FORCED_WIDTHrr`rarr=r[r>r rI _CHUNK_SIZErrGrr?boolr\r@rvisible_prompt_funchidden_prompt_funcrrritemsosenvironget Exception)rr rr bytes_input echo_input old_stdin old_stdout old_stderrold_forced_width bytes_output bytes_errorrrrrold_visible_prompt_funcold_hidden_prompt_funcold__getchar_funcold_should_strip_ansiold_envkeyvaluerrs @@r isolationzCliRunner.isolations6(t|<<  I Z Z %2"$ mmC  z|| ? '(v LlCC(( K*"5 $,YS" " "   J ? '&'J "( 4F %/FO&;E #&6J # # #&mmoo , , U=JsOO$',BJsOO#CJ#CJ!CI)@F &(>F %/FO&;E #&6J # 6 6 6 6sg2=O0 K>=O> L O L  O M MMQ<- O;:Q<; P Q<P A4Q<argscatch_exceptionsextrac 0d}||||5} d} d} d} t|trtj|} |d} n%#t $r||} YnwxYw |jd|pd| d|} n#t$r}tj }tj tjtjt tjf|j}|d}|dkr|} t|t sMtjt|tjdd}|} Yd}~n4d}~wt*$r$}|s|} d} tj }Yd}~nd}~wwxYwtj| d}|jrd}n|| d}na#tj| d}|jrd}n| d}wxYwdddn #1swxYwYt3|||| | | | S) aInvokes 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 rrr prog_namer+)rrrtrrn)rr^r?shlexsplitpopKeyErrorrmain SystemExitrrlr=r[rUnionrBr@coderprrrgetvaluerrd)rrrr rrrrrl outstreamsrirkrjree_coderprxs rinvokezCliRunner.invoke]sX ^^%S^ > >, 6*L37II$$$ ){4(( <!IIk22  < < < 66s;;  < 6'sxVTZR9VVPUVV  # # #<>> 173:+> ?HH>FQ;; !I!&#..J$$S[[111J$$T***F"  * * *'  <>>  *   """#A//11?6!FF']3355FF    """#A//11?6!FF']3355F5555Y, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6\%    s0I7 A"!I7"BI7BI7BH  F*&CE94H 9 F*F% H %F**H -AI7 AI((I77I;>I;temp_dirzos.PathLike[str]c#Ktj}tj|}tj| |Vtj||( t j|dS#t$rYdSwxYwdS#tj||& t j|w#t$rYwwxYwwxYw)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. )dirN)rgetcwdtempfilemkdtempchdirshutilrmtreeOSError)rrcwddts risolated_filesystemzCliRunner.isolated_filesystems ikk  ( + + +   HHH HSMMMM"%%%%%DD  HSMMMM"%%%%D sBBA11 A?>A?CB10C1 B>;C=B>>C)rNFTr)NNF)NNNTF)r:r;r<rr?r=rMappingrrrr contextlibcontextmanagerrrAr\r@rDrr`rarSequencerdrrr+rrrfrfs(;?  % % %Z #qz#"67 8 % %  %  % % % %""3""""HLAIc1:c?.B$CD 3 3' (?C;? L7L7z!'#uad15k"9:;L7Z #qz#"67 8L7 L7 AGBJ 2:(>>? @ L7L7L7L7b;?>B;?!%c c c jajo!567c z!'#uad15k"9:; c Z #qz#"67 8 c  c c c  c c c c JGK 1730B+B#CD Crrf)$rr`rrrrrtypingr=typesrrrrr_compatr TYPE_CHECKINGcorer r rrrDrG TextIOWrapperrIrr?rAr\r@r>rbrdrfr+rrrs ((((((?"!!!!!!!!!!!!!!D  <0QZ5E"*" :agc5!$qu+56 7BEZ(7474747474747474t@@@@@@@@@@r