zmc
2023-12-22 9fdbf60165db0400c2e8e6be2dc6e88138ac719a
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
U
Þ=®dx+ã@s’ddlZddlZddlZddlmZmZmZmZmZddl    m
Z
m Z m Z m Z ddlmZmZdZ    edk    rne ƒZ    Gdd„deƒZGdd    „d    eƒZdS)
éNé)ÚAnsiForeÚAnsiBackÚ    AnsiStyleÚStyleÚBEL)Úenable_vt_processingÚWinTermÚWinColorÚWinStyle)ÚwindllÚ winapi_testc@s\eZdZdZdd„Zdd„Zdd„Zdd    „Zd
d „Zd d „Z    dd„Z
dd„Z e dd„ƒZ dS)Ú StreamWrapperz´
    Wraps a stream (such as stdout), acting as a transparent proxy for all
    attribute access apart from method 'write()', which is delegated to our
    Converter instance.
    cCs||_||_dS©N)Ú_StreamWrapper__wrappedÚ_StreamWrapper__convertor)ÚselfÚwrappedÚ    converter©rúKd:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\colorama/ansitowin32.pyÚ__init__szStreamWrapper.__init__cCs t|j|ƒSr)Úgetattrr)rÚnamerrrÚ __getattr__szStreamWrapper.__getattr__cOs|jj||ŽSr)rÚ    __enter__©rÚargsÚkwargsrrrrszStreamWrapper.__enter__cOs|jj||ŽSr)rÚ__exit__rrrrr%szStreamWrapper.__exit__cCs
||_dSr©Ú__dict__)rÚstaterrrÚ __setstate__(szStreamWrapper.__setstate__cCs|jSrr ©rrrrÚ __getstate__+szStreamWrapper.__getstate__cCs|j |¡dSr)rÚwrite©rÚtextrrrr&.szStreamWrapper.writecCs\|j}dtjkr0|dk    r0|tjks,|tjkr0dSz
|j}Wntk
rPYdSX|ƒSdS)NÚPYCHARM_HOSTEDTF)rÚosÚenvironÚsysÚ
__stdout__Ú
__stderr__ÚisattyÚAttributeError)rÚstreamÚ stream_isattyrrrr/1s
 
zStreamWrapper.isattyc    Cs.|j}z|jWSttfk
r(YdSXdS©NT)rÚclosedr0Ú
ValueError)rr1rrrr4=s
zStreamWrapper.closedN)Ú__name__Ú
__module__Ú __qualname__Ú__doc__rrrrr#r%r&r/Úpropertyr4rrrrrs rc@s†eZdZdZe d¡Ze d¡Zddd„Zdd    „Z    d
d „Z
d d „Z dd„Z dd„Z dd„Zdd„Zdd„Zdd„Zdd„Zdd„ZdS)Ú AnsiToWin32z¾
    Implements a 'write()' method which, on Windows, will strip ANSI character
    sequences from the text, and if outputting to a tty, will convert them into
    win32 function calls.
    z?\[((?:\d|;)*)([a-zA-Z])?z?\]([^]*)()?NFc CsÈ||_||_t||ƒ|_tjdk}|o*tƒ}z | ¡}Wntk
rPd}YnX| p^t    |ƒ}|jj
or|j  ¡}    |o|| }
|dkr|
pŽ|     }||_ |dkr¦|
o¤|    }||_ | ¡|_|jtjk|_dS)NÚntéÿÿÿÿ)rÚ    autoresetrr1r*rr ÚfilenoÚ    Exceptionrr4r/ÚstripÚconvertÚget_win32_callsÚ win32_callsr,ÚstderrÚ    on_stderr) rrrBrAr>Ú
on_windowsÚconversion_supportedÚfdZsystem_has_native_ansiZhave_ttyZneed_conversionrrrrQs( 
 
 
 
 
 
zAnsiToWin32.__init__cCs|jp|jp|jS)aj
        True if this class is actually needed. If false, then the output
        stream will not be affected, nor will win32 calls be issued, so
        wrapping stdout is not actually required. This will generally be
        False on non-Windows platforms, unless optional functionality like
        autoreset has been requested using kwargs to init()
        )rBrAr>r$rrrÚ should_wrapyszAnsiToWin32.should_wrapcNCs@|jr:tr:tjtjftjtjtjftjtjtj    ftj    tjtj    ft
j tj t j ft
jtj t jft
jtj t jft
jtj t jft
jtj t jft
jtj t jft
jtj t jft
jtj t jft
jtj ft
jtj t j dft
jtj t jdft
jtj t jdft
jtj t jdft
jtj t jdft
jtj t jdft
jtj t jdft
jtj t jdftj tj t j ftjtj t jftjtj t jftjtj t jftjtj t jftjtj t jftjtj t jftjtj t jftjtj ftjtj t j dftjtj t jdftjtj t jdftjtj t jdftjtj t jdftjtj t jdftjtj t jdftjtj t jdfi&St!ƒSr3)"rBÚwintermrÚ    RESET_ALLÚ    reset_allÚBRIGHTÚstyler ÚDIMÚNORMALrÚBLACKÚforer
ÚREDÚGREENÚYELLOWÚBLUEÚMAGENTAÚCYANÚWHITEÚGREYÚRESETÚ LIGHTBLACK_EXÚ LIGHTRED_EXÚ LIGHTGREEN_EXÚLIGHTYELLOW_EXÚ LIGHTBLUE_EXÚLIGHTMAGENTA_EXÚ LIGHTCYAN_EXÚ LIGHTWHITE_EXrÚbackÚdictr$rrrrCƒsž
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
        Ú(zAnsiToWin32.get_win32_callscCs@|js |jr| |¡n|j |¡|j ¡|jr<| ¡dSr)rArBÚwrite_and_convertrr&Úflushr>rMr'rrrr&¯s    
zAnsiToWin32.writecCs4|jr| dd¡n|js0|jjs0|j tj¡dS)NÚm©r)    rBÚ
call_win32rAr1r4rr&rrLr$rrrrM¹szAnsiToWin32.reset_allcCsbd}| |¡}|j |¡D]0}| ¡\}}| |||¡|j| ¡Ž|}q| ||t|ƒ¡dS)zª
        Write the given text to our wrapped stream, stripping any ANSI
        sequences from the text, and optionally converting them into win32
        calls.
        rN)Ú convert_oscÚ ANSI_CSI_REÚfinditerÚspanÚwrite_plain_textÚ convert_ansiÚgroupsÚlen)rr(ÚcursorÚmatchÚstartÚendrrrrgÀs
 zAnsiToWin32.write_and_convertcCs*||kr&|j |||…¡|j ¡dSr)rr&rh)rr(rvrwrrrrpÐszAnsiToWin32.write_plain_textcCs"|jr| ||¡}| ||¡dSr)rBÚextract_paramsrk)rÚ paramstringÚcommandÚparamsrrrrqÖs zAnsiToWin32.convert_ansicCsz|dkr8tdd„| d¡Dƒƒ}t|ƒdkrv|d}q n>tdd„| d¡Dƒƒ}t|ƒdkrv|d    krjd
}n |d krvd}|S) NÚHfcss&|]}t|ƒdkrt|ƒndVqdS)rrN©rsÚint©Ú.0ÚprrrÚ    <genexpr>Þsz-AnsiToWin32.extract_params.<locals>.<genexpr>ú;é)rcss"|]}t|ƒdkrt|ƒVqdS)rNr}rrrrr‚ãs rÚJKmrjÚABCD)ÚtupleÚsplitrs)rrzryr{rrrrxÜs   zAnsiToWin32.extract_paramsc Csø|dkrR|D]B}||jkr |j|}|d}|dd…}t|jd}|||Žq n¢|dkrptj|d|jdn„|dkrŽtj|d|jdnf|dkr¨tj||jdnL|dkrô|d}d| fd|f|df| dfd    œ|\}    }
tj|    |
|jddS)
Nrirr)rFÚJÚKr|r†)ÚAÚBÚCÚD)rDrfrFrKÚ erase_screenÚ
erase_lineÚset_cursor_positionÚ cursor_adjust) rrzr{ÚparamÚ    func_argsÚfuncrrÚnÚxÚyrrrrkîs$
 
  *zAnsiToWin32.call_win32cCs€|j |¡D]n}| ¡\}}|d|…||d…}| ¡\}}|tkr | d¡dkr | d¡}|ddkr t |d¡q |S)NrƒrrÚ02)    Ú ANSI_OSC_RErnrorrrÚcountrˆrKÚ    set_title)rr(rurvrwryrzr{rrrrls  
 zAnsiToWin32.convert_osccCs|j ¡dSr)rrhr$rrrrhszAnsiToWin32.flush)NNF)r6r7r8r9ÚreÚcompilermršrrJrCr&rMrgrprqrxrkrlrhrrrrr;Hs
 
 
(
,
r;)rr,r*ÚansirrrrrrKrr    r
r Úwin32r r Úobjectrr;rrrrÚ<module>s8