R`ix+ddlZddlZddlZddlmZmZmZmZmZddl m Z m Z m Z m Z ddlmZmZdZ ee Z GddeZGdd eZy) N)AnsiForeAnsiBack AnsiStyleStyleBEL)enable_vt_processingWinTermWinColorWinStyle)windll winapi_testcPeZdZdZdZdZdZdZdZdZ dZ d Z e d Z y ) 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. c ||_||_yN)_StreamWrapper__wrapped_StreamWrapper__convertor)selfwrapped converters /builddir/build/BUILDROOT/alt-python312-pip-23.3.1-3.el8.x86_64/opt/alt/python312/lib/python3.12/site-packages/pip/_vendor/colorama/ansitowin32.py__init__zStreamWrapper.__init__s!$c.t|j|Sr)getattrr)rnames r __getattr__zStreamWrapper.__getattr__st~~t,,rc:|jj|i|Sr)r __enter__rargskwargss rr zStreamWrapper.__enter__s (t~~''888rc:|jj|i|Sr)r__exit__r!s rr%zStreamWrapper.__exit__%s&t~~&&777rc||_yr__dict__)rstates r __setstate__zStreamWrapper.__setstate__(s  rc|jSrr'rs r __getstate__zStreamWrapper.__getstate__+s }}rc:|jj|yr)rwritertexts rr/zStreamWrapper.write.s t$rc|j}dtjvr'|%|tjus|tj ury |j }|S#t$rYywxYw)NPYCHARM_HOSTEDTF)rosenvironsys __stdout__ __stderr__isattyAttributeError)rstream stream_isattys rr9zStreamWrapper.isatty1sb rzz )!v'?6S^^C[ #"MMM!? "  s A A&%A&c^|j} |jS#ttf$rYywxYwNT)rclosedr: ValueError)rr;s rr?zStreamWrapper.closed=s3 ==  +  s ,,N)__name__ __module__ __qualname____doc__rrr r%r*r-r/r9propertyr?rrrrsC % -9 8% #rrceZdZdZej dZej dZddZdZ dZ dZ d Z d Z d Zd Zd ZdZdZdZy) 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?\]([^]*)()?Nc||_||_t|||_tj dk(}|xr t } |j}| xs t|}|jj xr|jj} |xr| } || xs| }||_ || xr| }||_ |j|_|jt j"u|_y#t$rd}YwxYw)Nnt)r autoresetrr;r4rrfileno Exceptionr r?r9stripconvertget_win32_calls win32_callsr6stderr on_stderr) rrrPrOrL on_windowsconversion_supportedfdsystem_has_native_ansihave_ttyneed_conversions rrzAnsiToWin32.__init__Qs #$GT2 WW_ *;km !B&0!K3G3K{{)))Bdkk.@.@.B.M7M3M =#38|E  ?%2(G  //13) B sC22 D?DcR|jxs|jxs |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() )rPrOrLr,s r should_wrapzAnsiToWin32.should_wrapys ||;tzz;T^^;rc  |jrtritjtjftj tj tj ftjtj tjftjtj tjftjtjtjftjtjtjftjtjtjftj tjtj ftj"tjtj"ftj$tjtj$ftj&tjtj&ftj(tjtj*ftj,tjftj.tjtjdftj0tjtjdftj2tjtjdftj4tjtj dfitj6tjtj"dftj8tjtj$dftj:tjtj&dftj<tjtj*dft>jtj@tjft>jtj@tjft>jtj@tjft>j tj@tj ft>j"tj@tj"ft>j$tj@tj$ft>j&tj@tj&ft>j(tj@tj*ft>j,tj@ft>j.tj@tjdft>j0tj@tjdft>j2tj@tjdft>j4tj@tj dft>j6tj@tj"dft>j8tj@tj$dft>j:tj@tj&dft>j<tj@tj*dfiStCSr>)"rPwintermr RESET_ALL reset_allBRIGHTstyler DIMNORMALrBLACKforer REDGREENYELLOWBLUEMAGENTACYANWHITEGREYRESET LIGHTBLACK_EX LIGHTRED_EX LIGHTGREEN_EXLIGHTYELLOW_EX LIGHTBLUE_EXLIGHTMAGENTA_EX LIGHTCYAN_EX LIGHTWHITE_EXrbackdictr,s rrQzAnsiToWin32.get_win32_callss < '  w||X\\: 'x~~ >'',,!@'  hmm<'  7<<1A1A"B'  hmm<'x}} =' 0'&&x~~t(L'$$w||X\\4&H' &&x~~t(L!'"''',,)N#'$%% hmmT'J%'&((7<<9I9I4*P''(%% hmmT'J)'*&&x}}d(K+',x~~ >-'. w||X\\:/'0x~~ >1'2',,!@3'4  hmm<5'6  7<<1A1A"B7'8  hmm<9':x}} =;'< 0='>&&x~~t(L?'@$$w||X\\4&HA'B&&x~~t(LC'D''',,)NE'F%% hmmT'J((7<<9I9I4*P%% hmmT'J&&x}}d(KM'' Pv rc|js |jr|j|n5|jj ||jj |j r|jyyr)rOrPwrite_and_convertrr/flushrLr`r0s rr/zAnsiToWin32.writesU ::  " "4 ( LL  t $ LL   >> NN  rc|jr|jddy|jsA|jjs*|j j tjyyy)Nmr) rP call_win32rOr;r?rr/rr_r,s rr`zAnsiToWin32.reset_allsG << OOC &DKK$6$6 LL  u /%7rc,d}|j|}|jj|D]G}|j\}}|j ||||j |j |}I|j ||t|y)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_REfinditerspanwrite_plain_text convert_ansigroupslen)rr1cursormatchstartends rr{zAnsiToWin32.write_and_converts %%%..t4EJE3  ! !$ 6 D  u||~ .F 5 dFCI6rc||kr9|jj||||jjyyr)rr/r|)rr1rrs rrzAnsiToWin32.write_plain_texts6 3; LL  tE# / LL    rcf|jr%|j||}|j||yyr)rPextract_paramsr)r paramstringcommandparamss rrzAnsiToWin32.convert_ansis. <<((+>F OOGV , rc|dvrEtd|jdD}t|dkr|dz}t|dkr|Std|jdD}t|dk(r|dvrd }|S|d vrd}|S) NHfc3RK|]}t|dk7r t|nd!yw)rrNrint.0ps r z-AnsiToWin32.extract_params..s&XAWASVq[3q6a7AWs%';)rc3PK|]}t|dk7st| yw)rNrrs rrz-AnsiToWin32.extract_params..s!Q+AaSVq[3q6+As&&rJKmrABCD)tuplesplitr)rrrrs rrzAnsiToWin32.extract_paramss d?XARARSVAWXXFf+/$f+/ Q;+<+D,,, $ 0 0 7I$Q|j ddk(sS|j d}|ddvsltj|d|S)Nrrr02) ANSI_OSC_RErrrrcountrr^ set_title)rr1rrrrrrs rrzAnsiToWin32.convert_oscs%%..t4EJE3<$st*,D#(<<> K#~$$S)Q.(..s3FayD())&)45 rc8|jjyr)rr|r,s rr|zAnsiToWin32.flushs r)NNF)rArBrCrDrecompilerrrr\rQr/r`r{rrrrrr|rFrrrHrHHsj "**FGK"**<=K&4P<*X0 7 ! - $B,  rrH)rr6r4ansirrrrrr^r r r r win32r robjectrrHrFrrrsL ;;FF&  iG5F5pM&Mr