h-dZddlmZddlmZddlmZddgZGddZGd deZ Gd de Z d S) a pygments.formatters.terminal256 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Formatter for 256-color terminal output with ANSI sequences. RGB-to-XTERM color conversion routines adapted from xterm256-conv tool (http://frexx.de/xterm-256-notes/data/xterm256-conv2.tar.bz2) by Wolfgang Frisch. Formatter version 1. :copyright: Copyright 2006-2024 by the Pygments team, see AUTHORS. :license: BSD, see LICENSE for details. ) Formatter)codes) ansicolorsTerminal256FormatterTerminalTrueColorFormatterc.eZdZddZdZdZdZdZdS) EscapeSequenceNFcL||_||_||_||_||_dSN)fgbgbold underlineitalic)selfr r rrrs /builddir/build/BUILD/imunify360-venv-2.5.2/opt/imunify360/venv/lib/python3.11/site-packages/pip/_vendor/pygments/formatters/terminal256.py__init__zEscapeSequence.__init__#s) " cZt|rdd|zdzSdS)Nz[;m)lenjoinrattrss rescapezEscapeSequence.escape*s/ u:: 3SXXe__,s2 2rrc  g}|j}|jtvrOt|jdd}d|vrd|_||ddn |ddd |jzf|j|jtvrat|jdd}|tt|ddd zn |d dd |jzf|jr|d |j r|d |j r|d| |S)Nansirz;01mT385z%i 48010403) r rrreplacerappendextendr strintrrr)rrescs r color_stringzEscapeSequence.color_string/sf 7 w*$$DGOOF2667S== $DI S1X&&&& dC8999 7 w*$$DGOOF2667 SS1Xr!1223333 dC8999 9  LL    >  LL    ;  LL   {{5!!!rc |g}|jrb|ddt|jdt|jdt|jdf|jrb|ddt|jdt|jdt|jdf|jr|d|jr|d|jr|d ||S) Nr"2rr r%r&r'r() r r+r,r rr*rrrrs rtrue_color_stringz EscapeSequence.true_color_stringIs 7 Y LL$S__c$'!*oos47ST:W X X X 7 Y LL$S__c$'!*oos47ST:W X X X 9  LL    >  LL    ;  LL   {{5!!!rcg}|j|d|j|d|js|js|jr|d||S)N394900)r r*r rrrrrs r reset_stringzEscapeSequence.reset_stringWs{ 7  LL    7  LL    9  $+  LL   {{5!!!r)NNFFF)__name__ __module__ __qualname__rrr/r3r8rrr r "sd """4 " " """"""rr cReZdZdZdZgdZgZdZdZdZ dZ dZ d Z d Z d Zd S) ra Format tokens with ANSI color sequences, for output in a 256-color terminal or console. Like in `TerminalFormatter` color sequences are terminated at newlines, so that paging the output works correctly. The formatter takes colors from a style defined by the `style` option and converts them to nearest ANSI 256-color escape sequences. Bold and underline attributes from the style are preserved (and displayed). .. versionadded:: 0.9 .. versionchanged:: 2.2 If the used style defines foreground colors in the form ``#ansi*``, then `Terminal256Formatter` will map these to non extended foreground color. See :ref:`AnsiTerminalStyle` for more information. .. versionchanged:: 2.4 The ANSI color names have been updated with names that are easier to understand and align with colornames of other projects and terminals. See :ref:`this table ` for more information. Options accepted: `style` The style to use, can be a string or a Style subclass (default: ``'default'``). `linenos` Set to ``True`` to have line numbers on the terminal output as well (default: ``False`` = no line numbers). Terminal256) terminal256 console256256c tj|fi|g|_i|_i|_d|v|_d|v|_d|v|_|| | dd|_ d|_ dS)Nnobold nounderlinenoitaliclinenosFr) rr xterm_colors best_match style_stringusebold useunderline useitalic_build_color_table _setup_stylesgetrF_lineno)roptionss rrzTerminal256Formatter.__init__s4++7+++w. )8#72 !!! {{9e44  rcf|jd|jd|jd|jd|jd|jd|jd|jd|jd |jd |jd |jd |jd |jd|jd|jdd}tdD]F}||dzdz}||dzdz}||dz}|j|||fGtddD]'}d|dzz}|j|||f(dS)N)rrr)rr)rrSr)rSrSr)rr)rSrrS)rrSrS)rUrU)rVrV)rr)rrWr)rWrWr)\rXrW)rWrrW)rrWrW)rWrWrW)r_rW$r2r$)rGr*range)r valuerangeirgbvs rrMz'Terminal256Formatter._build_color_tablesB   !3444   !3444   !3444   !3444   !3444   !3444   !3444   !3444   !3444   !3444   !3444   !3444   !3444   !3444   !3444   !3444: s 0 0AAGq=)AAFa<(A1q5!A   $ $aAY / / / /q" 0 0AAF A   $ $aAY / / / / 0 0rcd}d}tddD]K}|j|}||dz }||dz } ||dz } ||z| | zz| | zz} | |kr|}| }L|S)Nirr2r )rbrG) rrerfrgdistancematchrdvaluesrdgdbdds r_closest_colorz#Terminal256Formatter._closest_colorsq#  A&q)FVAYBVAYBVAYB22 2%A8|| rc8|j|d}|tvr |}||j|<|g tt |d}n#t $rd}YnwxYw|dz dz}|dz dz}|dz}||||}||j|<|S)NrrWra)rHrOrr-r, ValueErrorrr)rcolorindexrgbrerfrgs r _color_indexz!Terminal256Formatter._color_indexs##E400 J  E%*DOE " = #e**b))    d"AT!Ad A''1a00E%*DOE " sA A! A!c|jD]5\}}t}|dr!||d|_n(|dr ||d|_|dr!||d|_n(|dr ||d|_|jr|drd|_|jr|drd|_|j r|drd|_ | | f|j t|<7dS) N ansicolorrv bgansicolorbgcolorrTrr)styler ryr r rJrrKrrLrr/r8rIr,rttypendefrs rrNz"Terminal256Formatter._setup_stylessZ: D DKE4#%%FK  = --d;.?@@ g = --d7m<< M" ? --d=.ABB i ? --d9o>> | #V  #"   (T+%6 (#' ~ %$x. % $ -3-@-@-B-B-3-@-@-B-B-DD c%jj ) )# D Drc~|xjdz c_|d|jdkrdpd|jfzdS)Nr2z%s%04d:  r)rPwrite)routfiles r _write_linenoz"Terminal256Formatter._write_linenosG   jDLA$5$>$$D"dl#SSTTTTTrc.tj|||Sr )rformat)r tokensourcers rrzTerminal256Formatter.formatsk7;;;rcp|jr|||D]\}}d}|r|r |jt|\}}|d}|ddD]Q} | r||| z|z|jr||<|dR|dr!|||dz|zd}n#t $r |j}YnwxYw|r||r|||jr|ddSdS)NTrF)rFrrIr,splitrKeyErrorparent) rrrrvalue not_foundonoffspllines rformat_unencodedz%Terminal256Formatter.format_unencodeds < (   w ' ' '' % %LE5I )I ))"/E ;GB ++d++C #CRC00;#MM"t)c/:::<0 ..w7777#MM$////2w: b3r7lS&8999 %II )))!LEEE)- )I )6 % e$$$ < MM$       sB9C%%C98C9N)r9r:r;__doc__namealiases filenamesrrMrrryrNrrrr<rrrrbs@ D222GI""0"0"0H"&DDD*UUU<<<% % % % % rc4eZdZdZdZgdZgZdZdZdZ dS)ra} Format tokens with ANSI color sequences, for output in a true-color terminal or console. Like in `TerminalFormatter` color sequences are terminated at newlines, so that paging the output works correctly. .. versionadded:: 2.1 Options accepted: `style` The style to use, can be a string or a Style subclass (default: ``'default'``). TerminalTrueColor) terminal16m console16m16mcdSr r<)rs rrMz-TerminalTrueColorFormatter._build_color_table7s rc tt|d}n#t$rYdSwxYw|dz dz}|dz dz}|dz}|||fS)NrtrWra)r-r,ru)rrvrxrerfrgs r _color_tuplez'TerminalTrueColorFormatter._color_tuple:sq c%jj"%%CC   44  BY$  AX  $J1ays  ..c|jD]\}}t}|dr ||d|_|dr ||d|_|jr|drd|_|jr|drd|_|j r|drd|_ | | f|j t|<dS)Nrvr}rTrr)r~r rr r rJrrKrrLrr3r8rIr,rs rrNz(TerminalTrueColorFormatter._setup_stylesDs: D DKE4#%%FG} = --d7m<< I ? --d9o>> | #V  #"   (T+%6 (#' ~ %$x. % $ -3-E-E-G-G-3-@-@-B-B-DD c%jj ) ) D DrN) r9r:r;rrrrrMrrNr<rrrr%sg   D222GI   DDDDDrN) rpip._vendor.pygments.formatterrpip._vendor.pygments.consolerpip._vendor.pygments.styler__all__r rrr<rrrs2544444......111111 "#? @="="="="="="="="@     9   F-D-D-D-D-D!5-D-D-D-D-Dr