HEX
Server: LiteSpeed
System: Linux standart9.isimtescil.net 3.10.0-962.3.2.lve1.5.26.7.el7.x86_64 #1 SMP Wed Oct 2 07:53:12 EDT 2019 x86_64
User: karalev (5310)
PHP: 8.2.29
Disabled: NONE
Upload Files
File: //proc/self/root/opt/alt/python37/lib/python3.7/site-packages/mako/__pycache__/lexer.cpython-37.pyc
B

�C]B�@s\dZddlZddlZddlmZddlmZddlmZddlmZiZ	Gdd�de
�ZdS)	zGprovides the Lexer class for parsing template strings into parse trees.�N)�compat)�
exceptions)�	parsetree)�adjust_whitespacec@s�eZdZd$dd�Zedd��Zd%dd�Zd	d
�Zdd�Zd
d�Z	e
�d�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�ZdS)&�LexerNFcCs�||_||_t�|j�|_d|_d|_d|_d|_g|_	g|_
g|_||_||_
tjrd|rdt�d��|dkrtg|_nt|d�s�|g|_n||_dS)N�rz4Mako for Python 3 does not support disabling Unicode�__iter__)�text�filenamerZTemplateNode�template�matched_lineno�matched_charpos�lineno�match_position�tag�control_line�
ternary_stack�disable_unicode�encodingrZpy3krZUnsupportedError�preprocessor�hasattr)�selfr	r
rZinput_encodingr�r�;/opt/alt/python37/lib/python3.7/site-packages/mako/lexer.py�__init__s(


zLexer.__init__cCs|j|j|j|jd�S)N)�sourcer�posr
)r	rr
r
)rrrr�exception_kwargs6szLexer.exception_kwargscCsXyt||f}Wn<tk
rL|r2t�||�}n
t�|�}|t||f<YnX|�|�S)z>compile the given regexp, cache the reg, and call match_reg().)�
_regexp_cache�KeyError�re�compile�	match_reg)rZregexp�flags�regrrr�match?s
zLexer.matchcCs�|j}|�|j|j�}|r�|��\}}||kr:|d|_n||_|j|_t�d|j||j��}|d}x,|dkr�||jkr�|j|dkr�|d8}qjW|||_	|jt
|�7_|S)z�match the given regular expression object to the current text
        position.

        if a match occurs, update the current text and line position.

        rz\nr�
)rr%r	�spanrrr �findall�
textlengthr
�len)rr$Zmpr%�start�end�linesZcprrrr"Ms"
zLexer.match_regc	GsR|j}d�|�}d}d}d}�x.|�d�}|r0q |�dtj�}|rDq |�d|�}|r�|rr|dks�|dks�|dks�|j||jt|�d���|�d�fS|s�|�d|tj�}|�r0||�d��d�7}||�d��d	�8}||�d��d
�7}||�d��d�8}||�d��d�7}||�d��d
�8}q t	j
dd�|�f|j��q WdS)N�|rz#.*\nz+(\"\"\"|\'\'\'|\"|\')[^\\]*?(\\.[^\\]*?)*\1z(%s)rz(.*?)(?=\"|\'|#|%s)�{�}�(�)�[�]zExpected: %s�,)r�joinr%r �Sr	r*�group�countr�SyntaxExceptionr)	rZ
watch_nestingr	�startposZtext_reZbrace_levelZparen_levelZ
bracket_levelr%rrr�parse_until_textks@


zLexer.parse_until_textcOs�|�d|j�|�d|j�|�d|j�|j|d<|||�}t|j�r\|jdj�|�n|j	j�|�|j
r�|j
d}|j�|�t|tj
�r�|�|j�s�|jr�|jdr�|jddj�|�t|tj�r�t|j�r�|jd|_|j�|�n�t|tj
��r�|j�r |j
��|j��n�|j�rB|j
�|�|j�g�nl|j
�rp|j
d�|j��rp|jd�|�n>|j
�r�|j
d�|j��s�tjd|j|j
djff|j��dS)Nrrrr
���z1Keyword '%s' not a legal ternary for keyword '%s')�
setdefaultr	rr
r
r*rZnodes�appendrr�
isinstancer�ControlLineZ
is_ternary�keywordr�Tag�parent�isend�popZ
is_primaryrr:r)rZnodecls�args�kwargsZnodeZ
control_framerrr�append_node�sF







zLexer.append_nodez #.*coding[:=]\s*([-\w.]+).*\r?\nc
Cs&t|tj�r6|j�|�}|r&|�d�p,|p,d}||fS|�tj�r�|t	tj�d�}d}|j�|�
dd��}|dk	r�|�d�dkr�t�d|�d�|�
dd�dd|��n,|j�|�
dd��}|r�|�d�}n|p�d}|�ry|�
|�}Wn4t
k
�rt�d||�
dd�dd|��YnX||fS)	z�given string/unicode or bytes/string, determine encoding
           from magic encoding comment, return body as unicode
           or raw if decode_raw=False

        r�asciiNzutf-8�ignorezHFound utf-8 BOM in file, with conflicting magic encoding comment of '%s'rz0Unicode decode operation of encoding '%s' failed)r@rZ	text_type�
_coding_rer%r8�
startswith�codecs�BOM_UTF8r*�decoder�CompileException�UnicodeDecodeError)rr	Z
decode_rawZknown_encodingr
�mrZparsed_encodingrrr�decode_raw_stream�s@


zLexer.decode_raw_streamcCs<|�|j|j|j|j�\|_|_x|jD]}||j�|_q*W|�|j�t|j�|_	xz|j
|j	krfP|��rpP|��rzqX|�
�r�qX|��r�qX|��r�qX|��r�qX|��r�qX|��r�qX|j
|j	kr�Pt�d��qXWt|j�r�tjd|jdjf|j��t|j��r6t�d|jdj|j|jdj|jdj|j��|jS)Nzassertion failedzUnclosed tag: <%%%s>r=z"Unterminated control keyword: '%s')rTr	rrr
rr"rLr*r)r�	match_end�match_expression�match_control_line�
match_comment�match_tag_start�
match_tag_end�match_python_block�
match_textrrQrr:rBrrrrr)rZpreprocrrr�parse�sR


zLexer.parsecCs�|�dtjtjBtjB�}|r�|��\}}}||_i}|rvx:t�d|�D]*}|\}}}	|p\|	}
|
�dd�}
|
||<qHW|�	t
j||�|r�|j�
�nR|dkr�|�dtj�}|s�tjd|jdjf|j��|�	t
j|�d	��|��Sd
SdSdS)Na+
            \<%     # opening tag

            ([\w\.\:]+)   # keyword

            ((?:\s+\w+|\s*=\s*|".*?"|'.*?')*)  # attrname, = \
                                               #        sign, string expression

            \s*     # more whitespace

            (/)?>   # closing

            z)\s*(\w+)\s*=\s*(?:'([^']*)'|\"([^\"]*)\")z
r&r	z(.*?)(?=\</%text>)zUnclosed tag: <%%%s>r=rTF)r%r �Ir7�X�groupsrBr(�replacerIrrCrrFrr:r�Textr8rZ)rr%rB�attrrEZ
attributesZatt�keyZval1Zval2r	rrrrY)s6

zLexer.match_tag_startcCs�|�d�}|r~t|j�s4tjd|�d�f|j��n<|jdj|�d�krptjd|�d�|jdjff|j��|j��dSdSdS)Nz\</%[\t ]*(.+?)[\t ]*>z(Closing tag without opening tag: </%%%s>rr=z.Closing tag </%%%s> does not match tag: <%%%s>TF)	r%r*rrr:r8rrBrF)rr%rrrrZXs



zLexer.match_tag_endcCs0|�dtj�}|r(|��}|r"|SdSndSdS)Nz\ZTF)r%r r7r8)rr%�stringrrrrUlszLexer.match_endcCs@|�dtjtjB�}|r8|�d�}|r4|�tj|�dSdSdS)Na�
                (.*?)         # anything, followed by:
                (
                 (?<=\n)(?=[ \t]*(?=%|\#\#)) # an eval or line-based
                                             # comment preceded by a
                                             # consumed newline and whitespace
                 |
                 (?=\${)      # an expression
                 |
                 (?=</?[%&])  # a substitution or block or call start or end
                              # - don't consume
                 |
                 (\\\r?\n)    # an escaped newline  - throw away
                 |
                 \Z           # end of string
                )rTF)r%r r_r7r8rIrrb)rr%r	rrrr\ws
zLexer.match_textcCsd|�d�}|r\|j|j}}|�dd�\}}t|�d}|jtj||�d�dk||d�dSdSdS)	Nz<%(!)?Fz%>r&r�!)rrT)	r%rr
r<rrIrZCoder8)rr%�linerr	r,rrrr[�s
zLexer.match_python_blockcCs~|�d�}|rv|j|j}}|�ddd�\}}|dkrH|�dd�\}}nd}|�dd�}|jtj||��||d	�dSd
SdS)Nz\${Tz\|r0r.�z
r&)rrF)	r%rr
r<rarIrZ
Expression�strip)rr%rgrr	r,ZescapesrrrrV�s 
zLexer.match_expressioncCs�|�dtj�}|r�|�d�}|�d�}|dkr�t�d|�}|sRtjd|f|j��|�dd�\}}|dk	}|r�t|j�s�tjd||ff|j��n0|jdj	|kr�tjd	||jdj	ff|j��|�
tj|||�n|�
tj
|�d
SdSdS)NzB(?<=^)[\t ]*(%(?!%)|##)[\t ]*((?:(?:\\r?\n)|[^\r\n])*)(?:\r?\n|\Z)r��%z(end)?(\w+)\s*(.*)zInvalid control line: '%s'z!No starting keyword '%s' for '%s'r=z'Keyword '%s' doesn't match keyword '%s'TF)r%r �Mr8rr:rr*rrBrIrrA�Comment)rr%�operatorr	Zm2rErBrrrrW�s:




zLexer.match_control_linecCs2|�dtj�}|r*|�tj|�d��dSdSdS)z*matches the multiline version of a commentz<%doc>(.*?)</%doc>rTFN)r%r r7rIrrmr8)rr%rrrrX�s
zLexer.match_comment)NFNN)N)�__name__�
__module__�__qualname__r�propertyrr%r"r<rIr r!rLrTr]rYrZrUr\r[rVrWrXrrrrrs(
	
(/
.7/'r)�__doc__rNr ZmakorrrZ
mako.pygenrr�objectrrrrr�<module>s