Current File : //proc/self/root/lib/python3/dist-packages/pygments/lexers/__pycache__/__init__.cpython-312.pyc
�

|�eQ/����dZddlZddlZddlZddlZddlmZddlmZddl	m
Z
ddlmZddl
mZmZdd	d
d�Zgd�ee�zee�zZiZiZd
�Zd�Zdd�Zd�Zd�Zd�Zdd�Zdd�Zdd�Zd�Zdd�Zd�Z d�Z!Gd�dejD�Z#ejHe%Z&e#e%�Z'e'jPjSe&jP�e'ejHe%<e'`'e'`&e'`e'`y)z�
    pygments.lexers
    ~~~~~~~~~~~~~~~

    Pygments lexers.

    :copyright: Copyright 2006-2023 by the Pygments team, see AUTHORS.
    :license: BSD, see LICENSE for details.
�N)�basename)�LEXERS)�get_filetype_from_buffer)�find_plugin_lexers)�
ClassNotFound�guess_decode�PythonLexer�PythonTracebackLexer�
Lean3Lexer)�Python3Lexer�Python3TracebackLexer�	LeanLexer)�get_lexer_by_name�get_lexer_for_filename�find_lexer_class�guess_lexer�load_lexer_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/lexers/__init__.py�_fn_matchesr#sR���>�!�)+���G�4E�4E�d�4K�)L�L��.��&��}�}�R� � ��$��%�%�b�)�)�c��t|dddg�}|jD]!}t||�}|t|j<�#y)z0Load a lexer (and all others in the module too).N�__all__)�
__import__r"�getattr�_lexer_cache�name)�module_name�mod�
lexer_name�clss    r�_load_lexersr++sA��
�[�$��y�k�
:�C��k�k�%�
��c�:�&��!$��S�X�X��%r c#��K�tj�D]	}|dd���|r@t�D]2}|j|j|j
|jf���4yy�w)aReturn a generator of tuples in the form ``(name, aliases,
    filenames, mimetypes)`` of all know lexers.

    If *plugins* is true (the default), plugin lexers supplied by entrypoints
    are also returned.  Otherwise, only builtin ones are considered.
    �N)r�valuesrr&�aliases�	filenames�	mimetypes)�plugins�item�lexers   r�get_all_lexersr53sc�����
�
�����1�2�h����'�)�	N�E��*�*�e�m�m�U�_�_�e�o�o�M�M�	N��s�A$A&c���|tvr	t|Stj�D]#\}}}}}||k(s�t|�t|cSt	�D]}|j
|k(s�|cSy)zi
    Return the `Lexer` subclass that with the *name* attribute as given by
    the *name* argument.
    N)r%rr.r+rr&)r&r'�lnamer/�_r*s      rrrAsv��
�|���D�!�!�-3�]�]�_�&�)��U�G�Q���5�=���%���%�%�&�
"�#����8�8�t���J�r c�:�|std|z��tj�D]8\}}}}}|j�|vs�|tvrt|�t|cSt
�D]"}|j�|jvs� |cStd|z��)a$
    Return the `Lexer` subclass that has `alias` in its aliases list, without
    instantiating it.

    Like `get_lexer_by_name`, but does not instantiate the class.

    Will raise :exc:`pygments.util.ClassNotFound` if no lexer with that alias is
    found.

    .. versionadded:: 2.2
    �no lexer for alias %r found�rrr.�lowerr%r+rr/)�_aliasr'r&r/r8r*s      r�find_lexer_class_by_namer>Ss�����9�F�B�C�C�,2�M�M�O�&�(��T�7�A�q��<�<�>�W�$��<�'��[�)���%�%�	&�"�#����<�<�>�S�[�[�(��J���5��>�
?�?r c�P�|std|z��tj�D]=\}}}}}|j�|vs�|tvrt|�t	|di|��cSt
�D](}|j�|jvs� |di|��cStd|z��)z�
    Return an instance of a `Lexer` subclass that has `alias` in its
    aliases list. The lexer is given the `options` at its
    instantiation.

    Will raise :exc:`pygments.util.ClassNotFound` if no lexer with that alias is
    found.
    r:�r;)r=�optionsr'r&r/r8r*s       rrrns�����9�F�B�C�C�-3�M�M�O�1�(��T�7�A�q��<�<�>�W�$��<�'��[�)���%�0��0�0�	1�"�#�"���<�<�>�S�[�[�(��>��>�!�"��5��>�
?�?r c�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)	aLoad a lexer from a file.

    This method expects a file located relative to the current working
    directory, which contains a Lexer class. By default, it expects the
    Lexer to be name CustomLexer; you can specify your own class name
    as the second argument to this function.

    Users should be very careful with the input, because this method
    is equivalent to running eval on the input file.

    Raises ClassNotFound if there are any problems importing the Lexer.

    .. versionadded:: 2.2
    �rbNz	no valid z class found in zcannot read z: z#error when loading custom lexer: %sr@)�open�exec�readr�OSError�	Exception)�filename�	lexernamerA�custom_namespace�f�lexer_class�errs       rrr�s���I���
�(�D�
!�	-�Q������+�,�	-��,�,��!*�H�!6�7�
7�&�y�1���%�W�%�%�	-�	-���D��H�c�B�C�C����
��I��A�C�G�H�H��I�s9�A!�A�)A!�A�A!�!	B#�*A;�;B#�B�B#c����g}t|�}tj�D]I\}}}}}|D]<}t||�s�|tvrt|�|j
t||f��>�Kt�D]3}	|	jD]"}t||�s�|j
|	|f��$�5t�t�rt����fd�}
|r|j|
��|ddSy)z�Get a lexer for a filename.

    If multiple lexers match the filename pattern, use ``analyse_text()`` to
    figure out which one is more appropriate.

    Returns None if not found.
    c���|\}}d|vxrdxsd}�r |j��|z|jfS|j|z|jfS)N�*g�?r)�analyse_text�__name__�priority)�infor*rI�bonus�codes    �r�
get_ratingz1find_lexer_class_for_filename.<locals>.get_rating�s\����
��X��8�#�+��0�q��
��#�#�D�)�E�1�3�<�<�?�?��|�|�e�#�S�\�\�1�1r ��key���rN)
rrr.rr%r+�appendrr0�
isinstance�bytesr�sort)�_fnrW�matchesr�modnamer&r8r0rIr*rXs `         r�find_lexer_class_for_filenamerc�s�����G�	�#��B�*0�-�-�/�?�&���q�)�Q�!�	?�H��2�x�(��|�+� ��)�����T� 2�H�=�>�		?�?�"�#�0���
�
�	0�H��2�x�(�����X��/�	0�0�
�$����D�!��
2�������$��r�{�1�~��r c�J�t||�}|std|z��|di|��S)a�Get a lexer for a filename.

    Return a `Lexer` subclass instance that has a filename pattern
    matching `fn`. The lexer is given the `options` at its
    instantiation.

    Raise :exc:`pygments.util.ClassNotFound` if no lexer for that filename
    is found.

    If multiple lexers match the filename pattern, use their ``analyse_text()``
    methods to figure out which one is more appropriate.
    �no lexer for filename %r foundr@)rcr)r`rWrA�ress    rrr�s0��(��T�
2�C���<�s�B�C�C��>��>�r c��tj�D]/\}}}}}||vs�|tvrt|�t|di|��cSt	�D]}||j
vs�|di|��cSt
d|z��)z�
    Return a `Lexer` subclass instance that has `mime` in its mimetype
    list. The lexer is given the `options` at its instantiation.

    Will raise :exc:`pygments.util.ClassNotFound` if not lexer for that mimetype
    is found.
    zno lexer for mimetype %r foundr@)rr.r%r+rr1r)�_mimerArbr&r8r1r*s       r�get_lexer_for_mimetyperi�s���+1�-�-�/�1�&���q�!�Y��I���<�'��W�%���%�0��0�0�	1�
"�#�"���C�M�M�!��>��>�!�"��8�5�@�
A�Ar c#�K�tt�D]/}t|dd\}}|tvrt|�t|���1|rt	�Ed{���yy7��w)z*Return an iterator over all lexer classes.N�)�sortedrr%r+r)r2rZr'r&s    r�_iter_lexerclassesrm�sa�����f�~�!��"�3�K���O���T��|�#���%��4� � �	!�
�%�'�'�'��'�s�AA�A�Ac�J�
�t|�}i�
t�}t�D]j}|jD]%}t	||�s�|j|�d�
|<�'|jD]%}t	||�s�|j|�d�
|<�'�l|std|z��t|�dk(r|j�d	i|��Sg}|D]5}|j|�}|dk(r
|d	i|��cS|j||f��7�
fd�}	|j|	��|ddd	i|��S)
a

    As :func:`guess_lexer()`, but only lexers which have a pattern in `filenames`
    or `alias_filenames` that matches `filename` are taken into consideration.

    :exc:`pygments.util.ClassNotFound` is raised if no lexer thinks it can
    handle the content.
    TFrer-��?c�V��|d�|d|dj|djfS�Nrr-)rTrS)�t�primarys �r�	type_sortz+guess_lexer_for_filename.<locals>.type_sort%s0����!��g�a��d�m�Q�q�T�]�]�A�a�D�M�M�B�Br rYr[r@)
r�setrmr0r�add�alias_filenamesr�len�poprRr\r_)r`�_textrAr�matching_lexersr4rI�result�rvrtrss          @r�guess_lexer_for_filenamer~sK���
�#��B��G��e�O�#�%�'�����	&�H��2�x�(��#�#�E�*�!%����	&��-�-�	'�H��2�x�(��#�#�E�*�!&����	'�'���<�r�A�B�B�
�?��q� �$��"�"�$�/�w�/�/�
�F� �#��
�
�
��
&��
��9��#�7�#�#��
�
�r�5�k�"�	#�C��K�K�I�K���6�"�:�a�=�#�7�#�#r c���t|t�sG|jd|jd��}|r|j|xsd�}nt	|�\}}t|�}|�
	t
|fi|��Sddg}t�D]2}|j|�}|dk(r
|d
i|��cS||dkDs�,||f|dd�4|dr|d�td	��|dd
i|��S#t$rY�nwxYw)a�
    Return a `Lexer` subclass instance that's guessed from the text in
    `text`. For that, the :meth:`.analyse_text()` method of every known lexer
    class is called with the text as argument, and the lexer which returned the
    highest value will be instantiated and returned.

    :exc:`pygments.util.ClassNotFound` is raised if no lexer thinks it can
    handle the content.
    �
inencoding�encoding�utf8Ngrorr-z no lexer matching the text foundr@)
r]�str�get�decoderrrrrmrR)rzrAr�r8�ft�
best_lexerr4r}s        rrr1s���e�S�!��[�[��w�{�{�:�/F�G�
���L�L��!5�v�6�E�#�E�*�H�E�1�
"�%�	(�B�	�~�	�$�R�3�7�3�3��t��J�#�%�(��
�
�
��
&��
��9��#�7�#�#�
�
�1�
����K�J�q�M�(��a�=�J�q�M�1��>�?�?��:�a�=�#�7�#�#���	��	�s�&C�	C!� C!c��eZdZdZd�Zy)�_automodulezAutomatically import lexers.c���tj|�}|r)t|d�t|d}t	|||�|S|t
vrt
|t
|�St|��rq)rr�r+r%�setattr�COMPATr$�AttributeError)�selfr&rUr*s    r�__getattr__z_automodule.__getattr__[sa���z�z�$������a��!��t�A�w�'�C��D�$��$��J��6�>��4����.�.��T�"�"r N)rS�
__module__�__qualname__�__doc__r�r@r rr�r�Xs
��&�	#r r�)T)�CustomLexer)N)*r�r�sys�typesr�os.pathr�pygments.lexers._mappingr�pygments.modeliner�pygments.pluginr�
pygments.utilrrr��listr"r%rrr+r5rr>rrrcrrirmr~r�
ModuleTyper��modulesrS�oldmod�newmod�__dict__�updater@r r�<module>r�s���
�
����+�6�.�5�"�3��
��2�48��L�A�CG��<�P������*�%�N��$@�6@�2 I�F(�V�&B�&(�($�V$$�N#�%�"�"�#�

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