Your IP : 216.73.216.213


Current Path : /opt/alt/python37/lib/python3.7/site-packages/pygments/lexers/__pycache__/
Upload File :
Current File : //opt/alt/python37/lib/python3.7/site-packages/pygments/lexers/__pycache__/__init__.cpython-37.pyc

B

ǽ�\�+�@sJdZddlZddlZddlZddlZddlmZddlmZddl	m
Z
ddlmZddl
mZmZmZmZdd	d
ddgee�ZiZiZd
d�Zdd�Zdd�Zdd
�Zdd�Zdd�Zd&dd�Zd'dd�Zd(dd	�Zdd�Zd)dd �Z d!d"�Z!d#d�Z"Gd$d%�d%ej#�Z$ej%e&Z'e$e&�Z(e(j)�*e'j)�e(ej%e&<e(`(e(`'e(`e(`dS)*z�
    pygments.lexers
    ~~~~~~~~~~~~~~~

    Pygments lexers.

    :copyright: Copyright 2006-2019 by the Pygments team, see AUTHORS.
    :license: BSD, see LICENSE for details.
�N)�basename)�LEXERS)�get_filetype_from_buffer)�find_plugin_lexers)�
ClassNotFound�
itervalues�guess_decode�	text_type�get_lexer_by_name�get_lexer_for_filename�find_lexer_class�guess_lexer�load_lexer_from_filecCs8|tkr*t�t�|��}t|<|�|�St|�|�S)zBReturn whether the supplied file name fn matches pattern filename.)�_pattern_cache�re�compile�fnmatch�	translate�match)�fn�glob�pattern�r�I/opt/alt/python37/lib/python3.7/site-packages/pygments/lexers/__init__.py�_fn_matchess
rcCs8t|dddg�}x"|jD]}t||�}|t|j<qWdS)z0Load a lexer (and all others in the module too).N�__all__)�
__import__r�getattr�_lexer_cache�name)�module_name�modZ
lexer_name�clsrrr�_load_lexers's
r#ccsJxtt�D]}|dd�Vq
Wx$t�D]}|j|j|j|jfVq(WdS)zoReturn a generator of tuples in the form ``(name, aliases,
    filenames, mimetypes)`` of all know lexers.
    �N)rrrr�aliases�	filenames�	mimetypes)�item�lexerrrr�get_all_lexers/sr*cCsf|tkrt|Sx2tt�D]&\}}}}}||krt|�t|SqWxt�D]}|j|krL|SqLWdS)zALookup a lexer class by name.

    Return None if not found.
    N)rrrr#rr)rr �lnamer%�_r"rrrr9s
cCs�|std|��x>tt�D]2\}}}}}|��|kr|tkrDt|�t|SqWx t�D]}|��|jkrX|SqXWtd|��dS)z�Lookup a lexer class by alias.

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

    .. versionadded:: 2.2
    zno lexer for alias %r foundN)rrr�lowerrr#rr%)�_aliasr rr%r,r"rrr�find_lexer_class_by_nameKsr/cKs�|std|��xDtt�D]8\}}}}}|��|kr|tkrDt|�t|f|�SqWx&t�D]}|��|jkr^|f|�Sq^Wtd|��dS)zEGet a lexer by an alias.

    Raises ClassNotFound if not found.
    zno lexer for alias %r foundN)rrrr-rr#rr%)r.�optionsr rr%r,r"rrrr
as�CustomLexerc
Ks�yRi}t|d��}t|��|�WdQRX||krBtd||f��||}|f|�Stk
r�}ztd|��Wdd}~XYnPtk
r�}z�Wdd}~XYn.tk
r�}ztd|��Wdd}~XYnXdS)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
    �rbNzno valid %s class found in %szcannot read %sz#error when loading custom lexer: %s)�open�exec�readr�IOError�	Exception)�filenameZ	lexernamer0Zcustom_namespace�fZlexer_class�errrrrrvs
cs�g}t|�}xTtt�D]H\}}}}}x8|D]0}t||�r*|tkrHt|�|�t||f�q*WqWx6t�D],}	x&|	jD]}t||�rv|�|	|f�qvWqjWt	j
dkr�t�t�r�t
����fdd�}
|r�|j|
d�|ddSdS)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.
    )�cs@|\}}d|krdpd}�r0|���||jfS|j||jfS)N�*g�?r)�analyse_text�__name__�priority)�infor"r8Zbonus)�coderr�
get_rating�s
z1find_lexer_class_for_filename.<locals>.get_rating)�key���rN)rrrrrr#�appendrr&�sys�version_info�
isinstance�bytesr�sort)�_fnrA�matchesr�modnamerr,r&r8r"rBr)rAr�find_lexer_class_for_filename�s$


rNcKs$t||�}|std|��|f|�S)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.

    Raises ClassNotFound if not found.
    zno lexer for filename %r found)rNr)rKrAr0�resrrrr�s
cKsvx@tt�D]4\}}}}}||kr
|tkr0t|�t|f|�Sq
Wx"t�D]}||jkrJ|f|�SqJWtd|��dS)zHGet a lexer for a mimetype.

    Raises ClassNotFound if not found.
    zno lexer for mimetype %r foundN)rrrr#rr'r)Z_mimer0rMrr,r'r"rrr�get_lexer_for_mimetype�s
rPTccs^x>tt�D]2}t|dd�\}}|tkr2t|�t|Vq
W|rZxt�D]
}|VqLWdS)z*Return an iterator over all lexer classes.N�)�sortedrrr#r)ZpluginsrCr rr)rrr�_iter_lexerclasses�srSc
s
t|�}i�t�}xft�D]\}x*|jD] }t||�r&|�|�d�|<q&Wx*|jD] }t||�rR|�|�d�|<qRWqW|s�td|��t|�dkr�|�	�f|�Sg}x6|D].}|�
|�}|dkr�|f|�S|�||f�q�W�fdd�}	|j|	d�|d	df|�S)
a�
    Lookup all lexers that handle those filenames primary (``filenames``)
    or secondary (``alias_filenames``). Then run a text analysis for those
    lexers and choose the best result.

    usage::

        >>> from pygments.lexers import guess_lexer_for_filename
        >>> guess_lexer_for_filename('hello.html', '<%= @foo %>')
        <pygments.lexers.templates.RhtmlLexer object at 0xb7d2f32c>
        >>> guess_lexer_for_filename('hello.html', '<h1>{{ title|e }}</h1>')
        <pygments.lexers.templates.HtmlDjangoLexer object at 0xb7d2f2ac>
        >>> guess_lexer_for_filename('style.css', 'a { color: <?= $link ?> }')
        <pygments.lexers.templates.CssPhpLexer object at 0xb7ba518c>
    TFzno lexer for filename %r foundr$g�?cs$|d�|d|dj|djfS)Nrr$)r?r>)�t)�primaryrr�	type_sortsz+guess_lexer_for_filename.<locals>.type_sort)rCrD)
r�setrSr&r�addZalias_filenamesr�len�popr=rErJ)
rK�_textr0rZmatching_lexersr)r8�result�rvrVr)rUr�guess_lexer_for_filename�s2






r^cKs�t|t�s<|�d|�d��}|r0|�|p*d�}nt|�\}}t|�}|dk	rnyt|f|�Stk
rlYnXddg}xFt�D]<}|�	|�}|dkr�|f|�S||dkr~||f|dd�<q~W|dr�|ddkr�td	��|df|�S)
z?Guess a lexer by strong distinctions in the text (eg, shebang).�
inencoding�encoding�utf8Ngg�?rr$z no lexer matching the text found)
rHr	�get�decoderrr
rrSr=)r[r0r_r,ZftZ
best_lexerr)r]rrrr
!s*


c@seZdZdZdd�ZdS)�_automodulezAutomatically import lexers.cCsBt�|�}|r6t|d�t|d}t|||�|St|��dS)Nrr$)rrbr#r�setattr�AttributeError)�selfrr@r"rrr�__getattr__Cs
z_automodule.__getattr__N)r>�
__module__�__qualname__�__doc__rhrrrrrd@srd)r1)N)N)T)+rkrrF�typesr�os.pathrZpygments.lexers._mappingrZpygments.modelinerZpygments.pluginrZ
pygments.utilrrrr	�listrrrrr#r*rr/r
rrNrrPrSr^r
�
ModuleTyperd�modulesr>ZoldmodZnewmod�__dict__�updaterrrr�<module>
s@

#
+

3