Current File : //usr/lib/python3/dist-packages/pygments/formatters/__pycache__/__init__.cpython-312.pyc
�

|�e��v�dZddlZddlZddlZddlZddlmZddlmZddl	m
Z
ddlmZgd�e
e�zZiZiZd�Zd	�Zd
�Zd�Zd�Zdd
�Zd�ZGd�dej0�Zej4eZee�Zej<j?ej<�eej4e<e`e`e`e`y)z�
    pygments.formatters
    ~~~~~~~~~~~~~~~~~~~

    Pygments formatters.

    :copyright: Copyright 2006-2023 by the Pygments team, see AUTHORS.
    :license: BSD, see LICENSE for details.
�N)�basename)�
FORMATTERS)�find_plugin_formatters)�
ClassNotFound)�get_formatter_by_name�get_formatter_for_filename�get_all_formatters�load_formatter_from_filec���|tvrBtjtj|��x}t|<|j|�St|j|�S)zBReturn whether the supplied file name fn matches pattern filename.)�_pattern_cache�re�compile�fnmatch�	translate�match)�fn�glob�patterns   �>/usr/lib/python3/dist-packages/pygments/formatters/__init__.py�_fn_matchesrsR���>�!�)+���G�4E�4E�d�4K�)L�L��.��&��}�}�R� � ��$��%�%�b�)�)�c��t|dddg�}|jD]!}t||�}|t|j<�#y)z4Load a formatter (and all others in the module too).N�__all__)�
__import__r�getattr�_formatter_cache�name)�module_name�mod�formatter_name�clss    r�_load_formattersr"$sB��
�[�$��y�k�
:�C��+�+�)���c�>�*��%(�����"�)rc#�K�tj�D])}|dtvrt|d�t|d���+t	�D]	\}}|���y�w)z-Return a generator for all formatter classes.�rN)r�valuesrr"r)�info�_�	formatters   rr	r	,se�����!�!�#�(����7�*�*��T�!�W�%��t�A�w�'�'�(�/�0����9����s�AAc���tj�D]*\}}}}}||vs�|tvrt|�t|cSt	�D]\}}||j
vs�|cSy)zALookup a formatter by alias.

    Returns None if not found.
    N)rr%rr"r�aliases)�aliasrrr*r'r!s      r�find_formatter_classr,7st��
-7�,=�,=�,?�*�(��T�7�A�q��G���+�+� ��-�#�D�)�)�	*�
)�*����3��C�K�K���J�rc�H�t|�}|�td|z��|di|��S)a
    Return an instance of a :class:`.Formatter` subclass that has `alias` in its
    aliases list. The formatter is given the `options` at its instantiation.

    Will raise :exc:`pygments.util.ClassNotFound` if no formatter with that
    alias is found.
    zno formatter found for name %r�)r,r)�_alias�optionsr!s   rrrFs0���v�
&�C�
�{��<�v�E�F�F��>��>�rc�L�	i}t|d�5}t|j�|�ddd�||vrtd|�d|����||}|di|��S#1swY�+xYw#t$r}td|�d|����d}~wt$r�t
$r}td|z��d}~wwxYw)	a#
    Return a `Formatter` subclass instance loaded from the provided file, relative
    to the current directory.

    The file is expected to contain a Formatter class named ``formattername``
    (by default, CustomFormatter). Users should be very careful with the input, because
    this method is equivalent to running ``eval()`` on the input file. The formatter is
    given the `options` at its instantiation.

    :exc:`pygments.util.ClassNotFound` is raised if there are any errors loading
    the formatter.

    .. versionadded:: 2.2
    �rbNz	no valid z class found in zcannot read z: z'error when loading custom formatter: %sr.)�open�exec�readr�OSError�	Exception)�filename�
formatternamer0�custom_namespace�f�formatter_class�errs       rr
r
Ts���M���
�(�D�
!�	-�Q������+�,�	-�� 0�0��!.��!:�;�
;�*�=�9���)��)�)�	-�	-���D��H�c�B�C�C����
��M��E��K�L�L��M�s9�A!�A�)A!�A�A!�!	B#�*A;�;B#�B�B#c�X�t|�}tj�D]@\}}}}}|D]3}t||�s�|tvrt|�t	|di|��ccS�Bt
�D].\}}|jD]}t||�s�|di|��ccS�0td|z��)a
    Return a :class:`.Formatter` subclass instance that has a filename pattern
    matching `fn`. The formatter is given the `options` at its instantiation.

    Will raise :exc:`pygments.util.ClassNotFound` if no formatter for that filename
    is found.
    z#no formatter found for file name %rr.)	rrr%rrr"r�	filenamesr)	rr0�modnamerr'r?r8�_namer!s	         rrrws���
�"��B�*4�*;�*;�*=�9�&���q�)�Q�!�	9�H��2�x�(��/�/�$�W�-�'��-�8��8�8�		9�9�-�.�&�
��s��
�
�	&�H��2�x�(��~�W�~�%�	&�&��=��B�
C�Crc��eZdZdZd�Zy)�_automodulez Automatically import formatters.c��tj|�}|r)t|d�t|d}t	|||�|St|��)Nrr$)r�getr"r�setattr�AttributeError)�selfrr&r!s    r�__getattr__z_automodule.__getattr__�sI���~�~�d�#����T�!�W�%�"�4��7�+�C��D�$��$��J��T�"�"rN)�__name__�
__module__�__qualname__�__doc__rIr.rrrCrC�s
��*�#rrC)�CustomFormatter) rMr
�sys�typesr�os.pathr�pygments.formatters._mappingr�pygments.pluginr�
pygments.utilr�listrrrrr"r	r,rr
r�
ModuleTyperC�modulesrJ�oldmod�newmod�__dict__�updater.rr�<module>r\s����
�
����3�2�'�=�?C�J�?O�P������*�)���� M�FD�,
#�%�"�"�
#�

���X�	��	�X�	�������v���'�����H��
�M�6�=�&�*�f�lr