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
U
H=®dÞ(ã@sŠddlZddlZddlZddlmZmZmZmZddlm    Z    m
Z
m Z ddl m Z mZdZe dk    rfe    ƒZGdd„deƒZGdd    „d    eƒZdS)
éNé)ÚAnsiForeÚAnsiBackÚ    AnsiStyleÚStyle)ÚWinTermÚWinColorÚWinStyle)ÚwindllÚ winapi_testc@sLeZdZdZdd„Zdd„Zdd„Zdd    „Zd
d „Zd d „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úWD:\z\workplace\VsCode\pyvenv\venv\Lib\site-packages\pip/_vendor/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|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'+s
 
zStreamWrapper.isattycCs*|j}z|jWStk
r$YdSXdS©NT)rÚclosedr()rr)rrrr,7s
zStreamWrapper.closedN) Ú__name__Ú
__module__Ú __qualname__Ú__doc__rrrrrr'Úpropertyr,rrrrr s r c@s~eZdZdZe d¡Ze d¡Zddd„Zdd    „Z    d
d „Z
d d „Z dd„Z dd„Z dd„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?\]((?:.|;)*?)()?NFcCs–||_||_t||ƒ|_tjdk}|o*tƒ}|dkrN|pL|jj oL|j ¡ }||_    |dkrt|or|jj or|j ¡}||_
|  ¡|_ |jt jk|_dS)NÚnt)rÚ    autoresetr r)r"rr r,r'ÚstripÚconvertÚget_win32_callsÚ win32_callsr$ÚstderrÚ    on_stderr)rrr6r5r4Ú
on_windowsÚconversion_supportedrrrrIs 
 
 
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()
        )r6r5r4©rrrrÚ should_wrapjszAnsiToWin32.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!ƒSr+)"r6Ú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=rrrr7tsž
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
        Ú(zAnsiToWin32.get_win32_callscCs@|js |jr| |¡n|j |¡|j ¡|jr<| ¡dSr )r5r6Úwrite_and_convertrrÚflushr4rArrrrr s    
zAnsiToWin32.writecCs4|jr| dd¡n|js0|jjs0|j tj¡dS)NÚm©r)    r6Ú
call_win32r5r)r,rrrr@r=rrrrAª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Úendrrrr[±s
 zAnsiToWin32.write_and_convertcCs*||kr&|j |||…¡|j ¡dSr )rrr\)rr rjrkrrrrdÁszAnsiToWin32.write_plain_textcCs"|jr| ||¡}| ||¡dSr )r6Úextract_paramsr_)rÚ paramstringÚcommandÚparamsrrrreÇ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©rgÚint©Ú.0ÚprrrÚ    <genexpr>Ïsz-AnsiToWin32.extract_params.<locals>.<genexpr>ú;é)rcss"|]}t|ƒdkrt|ƒVqdS)rNrqrsrrrrvÔs rÚJKmr^ÚABCD)ÚtupleÚsplitrg)rrnrmrorrrrlÍ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)
Nr]rr)r:ÚJÚKrprz)ÚAÚBÚCÚD)r8rZr:r?Ú erase_screenÚ
erase_lineÚset_cursor_positionÚ cursor_adjust) rrnroÚparamÚ    func_argsÚfuncrrÚnÚxÚyrrrr_ßs$
 
  *zAnsiToWin32.call_win32cCsr|j |¡D]`}| ¡\}}|d|…||d…}| ¡\}}|dkr | d¡}|ddkr t |d¡q |S)NúrwrÚ02r)Ú ANSI_OSC_RErbrcrfr|r?Ú    set_title)rr rirjrkrmrnrorrrr`õs  
 zAnsiToWin32.convert_osc)NNF)r-r.r/r0ÚreÚcompilerarrr>r7rrAr[rdrerlr_r`rrrrr2@s
 
 
!
,
r2)r‘r$r"Úansirrrrr?rrr    Úwin32r
r Úobjectr r2rrrrÚ<module>s0