zmc
2023-08-08 e792e9a60d958b93aef96050644f369feb25d61b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
U
ß=®dÔ>ã@sddlZddlZddlZddlZddlZddlZddlZddlZddl    m
Z
ddl m Z ddl m Z ddl mZddlmZejrŽddlmZGd    d
„d
ƒZejejeejdd œd d „ƒZGdd„dejƒZejejeeejejfeej dœdd„Z!Gdd„dƒZ"Gdd„dƒZ#dS)éN)Ú TracebackTypeé)Ú
formatting)Útermui)Úutils)Ú_find_binary_reader)Ú BaseCommandc@s°eZdZejejddœdd„Zeejdœdd„Ze    e    dœd    d
„Z
de e    d œd d„Z de e    d œdd„Z de e    d œdd„Zeje    dœdd„Zeje    dœdd„Zedœdd„ZdS)Ú EchoingStdinN)ÚinputÚoutputÚreturncCs||_||_d|_dS)NF)Ú_inputÚ_outputÚ_paused)Úselfr
r ©rúDd:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\click/testing.pyÚ__init__szEchoingStdin.__init__)Úxr cCs t|j|ƒS©N)Úgetattrr )rrrrrÚ __getattr__szEchoingStdin.__getattr__)Úrvr cCs|js|j |¡|Sr)rrÚwrite)rrrrrÚ_echos zEchoingStdin._echoéÿÿÿÿ)Únr cCs| |j |¡¡Sr)rr Úread©rrrrrr#szEchoingStdin.readcCs| |j |¡¡Sr)rr Úread1rrrrr&szEchoingStdin.read1cCs| |j |¡¡Sr)rr Úreadlinerrrrr )szEchoingStdin.readline©r cs‡fdd„ˆj ¡DƒS)Ncsg|]}ˆ |¡‘qSr©r©Ú.0r©rrrÚ
<listcomp>-sz*EchoingStdin.readlines.<locals>.<listcomp>)r Ú    readlinesr%rr%rr',szEchoingStdin.readlinescst‡fdd„ˆjDƒƒS)Nc3s|]}ˆ |¡VqdSrr"r#r%rrÚ    <genexpr>0sz(EchoingStdin.__iter__.<locals>.<genexpr>)Úiterr r%rr%rÚ__iter__/szEchoingStdin.__iter__cCs
t|jƒSr)Úreprr r%rrrÚ__repr__2szEchoingStdin.__repr__)r)r)r)Ú__name__Ú
__module__Ú __qualname__ÚtÚBinaryIOrÚstrÚAnyrÚbytesrÚintrrr ÚListr'ÚIteratorr*r,rrrrr    sr    )Ústreamr ccs&|dkrdVnd|_dVd|_dS)NTF)r)r8rrrÚ _pause_echo6s
r9csReZdZejeeejddœ‡fdd„ Zeedœdd„ƒZ    eedœdd    „ƒZ
‡Z S)
Ú_NamedTextIOWrapperN)ÚbufferÚnameÚmodeÚkwargsr c s tƒj|f|Ž||_||_dSr)ÚsuperrÚ_nameÚ_mode)rr;r<r=r>©Ú    __class__rrrAsz_NamedTextIOWrapper.__init__r!cCs|jSr)r@r%rrrr<Hsz_NamedTextIOWrapper.namecCs|jSr)rAr%rrrr=Lsz_NamedTextIOWrapper.mode) r-r.r/r0r1r2r3rÚpropertyr<r=Ú __classcell__rrrBrr:@sþr:)r
Úcharsetr cCsbt|dƒr6tt tjtj|¡ƒ}|dk    r.|Stdƒ‚|dkrDd}nt|tƒrX|     |¡}t
  |¡S)Nrz.Could not find binary reader for input stream.ó) Úhasattrrr0ÚcastÚIOr3Ú    TypeErrorÚ
isinstancer2ÚencodeÚioÚBytesIO)r
rFrrrrÚmake_input_streamQs
 
 
rPc @s–eZdZdZddeejeejeeje    ejej
ej e    e    e fdœdd„Z eedœdd    „ƒZeedœd
d „ƒZeedœd d „ƒZedœdd„ZdS)ÚResultz3Holds the captured result of an invoked CLI script.NÚ    CliRunner©ÚrunnerÚ stdout_bytesÚ stderr_bytesÚ return_valueÚ    exit_codeÚ    exceptionÚexc_infocCs.||_||_||_||_||_||_||_dSrrS)rrTrUrVrWrXrYrZrrrrhs zResult.__init__r!cCs|jS)z(The (standard) output as unicode string.)Ústdoutr%rrrr …sz Result.outputcCs|j |jjd¡ dd¡S)z&The standard output as unicode string.Úreplaceú
Ú
)rUÚdecoderTrFr\r%rrrr[Šsÿz Result.stdoutcCs,|jdkrtdƒ‚|j |jjd¡ dd¡S)z%The standard error as unicode string.Nzstderr not separately capturedr\r]r^)rVÚ
ValueErrorr_rTrFr\r%rrrÚstderr‘s 
ÿz Result.stderrcCs,|jrt|jƒnd}dt|ƒj›d|›dS)NÚokayú<ú ú>)rYr+Útyper-)rZexc_strrrrr,šszResult.__repr__)N)r-r.r/Ú__doc__r4r0ÚOptionalr3r5Ú BaseExceptionÚTupleÚTyperrrDr2r r[rar,rrrrrQes( öÿø rQc
@s€eZdZdZdeejejeejefeeddœdd„Z    d    ed
œd d „Z
dejejeejefejeejefd œdd„Z e j dejejeeejejfejejeejefeejejejejejfdœdd„ƒZdd    ejejeejefejejeeejejfejejeejefeeejedœdd„Ze j dejejedfejedœdd„ƒZdS)rRaø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-8NFT)rFÚenvÚ
echo_stdinÚ
mix_stderrr cCs ||_|p i|_||_||_dSr)rFrmrnro)rrFrmrnrorrrr²s
zCliRunner.__init__r)Úclir cCs
|jpdS)zžGiven 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<)rrprrrÚget_default_prog_name¾szCliRunner.get_default_prog_name)Ú    overridesr cCst|jƒ}|r| |¡|S)z8Returns the environment overrides for invoking a script.)ÚdictrmÚupdate)rrsrrrrÚmake_envÅs
 
zCliRunner.make_env)r
rmÚcolorr c#s~t||jƒ}d}tj}tj}tj}tj}    dt_| |¡}t     
¡}
|j r^t   t jt||
ƒ¡}}t||jdddt_‰|j r‚dˆ_t|
|jdddt_d} |jrªtjt_nt     
¡} t| |jd    dd
d t_t|ƒdt jttd œ‡fd d„ ƒ} t|ƒdt jttd œ‡fdd„ ƒ} t|ƒttdœdd„ƒ}|‰dt jt jt jt jttdœ‡fdd„ }tj}tj}tj}tj}| t_| t_|t_|t_i}zl| ¡D]T\}}t j! #|¡||<|dkrÞz t j!|=Wnt"k
rÚYnXn
|t j!|<q–|
| fVW5| ¡D]D\}}|dkr:z t j!|=Wnt"k
r6YnXn
|t j!|<q|t_|t_|t_|t_|t_|t_|t_|    t_XdS)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.
        NéPz<stdin>Úr)Úencodingr<r=rz<stdout>Úwz<stderr>Úbackslashreplace)rzr<r=Úerrors)Úpromptr cs>tj |p d¡ˆ ¡ d¡}tj |›d¡tj ¡|S)NÚr]r^)Úsysr[rr ÚrstripÚflush)r~Úval©Ú
text_inputrrÚ visible_inputs
 
z*CliRunner.isolation.<locals>.visible_inputcs.tj |p d›d¡tj ¡ˆ ¡ d¡S)Nrr^r])r€r[rr‚r r)r~r„rrÚ hidden_inputs
z)CliRunner.isolation.<locals>.hidden_input)Úechor cSs*tj d¡}|rtj |¡tj ¡|S)Nr)r€Ústdinrr[rr‚)rˆÚcharrrrÚ_getchar#s
 
z%CliRunner.isolation.<locals>._getchar)r8rwr cs|dkrˆ S| Srr)r8rw)Ú default_colorrrÚshould_strip_ansi/sz.CliRunner.isolation.<locals>.should_strip_ansi)N)N)NN)$rPrFr€r‰r[rarZ FORCED_WIDTHrvrNrOrnr0rIr1r    r:Ú _CHUNK_SIZEror9rhr2ÚboolrJr3rZvisible_prompt_funcZhidden_prompt_funcr‹rrÚitemsÚosÚenvironÚ    ExceptionÚget)rr
rmrwZ bytes_inputZ
echo_inputZ    old_stdinZ
old_stdoutZ
old_stderrZold_forced_widthZ bytes_outputZ bytes_errorr†r‡r‹rZold_visible_prompt_funcZold_hidden_prompt_funcZold__getchar_funcZold_should_strip_ansiZold_envÚkeyÚvaluer)rŒr…rÚ    isolationÎs® 
ÿÿ ÿ
û    ÿþ
 
 zCliRunner.isolation)rpÚargsr
rmÚcatch_exceptionsrwÚextrar c Ks¬d}|j|||dz}    d}
d} d} t|tƒr8t |¡}z| d¡} Wntk
rd| |¡} YnXzòz|j f|pvd| dœ|—Ž}
WnÎtk
r}ztt ¡}t tjtjttjf|j¡}|dkrÎd}|dkrÚ|} t|tƒstj     t|ƒ¡tj     d¡d}|} W5d}~XYn<tk
rT}z|s4‚|} d} t ¡}W5d}~XYnXW5tj     
¡|    d  ¡}|j r~d}n |    d  ¡}XW5QRXt||||
| | |d    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
rmrwrÚ    prog_namerr)r˜r›r^rS)r—rLr2ÚshlexÚsplitÚpopÚKeyErrorrrr€r[r‚ÚgetvalueroÚmainÚ
SystemExitrZr0rIrhÚUnionr5r3Úcoderr“rQ)rrpr˜r
rmr™rwršrZZ
outstreamsrWrYrXr›r[raÚeZe_coderrrÚinvoke]sZ,
 
   
 ùzCliRunner.invokezos.PathLike[str])Útemp_dirr ccsft ¡}tj|d}t |¡z
|VW5t |¡|dkr`zt |¡Wntk
r^YnXXdS)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)rr§ÚcwdÚdtrrrÚisolated_filesystemÂs 
 
 
zCliRunner.isolated_filesystem)rlNFT)N)NNF)NNNTF)N)r-r.r/rgr2r0rhÚMappingrrrrrvÚ
contextlibÚcontextmanagerr£r4rJr3r7rjrNrOr—ÚSequencerQr¦r²rrrrrRŸsdûú ÿþ     üûù÷ eÿþrR)$r´rNr‘rœr­r€rªÚtypingr0ÚtypesrrrrrÚ_compatrÚ TYPE_CHECKINGÚcorerr    rµrhr7r9Ú TextIOWrapperr:r£r2r4rJr3r1rPrQrRrrrrÚ<module>s0      "    þ :