Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
img.cpython-313.pyc274 linesDownload Raw Back to __pycache__
1�

2�j[���SrSSKrSSKrSSKJr SSKJrJrJrJ	r	 SSK3r4SSKJrJ
r
Jr SrSSKr/SQr/S	QS5S/S/S
S/S.rSrSrSr"SS\5r"SS\5r"SS5r"SS\5r"SS\5r"SS\5r"SS \5rg!\a SrNtf=f!\a SSKrN�!\a SrN�f=ff=f)!z�6pygments.formatters.img7~~~~~~~~~~~~~~~~~~~~~~~8 9Formatter for Pixmap output.10 11:copyright: Copyright 2006-present by the Pygments team, see AUTHORS.12:license: BSD, see LICENSE for details.13�N)�	Formatter)�get_bool_opt�get_int_opt�get_list_opt�get_choice_opt)�Image�	ImageDraw�	ImageFontTF)�ImageFormatter�GifImageFormatter�JpgImageFormatter�BmpImageFormatter)��Roman�Book�Normal�Regular�Medium�Oblique�Italic�BoldzBold ObliquezBold Italic)�NORMAL�ITALIC�BOLD�14BOLDITALICzDejaVu Sans MonozCourier New�Menloc��\rSrSrSrSrg)�PilNotAvailable�4z,When Python imaging library is not available�N��__name__�15__module__�__qualname__�__firstlineno__�__doc__�__static_attributes__r ��]D:\code\apps\devtools\python\user_packages\Python313\site-packages\pygments/formatters/img.pyrr4s��6r(rc��\rSrSrSrSrg)�FontNotFound�8z(When there are no usable fonts specifiedr Nr!r r(r)r+r+8s��2r(r+c�b�\rSrSrSrSSjrSrSrSrSr	SSjr16S	rS17rSr
SrS
rSrg)�FontManager�<z618Manages a set of fonts: normal, italic, bold, etc...19c��XlX l0UlSUlSUl[US5(d$[RRU5(aC[R"XR5nSUl[HnX0RU'M g[RRS5(a#U(d[UlUR!5 g[RRS5(a#U(d["UlUR%5 gU(d[&UlUR)5 g)NF�readT�win�darwin)�	font_name�	font_size�fonts�encoding�variable�hasattr�os�path�isfiler20�truetype�STYLES�sys�platform�21startswith�DEFAULT_FONT_NAME_WIN�_create_win�DEFAULT_FONT_NAME_MAC�_create_mac�DEFAULT_FONT_NAME_NIX�_create_nix)�selfr4r5�font�styles     r)�__init__�FontManager.__init__As���"��"����22���
���
��9�f�%�%������	�)B�)B��%�%�i���@�D� �D�M���$(�23�24�5�!� �
��<�<�"�"�5�)�)��!6�������
�\�\�
$�
$�X�
.�
.��!6��������!6������r(c�t�[R"SUSU3S/[RSS9nUR5upEURS:XajUR5nUHSnUR
S5(aMUR5R5RS5nU(dMQUs $ gg)Nzfc-listz:style=�file)�stdout�stderrrsFontconfig warning:�:)	�25subprocess�Popen�PIPE�communicate�26returncode�27splitlinesrA�decode�strip)	rH�namerJ�procrO�_�lines�liner;s	         r)�_get_nix_font_path�FontManager._get_nix_font_path\s�������t�f�G�E�7�,C�V� L�'1���t�E���$�$�&�	���?�?�a���%�%�'�E����?�?�#9�:�:���{�{�}�*�*�,�2�2�3�7���4��K��� r(c�B�[SHQnURURU5nUcM$[R"X R285URS' O [SURS35eSH�n[UHRnURURU5nUcM$[R"X R295URU' M` US:XaURSURU'M�URSURU'M� g)Nr�No usable fonts named: "�"�rrrrr)r>r_r4r30r=r5r6r+)rHrZr;rJ�	stylenames     r)rG�FontManager._create_nixjs����8�$�D��*�*�4�>�>�4�@�D���'0�'9�'9�$���'O��31�32�8�$��	%��!9�$�.�.�9I��K�L�L�5�E�#�E�]�	��.�.�t�~�~�y�I���#�(1�(:�(:�4���(P�D�J�J�u�%��	+��L�(�(,�33�34�6�(:�D�J�J�u�%�(,�35�36�8�(<�D�J�J�u�%�6r(c�h�URUS-U-R5R55$)N� )�getrY�lower)rH�font_maprZrJs    r)�_get_mac_font_path�FontManager._get_mac_font_path~s,���|�|�T�C�Z�%�/�6�6�8�>�>�@�A�Ar(c�"^�0n[RR[R"S5S5SS4H2mUR	U4Sj[R37"T555 M4 [SHQnURXRU5nUcM$[R"X0R5URS' O [SURS35eS	H�n[UHRnURXRU5nUcM$[R"X0R5URU' M` US38:XaURSURU'M�URSURU'M� g)N�HOMEzLibrary/Fonts/z/Library/Fonts/z/System/Library/Fonts/c3�*># �UH�u pUH{nUR5RS5(dM)[RR	U5SR5[RRTU54v� M} M� g7f))�ttf�ttcrN)rj�endswithr:r;�splitext�join)�.0r\�files�f�font_dirs    �r)�	<genexpr>�*FontManager._create_mac.<locals>.<genexpr>�sr����7�#4�K�A�q��A��7�7�9�%�%�n�5�L����!�!�!�$�Q�'�-�-�/������h��1J�K��L�#4�s�1B�ABrrbrcrdrr)r:r;ru�getenv�update�walkr>rlr4r39r=r5r6r+)rHrkrZr;rJrerys      @r)rE�FontManager._create_mac�sO����������b�i�i��&7�9I�J�*�,D�F�H��O�O�7�#%�7�7�8�#4�7�
7�F��8�$�D��*�*�8�^�^�T�J�D���'0�'9�'9�$���'O��40�41�8�$��	%��!9�$�.�.�9I��K�L�L�5�E�#�E�]�	��.�.�x����S���#�(1�(:�(:�4���(P�D�J�J�u�%��	+��L�(�(,�42�43�6�(:�D�J�J�u�%�(,�44�45�8�(<�D�J�J�u�%�6r(c���SHGnUH>nSRX&=(a SU-U5n[R"X5up�Us s $ MI U(a[	SUSUSS35eg![a Mpf=f)N)rz (TrueType)z{}{}{}rhzFont z (rz) not found in registry)�format�_winreg�QueryValueEx�OSErrorr+)46rH�key�basename�styles�fail�suffixrJ�valname�valr\s47          r)�_lookup_win�FontManager._lookup_win�s���)�F����&�o�o�h�8K�#�e�)�V�T�G�$�1�1�#�?�F�C��J�	 �*��"�U�8�*�B�v�a�y�k�AX�#Y�Z�Z�������s�7A+�+48A9�8A9c���Sn[RS4[RS4[RS4[RS4/nUGH"n[R"U6nUR	X@R49[SS5n[R"XPR5URS'SH�nUR	X@R50[U5nU(a/[R"XPR5URU'M\US:XaURSURU'M�URSURU'M� [R"U5  g U(aUe[S5e![anUnSnAOSnAff=f[R"U5 GMn![R"U5 f=f![a GM�f=f)	Nz2Software\Microsoft\Windows NT\CurrentVersion\Fontsz/Software\Microsoft\Windows\CurrentVersion\FontsrTrdrrz$Can't open Windows font registry key)r��HKEY_CURRENT_USER�HKEY_LOCAL_MACHINE�OpenKeyr�r4r>r51r=r5r6�CloseKeyr+r�)rH�lookuperror�keynames�keynamer�r;rJ�errs        r)rC�FontManager._create_win�s������/�/�1f�g��/�/�1c�d��0�0�2g�h��0�0�2d�e�h�� �G�
��o�o�w�/��*��+�+�C�����AQ�SW�X�D�+4�+=�+=�d�N�N�+S�D�J�J�x�(�!A��#�/�/��^�^�V�E�]�S���09�0B�0B�4���0X�D�J�J�u�-�$��4�48�J�J�v�4F��52�53�5� 1�48�J�J�x�4H��54�55�5� 1�"B���$�$�S�)�' �:�!�!��F�G�G��$�&�"%�K��&����$�$�S�)��G�$�$�S�)���
��
�sO�G�$C3F�G�56F�F�F9�F�F9� G�9G�G�57G#�"G#c�$�URS5$)z58Get the character size.59�M)�
get_text_size�rHs r)�
get_char_size�FontManager.get_char_size�s���!�!�#�&�&r(c��URSn[US5(aURU5SS$URU5$)z$60Get the text size (width, height).61r�getbbox��)r6r9r��getsize)rH�textrIs   r)r��FontManager.get_text_size�sD���z�z�(�#���4��#�#��<�<��%�a��*�*��<�<��%�%r(c���U(a8U(a1UR(aURS5$URS$U(a1UR(aURS5$URS$U(a1UR(aURS5$URS$UR(aURS5$URS$)z.62Get the font based on bold and italic flags.63rrrr)r8�	get_styler6)rH�bold�obliques   r)�get_font�FontManager.get_font�s����G��}�}��~�~�l�3�3��:�:�l�+�+�
��}�}��~�~�f�-�-��:�:�f�%�%�
��}�}��~�~�h�/�/��:�:�h�'�'��}�}��~�~�h�/�/��:�:�h�'�'r(c��URUn[UHnURU5 Us $ U$![a M*[a Uss $f=f)ze64Get the specified style of the font if it is a variable font.65If not found, return the normal font.66)r6r>�set_variation_by_name�67ValueErrorr�)rHrJrI�68style_names    r)r��FontManager.get_style�s`��69�z�z�%� �� ��-�J�
��*�*�:�6���(�����
���
���
�s�6�70A�A�A)r7r4r5r6r8N)�)F)r"r#r$r%r&rKr_rGrlrEr�rCr�r�r�r�r'r r(r)r.r.<sA����6�=�(B�=�:�%H�N'�&�(�2r(r.c��\rSrSrSrSr/SQrS/rSrSr	Sr71SS	jrS72rSr
SrS
rSrSrSrSrSrSrSrSrSrSrSrSrSrg)ria#	73Create a PNG image from source code. This uses the Python Imaging Library to74generate a pixmap from the source code.75 76.. versionadded:: 0.1077 78Additional options accepted:79 80`image_format`81    An image format to output to that is recognised by PIL, these include:82 83    * "PNG" (default)84    * "JPEG"85    * "BMP"86    * "GIF"87 88`line_pad`89    The extra spacing (in pixels) between each line of text.90 91    Default: 292 93`font_name`94    The font name to be used as the base font from which others, such as95    bold and italic fonts will be generated.  This really should be a96    monospace font to look sane.97    If a filename or a file-like object is specified, the user must98    provide different styles of the font.99 100    Default: "Courier New" on Windows, "Menlo" on Mac OS, and101             "DejaVu Sans Mono" on \*nix102 103`font_size`104    The font size in points to be used.105 106    Default: 14107 108`image_pad`109    The padding, in pixels to be used at each edge of the resulting image.110 111    Default: 10112 113`line_numbers`114    Whether line numbers should be shown: True/False115 116    Default: True117 118`line_number_start`119    The line number of the first line.120 121    Default: 1122 123`line_number_step`124    The step used when printing line numbers.125 126    Default: 1127 128`line_number_bg`129    The background colour (in "#123456" format) of the line number bar, or130    None to use the style background color.131 132    Default: "#eed"133 134`line_number_fg`135    The text color of the line numbers (in "#123456"-like format).136 137    Default: "#886"138 139`line_number_chars`140    The number of columns of line numbers allowable in the line number141    margin.142 143    Default: 2144 145`line_number_bold`146    Whether line numbers will be bold: True/False147 148    Default: False149 150`line_number_italic`151    Whether line numbers will be italicized: True/False152 153    Default: False154 155`line_number_separator`156    Whether a line will be drawn between the line number area and the157    source code area: True/False158 159    Default: True160 161`line_number_pad`162    The horizontal padding (in pixels) between the line number margin, and163    the source code area.164 165    Default: 6166 167`hl_lines`168    Specify a list of lines to be highlighted.169 170    .. versionadded:: 1.2171 172    Default: empty list173 174`hl_color`175    Specify the color for highlighting lines.176 177    .. versionadded:: 1.2178 179    Default: highlight color of the selected style180�img)r��IMG�pngz*.pngFr�c�h�[(d[S5e[R"U40UD6 SUl[UR5UlURRcSUlOURRUl[US/SQURSS9Ul[US	S1815Ul
[USS5Ul[US
S5n[UR!SS5U5UlUR"R%5uUlUlUR!SS5UlUR!SS5Ul[USS5Ul[1USS5Ul[1USS5Ul[USS5UlSS5Ul[1USS5Ul[USS5Ul[USS5UlUR8(a/UR&UR.-UR6S--Ul OS Ul /Ul![EUS!/5nUH(nURBRG[IU55 M* UR!S"URRL5=(d S#Ul'/Ul(g![Ja Muf=f)$z5182See the class docstring for explanation of options.183z5Python Imaging Library is required for this formatter�latin1Nz#fff�image_format)r��jpeg�gif�bmpT)�normcase�	image_pad�184�line_padr�r5r�r4r�line_number_fgz#886�line_number_bgz#eed�line_number_chars�line_number_boldF�line_number_italic�line_number_pad��line_numbers�line_number_separator�line_number_step��line_number_startr�hl_lines�hl_colorz#f90))�
pil_availablerrrKr7�dictrJr��background_colorr�default_image_formatr�rr�r�r.rir6r��fontw�fonthr�r�r�rr�r�r�r�r�r�r��line_number_widthr�r�append�intr��highlight_colorr��	drawables)rH�options�fontsize�hl_lines_strr^s     r)rK�ImageFormatter.__init__�sv���}�!�G�I�
I����4�+�7�+� ��
��4�:�:�&����:�:�&�&�.�$*�D�!�$(�J�J�$?�$?�D�!�*��^�%B��%�%��6���%�W�k�2�>���#�G�Z��;��
��w��R�8�� ����[�"�!=�x�H��185�!%���!9�!9�!;���186�D�J�%�k�k�*:�F�C���%�k�k�*:�F�C���!,�W�-@�!�"E��� ,�W�-?��!H���".�w�/C�U�#L���*�7�4E�q�I���(��.�$�G���%1�'�2I�4�&Q��"� +�G�5G�� K���!,�W�6I�1�!M������&*�j�j�4�3I�3I�&I�&*�&:�&:�Q�&>�'?�D�"�&'�D�"���
�#�G�Z��<�� �D�
��
�
�$�$�S��Y�/�!�187 ���J�$(�J�J�$>�$>�@�J�CI�	
�
�����	�
��
�s�?$J#�#188J1�0J1c��[S5e)NzWThe -S option is meaningless for the image formatter. Use -O style=<stylename> instead.)�NotImplementedError)rH�args  r)�get_style_defs�ImageFormatter.get_style_defs�s��!�#Q�R�	Rr(c�4�URUR-$)z189Get the height of a line.190)r�r�r�s r)�_get_line_height�ImageFormatter._get_line_height�s���z�z�D�M�M�)�)r(c�@�XR5-UR-$)z(191Get the Y coordinate of a line number.192)r�r��rH�linenos  r)�_get_line_y�ImageFormatter._get_line_y�s���-�-�/�/�$�.�.�@�@r(c��UR$)z193Get the width of a character.194)r�r�s r)�_get_char_width�ImageFormatter._get_char_width�s���z�z�r(c�8�XR-UR-$)z/195Get the X coordinate of a character position.196)r�r�)rH�197linelengths  r)�_get_char_x�ImageFormatter._get_char_x�s���N�N�*�T�-C�-C�C�Cr(c�F�URU5URU54$)z<198Get the actual position for a character and line position.199)r�r�)rHr�r�s   r)�
_get_text_pos�ImageFormatter._get_text_pos�s%�����200�+�T�-=�-=�f�-E�E�Er(c�<�URURU54$)z9201Get the actual position for the start of a line number.202)r�r�r�s  r)�_get_linenumber_pos�"ImageFormatter._get_linenumber_pos�s������ 0� 0�� 8�9�9r(c�*�USb203SUS-nU$SnU$)z5204Get the correct color for the token from the style.205�color�#z#000r )rHrJ�fills   r)�_get_text_color�ImageFormatter._get_text_color�s/����>�%���w��'�D����D��r(c�*�USb206SUS-nU$SnU$)z@207Get the correct background color for the token from the style.208�bgcolorNr�r )rHrJ�bg_colors   r)�_get_text_bg_color�!ImageFormatter._get_text_bg_color�s1�����'��U�9�-�-�H����H��r(c�F�URRUSUS5$)z%209Get the correct font for the style.210r��italic)r6r�)rHrJs  r)�_get_style_font�ImageFormatter._get_style_font�s#���z�z�"�"�5��=�%��/�B�Br(c��URU5UR-URUS-5UR-4$)z211Get the required image size.212r)r�r�r�)rH�
maxlinelength�	maxlinenos   r)�_get_image_size�ImageFormatter._get_image_sizesB��� � ��/�$�.�.�@�� � ��Q��/�$�.�.�@�B�	Br(c���URURU5[U5RUR5UR213R
URUR5URSS9 g)z1214Remember a line number drawable to paint later.215N�rI�text_fg�text_bg)216�217_draw_textr��str�rjustr�r6r�r�r�r�)rH�posnor�s   r)�_draw_linenumber�ImageFormatter._draw_linenumbersj��	
����$�$�U�+���K���d�4�4�5����$�$�T�%:�%:�%)�%<�%<�>��'�'��
	�	218r(c�@�URRXX4U45 g)z2219Remember a single drawable tuple to paint later.220N)r�r�)rH�posr�rIrr
s      r)r�ImageFormatter._draw_texts��	
�����s�$��A�Br(c���S=n=p4S=pVUGHDupxXpR;aURnXpR;aMURUn	URS5nURS5n221[	U2225H�up�URS5n
U
(a�UR
URXb5U
URU	5URU	5URU	5S9 URRU
5up�Xn-
n[XV5nU[U
5-
n[XC5nURS5(dM�SnSnUS-
nM� GMG XPlX@lX lg)z)223Create drawables for the token content.224rr�T�225rr�N)r��parent�226expandtabsrW�	enumerate�rstriprr�rr�r�r6r��max�lenrsr�	maxcharnor)rH�tokensourcer��charnorrr��ttype�valuerJr]�ir^�temp�227temp_widthr\s                r)�_create_drawables� ImageFormatter._create_drawablessX��'(�'��'��%&�&�
�'�L�E��{�{�*������{�{�*��K�K��&�E��$�$�Q�'�E��$�$�T�*�E�$�U�+����{�{�4�(����O�O��*�*�:�>��#�3�3�E�:�"&�"6�"6�u�"=�"&�"9�"9�%�"@�$��%)�J�J�$<�$<�T�$B�M�J��,�J�$'�
�$B�M��c�$�i�'�F� #�I� 6�I��=�=��&�&�!"�J��F��a�K�F�',�(�<+��"���r(c���UR(dg[UR5H6nXR-nX R-S:XdM%URX5 M8 g)z(228Create drawables for the line numbers.229Nr)r��rangerr�r�r)rH�p�ns   r)�_draw_line_numbers�!ImageFormatter._draw_line_numbersBsP��� � ���t�~�~�&�A��*�*�*�A��)�)�)�a�/��%�%�a�+�'r(c�v�UR(dgURcg[R"U5nURSnUR230UR-UR-231nURSXC4/URS9 UR(aURUS4XC4/URS9 Ag)z0232Paint the line number background on the image.233N�����)rr�r�r)r�r�r	�Draw�sizer�r�r��	rectangler�r�r^)rH�im�draw�recth�rectws     r)�_paint_line_number_bg�$ImageFormatter._paint_line_number_bgMs���� � �����&���~�~�b�!������������!7�!7�7�$�:N�:N�N��������/� �/�/�	�	1��%�%��I�I��q�z�E�>�2��9L�9L�I�M�r(c	���URU5 UR5 [R"SUR	UR234UR5UR5nURU5 [R"U5nUR(a�URUR-UR-235S-nUR5nUR SU-236nURH:nUR#US-2375n	UR%XY4XW-X�-4/UR&S9 M< UR(Hup�p�nU(aa[+US5(aUR-X�S9nOUR/U5SSnUR%U238SU239SU240SUS-U241SUS-/US9 UR1X�X�S	9 M� UR3X R4R755 g)242z�243Format ``tokensource``, an iterable of ``(tokentype, tokenstring)``244tuples and write it into ``outfile``.245 246This implementation calculates where it should draw each token on the247pixmap, then calculates the required pixmap size and draws the items.248�RGBr�rr1�textsize)r�rIr�N)rIr�)r'r-r�newrrrr�r9r	r2r�r�r�r�r�r3r�r4r�r�r9r=r�r��saver��upper)rHr �outfiler5r6�xr7r8�249linenumber�yrr#rIrr
�	text_sizes                r)r��ImageFormatter.format^s���	
���{�+����!�
�Y�Y��� � ��!3�!3�T�^�^�D��!�!�250��251	
�"�"�2�&��~�~�b�!���=�=�����!7�!7�7�$�:N�:N�N�QR�R�A��)�)�+�E��G�G�A�J��N�E�"�m�m�252��$�$�Z�!�^�4���������A�I�(>�?�$(�M�M��3�,�37�.�.�.�C��w���4��,�,� $�
�
�5�
� D�I� $���U� 3�A�B� 7�I�����A���A���A���1��0E�s�1�v�PY�Z[�P\�G\�]�dk��l��I�I�c�t�I�:�3A�	����*�*�0�0�2�3r()r�r�r7r�r6r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrr�N)r)r"r#r$r%r&rZ�aliases�	filenames�
unicodeoutputr�rKr�r�r�r�r�r�r�r�r�rrrrr'r-r9r�r'r r(r)rrs���l�^�D�#�G��	�I��M� ��6�pR�*�A��D�F�:���C�B�253�C�& �P	,��"#4r(rc�,�\rSrSrSrSrS/rS/rSrSr	g)ri�z�254Create a GIF image from source code. This uses the Python Imaging Library to255generate a pixmap from the source code.256 257.. versionadded:: 1.0258�img_gifr�z*.gifr N�259r"r#r$r%r&rZrGrHr�r'r r(r)rr�s"����D��g�G��	�I� �r(rc�.�\rSrSrSrSrSS/rS/rSrSr	g)	r
i�z�260Create a JPEG image from source code. This uses the Python Imaging Library to261generate a pixmap from the source code.262 263.. versionadded:: 1.0264�img_jpg�jpgr�z*.jpgr NrLr r(r)r
r
�s$����D��f�o�G��	�I�!�r(r
c�.�\rSrSrSrSrSS/rS/rSrSr	g)	ri�z�265Create a bitmap image from source code. This uses the Python Imaging Library to266generate a pixmap from the source code.267 268.. versionadded:: 1.0269�img_bmpr��bitmapz*.bmpr NrLr r(r)rr�s%����D��h��G��	�I� �r(r) r&r:r?�pygments.formatterr�
pygments.utilrrrrrR�PILrr	r270r��ImportErrorr��winreg�__all__r>rFrBrDr�	Exceptionr+r.rrr
rr r(r)�<module>rZs���271�272�(�����/�/��M��� ��G��h�'��(�!�=�1�	273��+��%����7�k�7�3�9�3�O�O�ds4�Y�s4�r!��!�"��"�!��!��Y���M���274��� ���������s:�B�B&�B#�"B#�&C�-B3�3B?�;C�>B?�?C
codekingpro/portable-devtools · Team Ai