VULN_CHECK_I913V6 jUdZddlZddlZddlmZddlmZmZmZm Z ddl Z ddl m Z m Z mZdZ ddlZgdZgd d d gd gd dgdZdZdZdZGddeZGddeZGddZGddeZGddeZGddeZGdd eZy#e$rdZYswxYw#e$r ddlZn #e$rdZYnwxYwYwxYw)!z pygments.formatters.img ~~~~~~~~~~~~~~~~~~~~~~~ Formatter for Pixmap output. :copyright: Copyright 2006-2023 by the Pygments team, see AUTHORS. :license: BSD, see LICENSE for details. N) Formatter) get_bool_opt get_int_opt get_list_optget_choice_opt)Image ImageDraw ImageFontTF)ImageFormatterGifImageFormatterJpgImageFormatterBmpImageFormatter)RomanBookNormalRegularMediumObliqueItalicBoldz Bold Obliquez Bold Italic)NORMALITALICBOLD BOLDITALICzDejaVu Sans Monoz Courier NewMenloceZdZdZy)PilNotAvailablez,When Python imaging library is not availableN__name__ __module__ __qualname____doc__H/usr/lib/python3.12/site-packages/pip/_vendor/pygments/formatters/img.pyrr5s6r%rceZdZdZy) FontNotFoundz(When there are no usable fonts specifiedNrr$r%r&r(r(9s2r%r(cPeZdZdZd dZdZdZdZdZddZ dZ d Z d Z d Z y ) FontManagerz> Manages a set of fonts: normal, italic, bold, etc... cj||_||_i|_d|_tj j dr|s t|_|jytj j dr|s t|_|jy|s t|_|jy)Nwindarwin) font_name font_sizefontsencodingsysplatform startswithDEFAULT_FONT_NAME_WIN _create_winDEFAULT_FONT_NAME_MAC _create_macDEFAULT_FONT_NAME_NIX _create_nix)selfr.r/s r&__init__zFontManager.__init__Bs""  << " "5 )!6     \\ $ $X .!6    !6    r%c^tjd|d|dgtjd}|j\}}|jdk(r]|j }|D]G}|j dr|jjjd}|sE|cSyy)Nzfc-listz:style=file)stdoutstderrrsFontconfig warning::) subprocessPopenPIPE communicate returncode splitlinesr4decodestrip) r;namestyleprocr?_lineslinepaths r&_get_nix_font_pathzFontManager._get_nix_font_pathTsT5,I6 R'1tE$$&  ??a %%'E??#9:{{}**,2237K   r%c*tdD]O}|j|j|}|"tj||j |j d<ntd|jzdD]}t|D]O}|j|j|}|"tj||j |j |<]|dk(r|j d|j |<|j d|j |<y)NrNo usable fonts named: "%s"rrrrr)STYLESrQr.r truetyper/r0r()r;rJrPrK stylenames r&r:zFontManager._create_nixbs8$D**4>>4@D'0'9'9$'O 8$ % <#~~ ./ /5E#E] ..t~~yI#(1(:(:4(PDJJu% + L((, 6(:DJJu%(, 8(>@AAr%ci}tjjtjddddfD]/|j fdtj D1t dD]P}|j||j|}|#tj||j|jd<ntd|jzdD]}t |D]P}|j||j|}|#tj||j|j|<^|d k(r|jd |j|<|jd|j|<y) NHOMEzLibrary/Fonts/z/Library/Fonts/z/System/Library/Fonts/c3K|]s}|jjdrRtjj |djtjj |fuyw))ttfttcrN)r[endswithosrPsplitextjoin).0ffont_dirs r& z*FontManager._create_mac..~s^7-A779%%n5!!!$Q'--/h1JK-sA9A<rrSrTrr)rdrPrfgetenvupdatelistdirrUr]r.r rVr/r0r()r;r\rJrPrKrWris @r&r8zFontManager._create_maczsYbii&79IJ*,DFH OO7H-7 7F8$D**8T^^TJD'0'9'9$'O 8$ % <#~~ ./ /5E#E] ..xS#(1(:(:4(PDJJu% + L((, 6(:DJJu%(, 8( Get the font based on bold and italic flags. rrrr)r0)r;boldobliques r&get_fontzFontManager.get_fontsK G::l+ + ::f% % ::h' '::h' 'r%N))F)r r!r"r#r<rQr:r]r8ryr6rrrr$r%r&r*r*=s<$ =*B=: %HN' & (r%r*ceZdZdZdZgdZdgZdZdZdZ ddZ d Z d Z d Z d Zd ZdZdZdZdZdZdZdZdZdZdZdZy)r a Create a PNG image from source code. This uses the Python Imaging Library to generate a pixmap from the source code. .. versionadded:: 0.10 Additional options accepted: `image_format` An image format to output to that is recognised by PIL, these include: * "PNG" (default) * "JPEG" * "BMP" * "GIF" `line_pad` The extra spacing (in pixels) between each line of text. Default: 2 `font_name` The font name to be used as the base font from which others, such as bold and italic fonts will be generated. This really should be a monospace font to look sane. Default: "Courier New" on Windows, "Menlo" on Mac OS, and "DejaVu Sans Mono" on \*nix `font_size` The font size in points to be used. Default: 14 `image_pad` The padding, in pixels to be used at each edge of the resulting image. Default: 10 `line_numbers` Whether line numbers should be shown: True/False Default: True `line_number_start` The line number of the first line. Default: 1 `line_number_step` The step used when printing line numbers. Default: 1 `line_number_bg` The background colour (in "#123456" format) of the line number bar, or None to use the style background color. Default: "#eed" `line_number_fg` The text color of the line numbers (in "#123456"-like format). Default: "#886" `line_number_chars` The number of columns of line numbers allowable in the line number margin. Default: 2 `line_number_bold` Whether line numbers will be bold: True/False Default: False `line_number_italic` Whether line numbers will be italicized: True/False Default: False `line_number_separator` Whether a line will be drawn between the line number area and the source code area: True/False Default: True `line_number_pad` The horizontal padding (in pixels) between the line number margin, and the source code area. Default: 6 `hl_lines` Specify a list of lines to be highlighted. .. versionadded:: 1.2 Default: empty list `hl_color` Specify the color for highlighting lines. .. versionadded:: 1.2 Default: highlight color of the selected style img)rIMGpngz*.pngFrc Dts tdtj|fi|d|_t |j |_|j jd|_n|j j|_t|dgd|jd|_ t|d d |_ t|d d |_t|d d}t|j!dd||_|j"j%\|_|_|j!dd|_|j!dd|_t|dd |_t1|dd|_t1|dd|_t|dd|_t1|dd|_t1|dd|_t|dd|_t|dd|_|j8r/|j&|j.z|j6d zz|_ nd |_ g|_!tE|d!g}|D]'} |jBjGtI|)|j!d"|j jLxsd#|_'g|_(y#tJ$rYlwxYw)$zE See the class docstring for explanation of options. z5Python Imaging Library is required for this formatterlatin1Nz#fff image_format)rjpeggifbmpT)normcase image_pad line_padrr/rr.rline_number_fgz#886line_number_bgz#eedline_number_charsline_number_boldFline_number_italicline_number_pad line_numbersline_number_separatorline_number_stepline_number_startrhl_lineshl_colorz#f90)) pil_availablerrr<r1dictrKrtbackground_colorrdefault_image_formatrrrrr*rZr0rfontwfonthrrrrrrrrrrrline_number_widthrrappendint ValueErrorhighlight_colorr drawables)r;optionsfontsize hl_lines_strrOs r&r<zImageFormatter.__init__ast!GI I4+7+  4::& :: & & .$*D !$(JJ$?$?D !* ^%B  % %6%Wk2>#GZ; w R8 ["!=xH !%!9!9!; DJ%kk*:FC%kk*:FC!,W-@!"E ,W-?!H".w/CU#L*74EqI(.$G%1'2I4&Q" +G5G K!,W6I1!M   &*jj43I3I&I&*&:&:Q&>'?D "&'D " #GZ<  D  $$SY/!  J$(JJ$>$>@JCI    s6$J JJctd)NzWThe -S option is meaningless for the image formatter. Use -O style= instead.)NotImplementedError)r;args r&get_style_defszImageFormatter.get_style_defss!#QR Rr%c4|j|jzS)z+ Get the height of a line. )rrrs r&_get_line_heightzImageFormatter._get_line_heightszzDMM))r%cB||jz|jzS)z8 Get the Y coordinate of a line number. )rrr;linenos r& _get_line_yzImageFormatter._get_line_ys!--//$..@@r%c|jS)z/ Get the width of a character. )rrs r&_get_char_widthzImageFormatter._get_char_widthszzr%c:||jz|jzS)z? Get the X coordinate of a character position. )rr)r; linelengths r& _get_char_xzImageFormatter._get_char_xsDNN*T-C-CCCr%cF|j||j|fS)zL Get the actual position for a character and line position. )rr)r;rrs r& _get_text_poszImageFormatter._get_text_poss% +T-=-=f-EEEr%c<|j|j|fS)zI Get the actual position for the start of a line number. )rrrs r&_get_linenumber_posz"ImageFormatter._get_linenumber_poss 0 0 899r%c(|d d|dz}|Sd}|S)zE Get the correct color for the token from the style. color#z#000r$)r;rKfills r&_get_text_colorzImageFormatter._get_text_colors/ > %w'D D r%c(|d d|dz}|Sd}|S)zP Get the correct background color for the token from the style. bgcolorNrr$)r;rKbg_colors r&_get_text_bg_colorz!ImageFormatter._get_text_bg_colors1   'U9--HHr%cF|jj|d|dS)z5 Get the correct font for the style. ritalic)r0r)r;rKs r&_get_style_fontzImageFormatter._get_style_fonts#zz""5=%/BBr%c|j||jz|j|dz|jzfS)z. Get the required image size. r)rrr)r; maxlinelength maxlinenos r&_get_image_sizezImageFormatter._get_image_sizesB  /$..@  Q/$..@B Br%c|j|j|t|j|j|j j |j|j|jdy)zA Remember a line number drawable to paint later. Nrtext_fgtext_bg) _draw_textrstrrjustrr0rrrr)r;posnors r&_draw_linenumberzImageFormatter._draw_linenumbersj   $ $U + K  d44 5$$T%:%:%)%<%<>''  r%cD|jj|||||fy)zB Remember a single drawable tuple to paint later. N)rr)r;posrrrrs r&rzImageFormatter._draw_texts! sD$ABr%c dx}x}}dx}}|D]=\}}||jvr|j}||jvr|j|} |jd}|jd} t | D]\} } | j d} | r|j |j||| |j| |j| |j| |jj| \}}||z }t||}|t| z }t||}| jdsd}d}|dz }@||_||_||_y)z9 Create drawables for the token content. rrT rrN)rtparent expandtabsrG enumeraterstriprrrrrr0rmaxlenrcr maxcharnor)r; tokensourcercharnorrrttypevaluerKrNirOtemp temp_widthrMs r&_create_drawablesz ImageFormatter._create_drawablessq'('')%&& 'LE5t{{* t{{*KK&E$$Q'E$$T*E$U+4{{4(OO**:v>#33E:"&"6"6u"="&"9"9%"@ $%)JJ$<$29L9LI M r%c |j||jtjd|j |j |j |j}|j|tj|}|jr|j|jz|jz dz}|j}|j d|z }|jD]?}|j#|dz } |j%|| f||z| |zfg|j&A|j(D]a\} } } } }|rB|j+| | }|j%| d| d| d|dz| d|dzg||j-| | | | c|j/||j0j3y)a  Format ``tokensource``, an iterable of ``(tokentype, tokenstring)`` tuples and write it into ``outfile``. This implementation calculates where it should draw each token on the pixmap, then calculates the required pixmap size and draws the items. RGBrrr)rr)rrN)rrrnewrrrrrr rrrrrrrrr rrtextsizersaverupper)r;routfiler r xr r  linenumberyrrrrr text_sizes r&formatzImageFormatter.format9s {+ ! YY   !3!3T^^ D  ! !  ""2&~~b! ==!7!77$:N:NNQRRA))+EGGAJNE"mm $$Z!^4AUAI(>?$(MM3,37.. .Cgw MMu4M@ AAA10Es1vPYZ[P\G\]dkl IIc5t'I : 3A **0023r%N)r)r r!r"r#rJaliases filenames unicodeoutputrr<rrrrrrrrrrrrrrrrrr$r%r&r r sjZ D#G IM 6pR* A  D F : C B  C & P ,"4r%r c$eZdZdZdZdgZdgZdZy)r z Create a GIF image from source code. This uses the Python Imaging Library to generate a pixmap from the source code. .. versionadded:: 1.0 img_gifrz*.gifNr r!r"r#rJrrrr$r%r&r r ^s" DgG I r%r c&eZdZdZdZddgZdgZdZy)r z Create a JPEG image from source code. This uses the Python Imaging Library to generate a pixmap from the source code. .. versionadded:: 1.0 img_jpgjpgrz*.jpgNr r$r%r&r r ls$ DfoG I!r%r c&eZdZdZdZddgZdgZdZy)rz Create a bitmap image from source code. This uses the Python Imaging Library to generate a pixmap from the source code. .. versionadded:: 1.0 img_bmprbitmapz*.bmpNr r$r%r&rrzs% DhG I r%r) r#rdr2pip._vendor.pygments.formatterrpip._vendor.pygments.utilrrrrrBPILrr r r ImportErrorrowinreg__all__rUr9r5r7r Exceptionr(r*r r r rr$r%r&r.s 4//M  Gh'(!=1  +%7k7393k(k(\m4Ym4f ! ! " " ! !EM  sF BB%B"!B"%C+B0/C0B:7C9B::C?C