Hacked By AnonymousFox

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

B

g[a�t�@sUdZddlZddlZddlmZddlmZddlm	Z	ddl
mZddl
mZdd	lmZejrxddlZdd
lmZed�Zejejdfed
<e�d�Ze�d�Ze�dej�Ze�dejej B�Z!e�dejej B�Z"e	d�Z#e	d�Z$e	d�Z%e	d�Z&e	d�Z'e	d�Z(e	d�Z)e	d�Z*e	d�Z+e	d�Z,e	d�Z-e	d�Z.e	d�Z/e	d �Z0e	d!�Z1e	d"�Z2e	d#�Z3e	d$�Z4e	d%�Z5e	d&�Z6e	d'�Z7e	d(�Z8e	d)�Z9e	d*�Z:e	d+�Z;e	d,�Z<e	d-�Z=e	d.�Z>e	d/�Z?e	d0�Z@e	d1�ZAe	d2�ZBe	d3�ZCe	d4�ZDe	d5�ZEe	d6�ZFe	d7�ZGe	d8�ZHe	d9�ZIe	d:�ZJe	d;�ZKe	d<�ZLe	d=�ZMe	d>�ZNe	d?�ZOe	d@�ZPe	dA�ZQe	dB�ZRe	dC�ZSe#e;e'e*e3e2e6e<e.e8e/e9e-e7e)e4e+e,e0e1e$e(e%e5e&e:dD�ZTdEdF�eT�U�D�ZVeWeT�eWeV�k�s�tXdG��e�dHdI�YdJdK�eZeTdLdM�dN�D���dO��Z[e\eIeKeJe=eNeOePg�Z]e\e=eQeKePg�Z^e_e_dP�dQdR�Z`dSe_dT�dUdV�Zae_e_dW�dXdY�Zbe_ecdZ�d[d\�Zdd]ejeeje_e_fd^�d_d`�ZfGdadb�db�ZgGdcdS�dSejh�ZiGddde�de�ZjGdfdg�dg�Zkd]dd^�dhdi�ZlGdjdk�dkem�ZnGdldm�dmejh�ZoGdnd�d�ZpdS)oz�Implements a Jinja / Python combination lexer. The ``Lexer`` class
is used to do some preprocessing. It filters out invalid operators like
the bitshift operators we don't allow in templates. It separates
template code and python code in expressions.
�N)�literal_eval)�deque)�intern�)�pattern)�TemplateSyntaxError)�LRUCache)�Environment�2�Lexer�_lexer_cachez\s+z(\r\n|\r|\n)z7('([^'\\]*(?:\\.[^'\\]*)*)'|"([^"\\]*(?:\\.[^"\\]*)*)")z�
    (
        0b(_?[0-1])+ # binary
    |
        0o(_?[0-7])+ # octal
    |
        0x(_?[\da-f])+ # hex
    |
        [1-9](_?\d)* # decimal
    |
        0(_?0)* # decimal zero
    )
    z�
    (?<!\.)  # doesn't start with a .
    (\d+_)*\d+  # digits, possibly _ separated
    (
        (\.(\d+_)*\d+)?  # optional fractional part
        e[+\-]?(\d+_)*\d+  # exponent part
    |
        \.(\d+_)*\d+  # required fractional part
    )
    �addZassign�colonZcommaZdiv�dot�eq�floordiv�gtZgteqZlbraceZlbracketZlparen�ltZlteq�mod�mul�ne�pipe�pow�rbraceZrbracketZrparenZ	semicolon�sub�tilde�
whitespace�float�integer�name�string�operatorZblock_beginZ	block_endZvariable_beginZvariable_endZ	raw_beginZraw_endZ
comment_beginZcomment_end�commentZlinestatement_beginZlinestatement_endZlinecomment_beginZlinecomment_endZlinecomment�data�initial�eof)�+�-�/z//�*�%z**�~�[�]�(�)�{�}z==z!=�>z>=�<z<=�=�.�:�|�,�;cCsi|]\}}||�qS�r:)�.0�k�vr:r:�=/opt/alt/python37/lib/python3.7/site-packages/jinja2/lexer.py�
<dictcomp>�sr?zoperators droppedr.r7ccs|]}t�|�VqdS)N)�re�escape)r;�xr:r:r>�	<genexpr>�srCcCs
t|�S)N)�len)rBr:r:r>�<lambda>��rE)�keyr/)�
token_type�returncCsL|tkrt|Stdtdtdtdtdtdtdtdt	dt
d	td
tdi�
||�S)Nzbegin of commentzend of commentr"zbegin of statement blockzend of statement blockzbegin of print statementzend of print statementzbegin of line statementzend of line statementztemplate data / textzend of template)�reverse_operators�TOKEN_COMMENT_BEGIN�TOKEN_COMMENT_END�
TOKEN_COMMENT�TOKEN_LINECOMMENT�TOKEN_BLOCK_BEGIN�TOKEN_BLOCK_END�TOKEN_VARIABLE_BEGIN�TOKEN_VARIABLE_END�TOKEN_LINESTATEMENT_BEGIN�TOKEN_LINESTATEMENT_END�
TOKEN_DATA�	TOKEN_EOF�get)rHr:r:r>�_describe_token_type�srX�Token)�tokenrIcCs|jtkr|jSt|j�S)z#Returns a description of the token.)�type�
TOKEN_NAME�valuerX)rZr:r:r>�describe_token�s
r^)�exprrIcCs2d|kr&|�dd�\}}|tkr*|Sn|}t|�S)z0Like `describe_token` but for token expressions.r6r)�splitr\rX)r_r[r]r:r:r>�describe_token_expr�sra)r]rIcCstt�|��S)zsCount the number of newline characters in the string.  This is
    useful for extensions that filter a stream.
    )rD�
newline_re�findall)r]r:r:r>�count_newlines�srdr	)�environmentrIcCs�tj}t|j�t||j�ft|j�t||j�ft|j�t||j�fg}|j	dk	rp|�
t|j	�td||j	�f�|jdk	r�|�
t|j�t
d||j�f�dd�t|dd�D�S)zACompiles all the rules from the environment into a list of rules.Nz	^[ \t\v]*z(?:^|(?<=\S))[^\S\r\n]*cSsg|]}|dd��qS)rNr:)r;rBr:r:r>�
<listcomp>�sz!compile_rules.<locals>.<listcomp>T)�reverse)r@rArD�comment_start_stringrK�block_start_stringrO�variable_start_stringrQ�line_statement_prefix�appendrS�line_comment_prefix�TOKEN_LINECOMMENT_BEGIN�sorted)re�e�rulesr:r:r>�
compile_rules�s*



rrc@s>eZdZdZefeejedd�dd�Ze	edd�dd	�Z
dS)
�FailurezjClass that raises a `TemplateSyntaxError` if called.
    Used by the `Lexer` to specify known errors.
    N)�message�clsrIcCs||_||_dS)N)rt�error_class)�selfrtrur:r:r>�__init__szFailure.__init__zte.NoReturn)�lineno�filenamerIcCs|�|j||��dS)N)rvrt)rwryrzr:r:r>�__call__szFailure.__call__)�__name__�
__module__�__qualname__�__doc__r�str�t�Typerx�intr{r:r:r:r>rs�srsc@sTeZdZUeed<eed<eed<ed�dd�Zeed�dd	�Zeed
�dd�Z	d
S)rYryr[r])rIcCst|�S)N)r^)rwr:r:r>�__str__sz
Token.__str__)r_rIcCs2|j|krdSd|kr.|�dd�|j|jgkSdS)z�Test a token against a token expression.  This can either be a
        token type or ``'token_type:token_value'``.  This can only test
        against string values and types.
        Tr6rF)r[r`r])rwr_r:r:r>�tests

z
Token.test)�iterablerIcst�fdd�|D��S)z(Test against multiple token expressions.c3s|]}��|�VqdS)N)r�)r;r_)rwr:r>rC$sz!Token.test_any.<locals>.<genexpr>)�any)rwr�r:)rwr>�test_any"szToken.test_anyN)
r|r}r~r��__annotations__r�r��boolr�r�r:r:r:r>rYs
c@s<eZdZdZddd�dd�Zdd�dd	�Zed�d
d�ZdS)�TokenStreamIteratorz`The iterator for tokenstreams.  Iterate over the stream
    until the eof token is reached.
    �TokenStreamN)�streamrIcCs
||_dS)N)r�)rwr�r:r:r>rx,szTokenStreamIterator.__init__)rIcCs|S)Nr:)rwr:r:r>�__iter__/szTokenStreamIterator.__iter__cCs.|jj}|jtkr |j��t�t|j�|S)N)r��currentr[rV�close�
StopIteration�next)rwrZr:r:r>�__next__2s


zTokenStreamIterator.__next__)r|r}r~rrxr�rYr�r:r:r:r>r�'sr�c@s�eZdZdZejeejeejed�dd�Z	e
d�dd�Zed�dd	�Z
eed�d
d��Zedd
�dd�Zed�dd�Zd!edd�dd�Zeejed�dd�Zeed�dd�Zed�dd�Zdd�dd�Zeed�dd �ZdS)"r�z�A token stream is an iterable that yields :class:`Token`\s.  The
    parser however does not iterate over it but calls :meth:`next` to go
    one token ahead.  The current active token is stored as :attr:`current`.
    )�	generatorrrzcCs>t|�|_t�|_||_||_d|_tdtd�|_	t
|�dS)NFr�)�iter�_iterr�_pushedrrz�closedrY�
TOKEN_INITIALr�r�)rwr�rrzr:r:r>rxCs
zTokenStream.__init__)rIcCst|�S)N)r�)rwr:r:r>r�QszTokenStream.__iter__cCst|j�p|jjtk	S)N)r�r�r�r[rV)rwr:r:r>�__bool__TszTokenStream.__bool__cCs|S)z Are we at the end of the stream?r:)rwr:r:r>�eosWszTokenStream.eosN)rZrIcCs|j�|�dS)z Push a token back to the stream.N)r�rl)rwrZr:r:r>�push\szTokenStream.pushcCs"t|�}|j}|�|�||_|S)zLook at the next token.)r�r�r�)rwZ	old_token�resultr:r:r>�look`s

zTokenStream.lookr)�nrIcCsxt|�D]}t|�q
WdS)zGot n tokens ahead.N)�ranger�)rwr��_r:r:r>�skiphszTokenStream.skip)r_rIcCs|j�|�rt|�SdS)zqPerform the token test and return the token if it matched.
        Otherwise the return value is `None`.
        N)r�r�r�)rwr_r:r:r>�next_ifmszTokenStream.next_ifcCs|�|�dk	S)z8Like :meth:`next_if` but only returns `True` or `False`.N)r�)rwr_r:r:r>�skip_ifvszTokenStream.skip_ifcCsX|j}|jr|j��|_n:|jjtk	rTyt|j�|_Wntk
rR|��YnX|S)z|Go one token ahead and return the old one.

        Use the built-in :func:`next` instead of calling this directly.
        )	r�r��popleftr[rVr�r�r�r�)rw�rvr:r:r>r�zszTokenStream.__next__cCs&t|jjtd�|_td�|_d|_dS)zClose the stream.r�r:TN)rYr�ryrVr�r�r�)rwr:r:r>r��s
zTokenStream.closecCsn|j�|�sft|�}|jjtkr>td|�d�|jj|j|j��td|�dt	|j���|jj|j|j��t
|�S)z}Expect a given token type and return it.  This accepts the same
        argument as :meth:`jinja2.lexer.Token.test`.
        z%unexpected end of template, expected r5zexpected token z, got )r�r�rar[rVrryrrzr^r�)rwr_r:r:r>�expect�s
zTokenStream.expect)r)r|r}r~rr��IterablerY�Optionalr�rxr�r�r�r��propertyr�r�r�r�r�r�r�r�r�r�r:r:r:r>r�=s 
	r�cCsZ|j|j|j|j|j|j|j|j|j|j	|j
|jf}t�
|�}|dkrVt|�t|<}|S)z(Return a lexer which is probably cached.N)ri�block_end_stringrj�variable_end_stringrh�comment_end_stringrkrm�trim_blocks�
lstrip_blocks�newline_sequence�keep_trailing_newlinerrWr)rerGZlexerr:r:r>�	get_lexer�s 
r�cs$eZdZdZdZ�fdd�Z�ZS)�OptionalLStripzWA special tuple for marking a point in the state that can have
    lstrip applied.
    r:cst��||�S)N)�super�__new__)ru�members�kwargs)�	__class__r:r>r��szOptionalLStrip.__new__)r|r}r~r�	__slots__r��
__classcell__r:r:)r�r>r��sr�c@sNeZdZUejeed<ejeejedfeje	fed<ej
eed<dS)�_Ruler.�tokens�commandN)r|r}r~r��Patternr�r��Union�Tuplersr�r:r:r:r>r��s
$r�c
@s�eZdZdZddd�dd�Zeed�dd	�Zdeejeejeejee	d
�dd�Z
dejeje
eefejeejeejed
�dd�Zdeejeejeejeejeje
eefd
�dd�ZdS)ra
Class that implements a lexer for a given environment. Automatically
    created by the environment class, usually you don't have to do that.

    Note that the lexer is not automatically bound to an environment.
    Multiple environments can share the same lexer.
    r	N)rerIc
Cs0tj}ttjtd�dd�}tttd�ttt	d�tt
td�ttt
d�tttd�tttd�g}t|�}||j�}||j�}||j�}||j�}	|jr�dnd}
|jr�|d�nd|_|j|_|j|_d|�d|�d	|�d
�}d�|gdd
�|D��}dt|d|�d��ttd�d�t|d�td�gtt|d|�d|�d	|�|
�d
��t t!fd�t|d�t"d�fd�gt#t|d|�d|�d	|�|
�d��t$d�g|t%t|d|	�d	|	���t&d�g|t't|d|�d|�d|�d	|�|
�d
�
�ttt(�d�t|d�t"d�fd�gt)t|d�t*d�g|t+t|d�t,t-fd�gi|_.dS)N)rBrIcSst�|tjtjB�S)N)r@�compile�M�S)rBr:r:r>�c�szLexer.__init__.<locals>.cz\n?r�z[^ \t]z(?P<raw_begin>z(\-|\+|)\s*raw\s*(?:\-z\s*|z))r7cSs"g|]\}}d|�d|�d��qS)z(?P<r2z	(\-|\+|))r:)r;r��rr:r:r>rf
sz"Lexer.__init__.<locals>.<listcomp>�rootz(.*?)(?:r/z#bygroupz.+z(.*?)((?:\+z|\-z#popz(.)zMissing end of comment tagz(?:\+z\-z	(.*?)((?:z(\-|\+|))\s*endraw\s*(?:\+zMissing end of raw directivez	\s*(\n|$)z(.*?)()(?=\n|$))/r@rAr�r�r�r��
whitespace_re�TOKEN_WHITESPACE�float_re�TOKEN_FLOAT�
integer_re�
TOKEN_INTEGER�name_rer\�	string_re�TOKEN_STRING�operator_re�TOKEN_OPERATORrrrir�r�r�r�r��lstrip_unless_rer�r��joinr�rUrKrMrLrsrOrPrQrR�TOKEN_RAW_BEGIN�
TOKEN_RAW_ENDrSrTrnrN�TOKEN_LINECOMMENT_ENDrq)
rwrerpr�Z	tag_rulesZroot_tag_rulesZblock_start_reZblock_end_reZcomment_end_reZvariable_end_reZblock_suffix_reZroot_raw_reZ
root_parts_rer:r:r>rx�sz




	



"zLexer.__init__)r]rIcCst�|j|�S)z`Replace all newlines with the configured sequence in strings
        and template data.
        )rbrr�)rwr]r:r:r>�_normalize_newlinesVszLexer._normalize_newlines)�sourcerrz�staterIcCs&|�||||�}t|�|||�||�S)z:Calls tokeniter + tokenize and wraps it in a token stream.)�	tokeniterr��wrap)rwr�rrzr�r�r:r:r>�tokenize\szLexer.tokenize)r�rrzrIc
csx�xp|D�]f\}}}|tkrq|}|tkr2t}�n0|tkrBt}�n |ttfkrTq�n|tkrh|�|�}n�|dkrv|}n�|t	kr�|}|�
�s�td|||��n�|tk�ry$|�|dd���
dd��d�}WnJtk
�r}z*t|��d�d��}	t|	|||�|�Wd	d	}~XYnXnL|tk�r4t|�d
d�d�}n.|tk�rPt|�d
d��}n|tk�rbt|}t|||�VqWd	S)
z�This is called with the stream as returned by `tokenize` and wraps
        every token in a :class:`Token` and converts the value.
        �keywordzInvalid character in identifierr����ascii�backslashreplacezunicode-escaper6Nr�r�r)�ignored_tokensrSrOrTrPr�r�rUr�r\�isidentifierrr��encode�decode�	Exceptionr�r`�stripr�r��replacer�rr��	operatorsrY)
rwr�rrzryrZZ	value_strr]rp�msgr:r:r>r�gsD	

$


z
Lexer.wrapccsVt�|�ddd�}|js,|ddkr,|d=d�|�}d}d}dg}|dk	rr|dkrr|d	ksdtd
��|�|d�|j|d}	t|�}
g}|j}d}
d}�x��x�|	D�]v\}}}|�	||�}|dkr�q�|r�|t
ttfkr�q�t
|t��r�|��}t
|t��r�|d}td
d�|ddd�D��}|dk�r\|��}|t|�d��d�}
|f|dd��}nj|dk�r�|dk	�r�|���t��s�|�d�d}|dk�s�|�r�|�||��s�|d|�f|dd��}x�t|�D]�\}}|jtk�r�|||��n�|dk�rLx�|����D]0\}}|dk	�r|||fV||�d�7}P�qWt|�d���n:||}|�sd|tk�rp|||fV||�d�|
7}d}
�q�Wn�|��}|t k�r6|dk�r�|�d�n�|dk�r�|�d�nj|dk�r�|�d�nT|dk�r6|�st!d|�d�|||��|�"�}||k�r6t!d|�d|�d�|||��|�sF|tk�rR|||fV||�d�7}|��dd�dk}|�#�}|dk	�r|dk�r�|�"�nV|dk�r�xJ|����D] \}}|dk	�r�|�|�P�q�Wt|�d���n
|�|�|j|d}	n||k�rt|�d���|}Pq�W||
k�r0dSt!d ||�d!|��|||��q�WdS)"aThis method tokenizes the text and returns the tokens in a
        generator. Use this method if you just want to tokenize a template.

        .. versionchanged:: 3.0
            Only ``\n``, ``\r\n`` and ``\r`` are treated as line
            breaks.
        N�r�r��
rrr�)�variable�blockz
invalid stateZ_beginTcss|]}|dk	r|VqdS)Nr:)r;�gr:r:r>rC�sz"Lexer.tokeniter.<locals>.<genexpr>r'r&z#bygroupz= wanted to resolve the token dynamically but no group matchedr0r1r.r/r,r-)r1r/r-zunexpected '�'z
', expected 'z#popzA wanted to resolve the new state dynamically but no group matchedz* yielded empty string without stack changezunexpected char z at )$rbr`r�r��AssertionErrorrlrqrDr��matchrRrPrT�
isinstance�tuple�groupsr�r��rstrip�count�	groupdictrWrQ�rfind�search�	enumerater�rs�items�RuntimeError�ignore_if_empty�groupr�r�pop�end)rwr�rrzr��lines�posry�stackZstatetokensZ
source_lengthZbalancing_stackr�Znewlines_strippedZ
line_startingZregexr�Z	new_state�mr��textZ
strip_sign�strippedZl_pos�idxrZrGr]r#Zexpected_op�pos2r:r:r>r��s�




















zLexer.tokeniter)NNN)NN)NN)r|r}r~rrxr�r�r�r�r�r�r�r�r��IteratorrYr�r�r:r:r:r>r�sy	&5)qrr@�typingr��astr�collectionsr�sysrZ_identifierrr��
exceptionsr�utilsr�
TYPE_CHECKINGZtyping_extensions�terer	r�MutableMappingr�r�r�r�rbr�r��
IGNORECASE�VERBOSEr�r�Z	TOKEN_ADDZTOKEN_ASSIGNZTOKEN_COLONZTOKEN_COMMAZ	TOKEN_DIVZ	TOKEN_DOTZTOKEN_EQZTOKEN_FLOORDIVZTOKEN_GTZ
TOKEN_GTEQZTOKEN_LBRACEZTOKEN_LBRACKETZTOKEN_LPARENZTOKEN_LTZ
TOKEN_LTEQZ	TOKEN_MODZ	TOKEN_MULZTOKEN_NEZ
TOKEN_PIPEZ	TOKEN_POWZTOKEN_RBRACEZTOKEN_RBRACKETZTOKEN_RPARENZTOKEN_SEMICOLONZ	TOKEN_SUBZTOKEN_TILDEr�r�r�r\r�r�rOrPrQrRr�r�rKrLrMrSrTrnr�rNrUr�rVr�r�rJrDr�r�ror��	frozensetr�r�r�rXr^rar�rd�Listrrrs�
NamedTuplerYr�r�r�r�r�r�rr:r:r:r>�<module>s�




*
 )m


Hacked By AnonymousFox1.0, Coded By AnonymousFox