HEX
Server: Apache/2.4.67 (Debian)
System: Linux vps-b2547eb4 6.1.0-41-cloud-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.158-1 (2025-11-09) x86_64
User: root (0)
PHP: 8.2.31
Disabled: NONE
Upload Files
File: //lib/python3/dist-packages/pygments/formatters/__pycache__/img.cpython-311.pyc
�

�E�c�U���dZddlZddlZddlmZddlmZmZmZm	Z	ddl
Z
	ddlmZm
Z
mZdZn
#e$rdZYnwxYw	ddlZn#e$r	ddlZn
#e$rdZYnwxYwYnwxYwgd�Zgd	�d
dgdgd
dgd�ZdZdZdZGd�de��ZGd�de��ZGd�d��ZGd�de��ZGd�de��ZGd�de��ZGd�d e��ZdS)!z�
    pygments.formatters.img
    ~~~~~~~~~~~~~~~~~~~~~~~

    Formatter for Pixmap output.

    :copyright: Copyright 2006-2022 by the Pygments team, see AUTHORS.
    :license: BSD, see LICENSE for details.
�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�
BOLDITALICzDejaVu Sans MonozCourier New�Menloc��eZdZdZdS)�PilNotAvailablez,When Python imaging library is not availableN��__name__�
__module__�__qualname__�__doc__���9/usr/lib/python3/dist-packages/pygments/formatters/img.pyrr5s������6�6�6�6r%rc��eZdZdZdS)�FontNotFoundz(When there are no usable fonts specifiedNrr$r%r&r(r(9s������2�2�2�2r%r(c�R�eZdZdZdd�Zd�Zd�Zd�Zd�Zdd	�Z	d
�Z
d�Zd�Zd
�Z
dS)�FontManagerz>
    Manages a set of fonts: normal, italic, bold, etc...
    �c��||_||_i|_d|_tj�d��r$|st|_|���dStj�d��r$|st|_|�
��dS|st|_|���dS)N�win�darwin)
�	font_name�	font_size�fonts�encoding�sys�platform�
startswith�DEFAULT_FONT_NAME_WIN�_create_win�DEFAULT_FONT_NAME_MAC�_create_mac�DEFAULT_FONT_NAME_NIX�_create_nix)�selfr/r0s   r&�__init__zFontManager.__init__Bs���"���"�����
���
��<�"�"�5�)�)�	��
7�!6�����������
�\�
$�
$�X�
.�
.�	��
7�!6������������
7�!6����������r%c�|�tjd|�d|��dgtjd���}|���\}}|jdkrp|���}|D]W}|�d��r�|�������d��}|r|cS�XdSdS)Nzfc-listz:style=�file)�stdout�stderrrsFontconfig warning:�:)	�
subprocess�Popen�PIPE�communicate�
returncode�
splitlinesr5�decode�strip)	r<�name�style�procr@�_�lines�line�paths	         r&�_get_nix_font_pathzFontManager._get_nix_font_pathTs������T�T�T�5�5�,I�6� R�'1��t�E�E�E���$�$�&�&�	����?�a����%�%�'�'�E��
 �
 ���?�?�#9�:�:����{�{�}�}�*�*�,�,�2�2�3�7�7��� ��K�K�K� ��4� �r%c���tdD]C}|�|j|��}|�$tj||j��|jd<n�Dtd|jz���dD]�}t|D]C}|�|j|��}|�$tj||j��|j|<n2�D|dkr|jd|j|<�o|jd|j|<��dS)Nr�No usable fonts named: "%s"�rrrrr)�STYLESrRr/r
�truetyper0r1r()r<rKrQrL�	stylenames     r&r;zFontManager._create_nixbs���8�$�	/�	/�D��*�*�4�>�4�@�@�D���'0�'9�$���'O�'O��
�8�$��� ��<�#�~� .�/�/�
/�5�
	=�
	=�E�#�E�]�	
=�	
=�	��.�.�t�~�y�I�I���#�(1�(:�4���(P�(P�D�J�u�%��E�$��L�(�(�(,�
�6�(:�D�J�u�%�%�(,�
�8�(<�D�J�u�%��
	=�
	=r%c��|�|dz|z��������S)N� )�getrJ�lower)r<�font_maprKrLs    r&�_get_mac_font_pathzFontManager._get_mac_font_pathws5���|�|�T�C�Z�%�/�6�6�8�8�>�>�@�@�A�A�Ar%c����i}tj�tjd��d��ddfD]5�|��fd�tj���D�����6tdD]D}|�||j|��}|�$tj
||j��|jd<n�Etd|jz���dD]�}t|D]D}|�||j|��}|�$tj
||j��|j|<n2�E|d	kr|jd
|j|<�p|jd|j|<��dS)N�HOMEzLibrary/Fonts/z/Library/Fonts/z/System/Library/Fonts/c3��K�|]�}|����d���)tj�|��d���tj��|��fV���dS))�ttf�ttcrN)r\�endswith�osrQ�splitext�join)�.0�f�font_dirs  �r&�	<genexpr>z*FontManager._create_mac.<locals>.<genexpr>~s������7�7���7�7�9�9�%�%�n�5�5�7���!�!�!�$�$�Q�'�-�-�/�/�����h��1J�1J�K�7�7�7�7�7�7r%rrTrUrr)rerQrg�getenv�update�listdirrVr^r/r
rWr0r1r()r<r]rKrQrLrXrjs      @r&r9zFontManager._create_maczs����������b�i��&7�&7�9I�J�J�*�,D�F�	7�	7�H��O�O�7�7�7�7���H�-�-�7�7�7�
7�
7�
7�
7�
�8�$�	/�	/�D��*�*�8�T�^�T�J�J�D���'0�'9�$���'O�'O��
�8�$��� ��<�#�~� .�/�/�
/�5�
	=�
	=�E�#�E�]�	
=�	
=�	��.�.�x����S�S���#�(1�(:�4���(P�(P�D�J�u�%��E�$��L�(�(�(,�
�6�(:�D�J�u�%�%�(,�
�8�(<�D�J�u�%��
	=�
	=r%Fc���dD]B}|D]=}	|�|od|z�|��}tj||��\}}	|ccS#t$rY�:wxYw�C|rtd|�d|d�d����dS)N)rz (TrueType)rZzFont z (rz) not found in registry)�_winreg�QueryValueEx�OSErrorr()
r<�key�basename�styles�fail�suffixrL�valname�valrNs
          r&�_lookup_winzFontManager._lookup_win�s���)�	�	�F��
�
���*2�(�E�4G�c�%�i�4G���P�G�$�1�#�w�?�?�F�C���J�J�J�J�J�������H�����
��
:�"�l�$,�H�H�f�Q�i�i�i�$9�:�:�:��4s�&5�
A�Ac�@�d}tjdftjdftjdftjdfg}|D�]P}	tj|�}	|�||jtdd��}tj||j	��|j
d<dD]}|�||jt|��}|r#tj||j	��|j
|<�N|dkr|j
d|j
|<�j|j
d|j
|<��	tj|��dS#t$r}|}Yd}~nd}~wwxYw	tj|��n#tj|��wxYw��A#t$rY��NwxYw|r|�td���)	Nz2Software\Microsoft\Windows NT\CurrentVersion\Fontsz/Software\Microsoft\Windows\CurrentVersion\FontsrTrUrrz$Can't open Windows font registry key)rp�HKEY_CURRENT_USER�HKEY_LOCAL_MACHINE�OpenKeyrzr/rVr
rWr0r1�CloseKeyr(rr)r<�lookuperror�keynames�keynamersrQrL�errs        r&r7zFontManager._create_win�s������/�1f�g��/�1c�d��0�2g�h��0�2d�e�h�� �	H�	H�G�
��o�w�/��*��+�+�C�����AQ�SW�X�X�D�+4�+=�d�D�N�+S�+S�D�J�x�(�!A�I�I��#�/�/��T�^�V�E�]�S�S���I�09�0B�4���0X�0X�D�J�u�-�-�$��4�4�48�J�v�4F��
�5� 1� 1�48�J�x�4H��
�5� 1� 1���$�S�)�)�)�)�)�)��$�&�&�&�"%�K�K�K�K�K�K�����&������$�S�)�)�)�)��G�$�S�)�)�)�)����)���
�
�
���
�����
"�!�!��F�G�G�GsN�E<�CD2�E<�2
E�<E�>E!�E�E!�E<�!E7�7E<�<
F
�	F
c�,�|�d��S)z)
        Get the character size.
        �M)�
get_text_size�r<s r&�
get_char_sizezFontManager.get_char_size�s���!�!�#�&�&�&r%c��|jd}t|d��r|�|��dd�S|�|��S)z4
        Get the text size (width, height).
        r�getbbox��)r1�hasattrr��getsize)r<�text�fonts   r&r�zFontManager.get_text_size�sO���z�(�#���4��#�#�	&��<�<��%�%�a��c�*�*��<�<��%�%�%r%c�z�|r|r
|jdS|r
|jdS|r
|jdS|jdS)z>
        Get the font based on bold and italic flags.
        rrrr)r1)r<�bold�obliques   r&�get_fontzFontManager.get_font�sW���	(�G�	(��:�l�+�+�
�	(��:�f�%�%�
�	(��:�h�'�'��:�h�'�'r%N)r+)F)r r!r"r#r=rRr;r^r9rzr7r�r�r�r$r%r&r*r*=s�������������$���=�=�=�*B�B�B�=�=�=�:
�
�
�
�%H�%H�%H�N'�'�'�&�&�&�(�(�(�(�(r%r*c��eZdZdZdZgd�ZdgZdZdZd�Z	dd	�Z
d
�Zd�Zd�Z
d
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�ZdS)ra�	
    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)r��IMG�pngz*.pngFr�c�f�tstd���tj|fi|��d|_t|j��|_|jj�d|_n|jj|_t|dgd�|j
d���|_t|d	d
��|_
t|dd��|_t|d
d��}t|�dd��|��|_|j���\|_|_|�dd��|_|�dd��|_t|dd��|_t1|dd��|_t1|dd��|_t|dd��|_t1|dd��|_t1|dd��|_t|dd��|_t|dd��|_|jr |j|jz|jdzz|_ nd |_ g|_!tE|d!g��}|D]:}	|j!�#tI|�����+#tJ$rY�7wxYw|�d"|jj&��pd#|_'g|_(dS)$zE
        See the class docstring for explanation of options.
        z5Python Imaging Library is required for this formatter�latin1Nz#fff�image_format)r��jpeg�gif�bmpT)�normcase�	image_pad�
�line_padr�r0r+r/r�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_availablerrr=r2�dictrLru�background_colorr�default_image_formatr�rr�r�r*r[r1r��fontw�fonthr�r�r�rr�r�r�r�r�r�r��line_number_widthr�r�append�int�
ValueError�highlight_colorr��	drawables)r<�options�fontsize�hl_lines_strrPs     r&r=zImageFormatter.__init__as����	I�!�G�I�I�
I���4�+�+�7�+�+�+� ��
��4�:�&�&����:�&�.�$*�D�!�!�$(�J�$?�D�!�*��^�%B�%B�%B��%��6�6�6���%�W�k�2�>�>���#�G�Z��;�;��
��w��R�8�8�� ����[�"�!=�!=�x�H�H��
�!%��!9�!9�!;�!;���
�D�J�%�k�k�*:�F�C�C���%�k�k�*:�F�C�C���!,�W�-@�!�"E�"E��� ,�W�-?��!H�!H���".�w�/C�U�#L�#L���*�7�4E�q�I�I���(��.�$�G�G���%1�'�2I�4�&Q�&Q��"� +�G�5G�� K� K���!,�W�6I�1�!M�!M�����	'�&*�j�4�3I�&I�&*�&:�Q�&>�'?�D�"�"�&'�D�"���
�#�G�Z��<�<�� �	�	�D�
��
�$�$�S��Y�Y�/�/�/�/���
�
�
���
�������J�$(�J�$>�@�@�J�CI�	
�
�����s�'I3�3
J�?Jrc� �td���)NzWThe -S option is meaningless for the image formatter. Use -O style=<stylename> instead.)�NotImplementedError)r<�args  r&�get_style_defszImageFormatter.get_style_defs�s��!�#Q�R�R�	Rr%c� �|j|jzS)z+
        Get the height of a line.
        )r�r�r�s r&�_get_line_heightzImageFormatter._get_line_height�s���z�D�M�)�)r%c�@�||���z|jzS)z8
        Get the Y coordinate of a line number.
        )r�r��r<�linenos  r&�_get_line_yzImageFormatter._get_line_y�s"����-�-�/�/�/�$�.�@�@r%c��|jS)z/
        Get the width of a character.
        )r�r�s r&�_get_char_widthzImageFormatter._get_char_width�s���z�r%c�&�||jz|jzS)z?
        Get the X coordinate of a character position.
        )r�r�)r<�
linelengths  r&�_get_char_xzImageFormatter._get_char_x�s���D�N�*�T�-C�C�Cr%c�V�|�|��|�|��fS)zL
        Get the actual position for a character and line position.
        )r�r�)r<r�r�s   r&�
_get_text_poszImageFormatter._get_text_pos�s+�����
�+�+�T�-=�-=�f�-E�-E�E�Er%c�:�|j|�|��fS)zI
        Get the actual position for the start of a line number.
        )r�r�r�s  r&�_get_linenumber_posz"ImageFormatter._get_linenumber_pos�s����� 0� 0�� 8� 8�9�9r%c�2�|d�d|dz}nd}|S)zE
        Get the correct color for the token from the style.
        �colorN�#z#000r$)r<rL�fills   r&�_get_text_colorzImageFormatter._get_text_color�s(����>�%���w��'�D�D��D��r%c�2�|d�d|dz}nd}|S)zP
        Get the correct background color for the token from the style.
        �bgcolorNr�r$)r<rL�bg_colors   r&�_get_text_bg_colorz!ImageFormatter._get_text_bg_color�s*�����'��U�9�-�-�H�H��H��r%c�P�|j�|d|d��S)z5
        Get the correct font for the style.
        r��italic)r1r�)r<rLs  r&�_get_style_fontzImageFormatter._get_style_font�s$���z�"�"�5��=�%��/�B�B�Br%c�|�|�|��|jz|�|dz��|jzfS)z.
        Get the required image size.
        r)r�r�r�)r<�
maxlinelength�	maxlinenos   r&�_get_image_sizezImageFormatter._get_image_size�sD��� � ��/�/�$�.�@�� � ��Q��/�/�$�.�@�B�	Br%c��|�|�|��t|���|j��|j�|j|j��|j	d���dS)zA
        Remember a line number drawable to paint later.
        N�r��text_fg�text_bg)
�
_draw_textr��str�rjustr�r1r�r�r�r�)r<�posnor�s   r&�_draw_linenumberzImageFormatter._draw_linenumber�s}��	
����$�$�U�+�+���K�K���d�4�5�5���$�$�T�%:�%)�%<�>�>��'��
	�	
�	
�	
�	
�	
r%c�D�|j�|||||f��dS)zB
        Remember a single drawable tuple to paint later.
        N)r�r�)r<�posr�r�r�r�s      r&r�zImageFormatter._draw_text�s+��	
����s�D�$���A�B�B�B�B�Br%c��dx}x}}dx}}|D�][\}}||jvr|j}||jv�|j|}	|�d��}|�d��}
t	|
��D]�\}}|�d��}
|
r�|�|�||��|
|�|	��|�	|	��|�
|	�����|j�|
��\}}||z
}t||��}|t|
��z
}t||��}|�d��r	d}d}|dz
}����]||_||_||_dS)z9
        Create drawables for the token content.
        rr�T�
r�r�N)ru�parent�
expandtabsrH�	enumerate�rstripr�r�r�r�r�r1r��max�lenrdr��	maxcharnor�)r<�tokensourcer��charnor�r�r��ttype�valuerLrO�irP�temp�
temp_widthrNs                r&�_create_drawablesz ImageFormatter._create_drawables�s���'(�'��'��)�%&�&�
�
�'�	 �	 �L�E�5��t�{�*�*�����t�{�*�*��K��&�E��$�$�Q�'�'�E��$�$�T�*�*�E�$�U�+�+�
 �
 ���4��{�{�4�(�(���7��O�O��*�*�:�v�>�>��#�3�3�E�:�:�"&�"6�"6�u�"=�"=�"&�"9�"9�%�"@�"@�$����%)�J�$<�$<�T�$B�$B�M�J���*�,�J�$'�
�z�$B�$B�M��c�$�i�i�'�F� #�I�v� 6� 6�I��=�=��&�&� �!"�J��F��a�K�F��'
 �(+���"�������r%c��|jsdSt|j��D]0}||jz}||jzdkr|�||���1dS)z8
        Create drawables for the line numbers.
        Nr)r��ranger�r�r�r�)r<�p�ns   r&�_draw_line_numbersz!ImageFormatter._draw_line_numberssn��� �	��F��t�~�&�&�	,�	,�A��D�*�*�A��D�)�)�a�/�/��%�%�a��+�+�+��	,�	,r%c�.�|jsdS|j�dStj|��}|jd}|j|jz|jz
}|�d||fg|j	���|j
r"|�|df||fg|j���~dS)z@
        Paint the line number background on the image.
        N���)rr�r�r)r�r�r	�Draw�sizer�r�r��	rectangler�r�rP)r<�im�draw�recth�rectws     r&�_paint_line_number_bgz$ImageFormatter._paint_line_number_bg(s���� �	��F���&��F��~�b�!�!����������!7�7�$�:N�N���������/� �/�	�	1�	1�	1��%�	N��I�I��q�z�E�5�>�2��9L�I�M�M�M��D�Dr%c	��|�|��|���tjd|�|j|j��|j��}|�|��tj
|��}|jr�|j|j
z|jz
dz}|���}|jd|z
}|jD]B}|�|dz
��}	|�||	f||z|	|zfg|j����C|jD]\}
}}}
}|r\|�||���}|�|
d|
d|
d|dz|
d|dzg|���|�|
|||
�����|�||j�����dS)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.
        �RGBr�rr)r�r�)r�r�N)r�rr�newr�r�r�r�rr	rr�r�r�r�r�rr�r	r�r��textsizer��saver��upper)r<r��outfiler
r�xrr
�
linenumber�yr�r�r�r�r��	text_sizes                r&�formatzImageFormatter.format9s���	
���{�+�+�+����!�!�!�
�Y��� � ��!3�T�^�D�D��!�
�
��
	
�"�"�2�&�&�&��~�b�!�!���=�	3����!7�7�$�:N�N�QR�R�A��)�)�+�+�E��G�A�J��N�E�"�m�
3�
3�
��$�$�Z�!�^�4�4������A���U��A��I�(>�?�$(�M��3�3�3�3�26�.�	;�	;�.�C���g�w��
m� �M�M�u�4�M�@�@�	�����A���A���A���1��0E�s�1�v�PY�Z[�P\�G\�]�dk��l�l�l��I�I�c�5�t�'�I�:�:�:�:�
�����*�0�0�2�2�3�3�3�3�3r%N)r)r r!r"r#rK�aliases�	filenames�
unicodeoutputr�r=r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrr$r%r&rr�sp������j�j�Z�D�#�#�#�G��	�I��M� ��6�6�6�pR�R�R�R�*�*�*�A�A�A����D�D�D�F�F�F�:�:�:�������C�C�C�B�B�B�
�
�
�C�C�C�& �& �& �P	,�	,�	,����"4�4�4�4�4r%rc�&�eZdZdZdZdgZdgZdZdS)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_gifr�z*.gifN�r r!r"r#rKrrr�r$r%r&rr^s5���������D��g�G��	�I� ���r%rc�(�eZdZdZdZddgZdgZdZdS)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_jpg�jpgr�z*.jpgNr r$r%r&r
r
ls7���������D��f�o�G��	�I�!���r%r
c�(�eZdZdZdZddgZdgZdZdS)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_bmpr��bitmapz*.bmpNr r$r%r&rrzs8���������D��h��G��	�I� ���r%r) r#rer3�pygments.formatterr�
pygments.utilrrrrrC�PILrr	r
r��ImportErrorrp�winreg�__all__rVr:r6r8r�	Exceptionr(r*rrr
rr$r%r&�<module>r.s�����
�	�	�	�
�
�
�
�(�(�(�(�(�(������������������/�/�/�/�/�/�/�/�/�/��M�M�������M�M�M�������N�N�N�N������� � � � � �������������������� � � ��G�F�F��h�'��(�!�=�1�	
�
��+��%����7�7�7�7�7�k�7�7�7�3�3�3�3�3�9�3�3�3�k(�k(�k(�k(�k(�k(�k(�k(�\m4�m4�m4�m4�m4�Y�m4�m4�m4�f!�!�!�!�!��!�!�!�"�"�"�"�"��"�"�"�!�!�!�!�!��!�!�!�!�!sA�/�9�9�A�A�A
�A�
A�A�A�A�A