Server : LiteSpeed
System : Linux server51.dnsbootclub.com 4.18.0-553.62.1.lve.el8.x86_64 #1 SMP Mon Jul 21 17:50:35 UTC 2025 x86_64
User : nandedex ( 1060)
PHP Version : 8.1.33
Disable Function : NONE
Directory :  /opt/cppython/lib/python3.8/site-packages/mako/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]


Current File : //opt/cppython/lib/python3.8/site-packages/mako/__pycache__/lexer.cpython-38.pyc
U

O��g�?�@sNdZddlZddlZddlmZddlmZddlmZiZGdd�d�Z	dS)zGprovides the Lexer class for parsing template strings into parse trees.�N)�
exceptions)�	parsetree)�adjust_whitespacec@s�eZdZd%dd�Zedd��Zd&dd�Zdd	�Zd
d�Zdd
�Z	e
�d�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�ZdS)'�LexerNcCsx||_||_t�|j�|_d|_d|_d|_d|_g|_	g|_
g|_||_|dkrZg|_
nt|d�sn|g|_
n||_
dS)N�r�__iter__)�text�filenamerZTemplateNode�template�matched_lineno�matched_charpos�lineno�match_position�tag�control_line�
ternary_stack�encoding�preprocessor�hasattr)�selfrr	Zinput_encodingr�r�7/opt/cppython/lib/python3.8/site-packages/mako/lexer.py�__init__s 

zLexer.__init__cCs|j|j|j|jd�S)N)�sourcer
�posr	)rrrr	)rrrr�exception_kwargs*s
�zLexer.exception_kwargscCsVzt||f}Wn:tk
rJ|r0t�||�nt�|�}|t||f<YnX|�|�S)z>compile the given regexp, cache the reg, and call match_reg().)�
_regexp_cache�KeyError�re�compile�	match_reg)r�regexp�flags�regrrr�match3szLexer.matchcCs�|j}|�|j|j�}|r�|��\}}||kr6|dn||_|j|_|d}|dkrv||jkrv|jd|d��d�}|||_|j|j||j��	d�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.

        rrN�
)
rr$r�spanr
r�
textlength�rfindr�count)rr#�mpr$�start�end�cprrrr >s
 zLexer.match_regc	GsL|j}d�|�}d}d}d}|�d�}|r,q|�dtj�}|r@q|�d|�}|r�|rn|dks�|dks�|dks�|j||jt|�d���|�d�fS|s�|�d|tj�}|�r,||�d��d�7}||�d��d	�8}||�d��d
�7}||�d��d�8}||�d��d�7}||�d��d
�8}qt	j
dd�|�f|j��qdS)N�|rz#.*\nz+(\"\"\"|\'\'\'|\"|\')[^\\]*?(\\.[^\\]*?)*\1z(%s)rz(.*?)(?=\"|\'|#|%s)�{�}�(�)�[�]zExpected: %s�,)r�joinr$r�Sr�len�groupr)r�SyntaxExceptionr)	rZ
watch_nestingr�startposZtext_reZbrace_levelZparen_levelZ
bracket_levelr$rrr�parse_until_textTsZ

���������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)Nrr
rr	���z1Keyword '%s' not a legal ternary for keyword '%s')�
setdefaultrrrr	r8rZnodes�appendr
r�
isinstancer�ControlLineZ
is_ternary�keywordr�Tag�parent�isend�popZ
is_primaryrr:r)rZnodecls�args�kwargs�nodeZ
control_framerrr�append_node|sZ




�
���

�����zLexer.append_nodez #.*coding[:=]\s*([-\w.]+).*\r?\nc
Cs"t|t�r4|j�|�}|r$|�d�p*|p*d}||fS|�tj�r�|ttj�d�}d}|j�|�	dd��}|dk	r�|�d�dkr�t
�d|�d�|�	dd�dd|��n*|j�|�	dd��}|r�|�d�n|p�d}|�rz|�	|�}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

        rzutf-8N�ignorezHFound utf-8 BOM in file, with conflicting magic encoding comment of '%s'rz0Unicode decode operation of encoding '%s' failed)
r@�str�
_coding_rer$r9�
startswith�codecs�BOM_UTF8r8�decoderZCompileException�UnicodeDecodeError)rrZ
decode_rawZknown_encodingr	�mrZparsed_encodingrrr�decode_raw_stream�sD
�
�	�
�
	zLexer.decode_raw_streamcCs:|�|jd|j|j�\|_|_|jD]}||j�|_q$|�|j�t|j�|_|j	|jkr\q�|�
�rfq�|��rpqN|��rzqN|�
�r�qN|��r�qN|��r�qN|��r�qN|��r�qN|��r�qN|j	|jkr�q�t�d��qNt|j�r�tjd|jdjf|j��t|j��r4t�d|jdj|j|jdj|jdj|j��|jS)NTzassertion failed�Unclosed tag: <%%%s>r=z"Unterminated control keyword: '%s')rTrrr	rr rMr8r'r�	match_end�match_expression�match_control_line�
match_comment�match_tag_start�
match_tag_end�match_python_block�
match_percent�
match_textrZ
MakoExceptionrr:rBrrr
rr
)rZpreprocrrr�parse�sd�

��
�

�zLexer.parsecCs�d}|�|tjtjBtjB�}|s&dS|��\}}}||_i}|rzt�d|�D]*}|\}}	}
|	pb|
}|�dd�}|||<qN|�	t
j||�|r�|j�
�nR|dkr�|�dtj�}|s�tjd|jd	jf|j��|�	t
j|�d
��|��SdS)Na�
            \<%     # opening tag

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

            ((?:\s+\w+|\s*=\s*|"[^"]*?"|'[^']*?'|\s*,\s*)*)  # attrname, = \
                                               #        sign, string expression
                                               # comma is for backwards compat
                                               # identified in #366

            \s*     # more whitespace

            (/)?>   # closing

        Fz)\s*(\w+)\s*=\s*(?:'([^']*)'|\"([^\"]*)\")�
r%rz(.*?)(?=\</%text>)rUr=rT)r$r�Ir7�X�groupsrB�findall�replacerJrrCrrFrr:r�Textr9r[)rr#r$rB�attrrE�
attributesZatt�keyZval1Zval2rrrrrZsB��

��zLexer.match_tag_startcCs�|�d�}|r~t|j�s4tjd|�d�f|j��n<|jdj|�d�krptjd|�d�|jdjff|j��|j��dSdSdS)Nz\</%[\t ]*([^\t ]+?)[\t ]*>z(Closing tag without opening tag: </%%%s>rr=z.Closing tag </%%%s> does not match tag: <%%%s>TF)	r$r8rrr:r9rrBrF�rr$rrrr[Fs*

������
zLexer.match_tag_endcCs.|�dtj�}|sdS|��}|r&|SdSdS)Nz\ZFT)r$rr7r9)rr$�stringrrrrVZszLexer.match_endcCs@|�dtj�}|r8|�tj|�d�d|�d��dSdSdS)Nz(?<=^)(\s*)%%(%*)r�%�TF)r$r�MrJrrfr9rjrrrr]es�zLexer.match_percentcCs@|�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$rrbr7r9rJrrf)rr$rrrrr^os
�
zLexer.match_textcCsd|�d�}|r\|j|j}}|�dd�\}}t|�d}|jtj||�d�dk||d�dSdSdS)	Nz<%(!)?Fz%>r%r�!�r
rT)	r$rrr<rrJrZCoder9)rr$�linerrr,rrrr\�s
�zLexer.match_python_blockcCsz|�d�}|sdS|j|j}}|�ddd�\}}|dkrL|�dd�\}}nd}|�dd	�}|jtj||��||d
�dS)Nz\${FTz\|r0r.�r`r%rp)	r$rrr<rerJr�
Expression�strip)rr$rqrrr,�escapesrrrrW�s"
�zLexer.match_expressioncCs�|�dtj�}|sdS|�d�}|�d�}|dkr�t�d|�}|sVtjd|f|j��|�dd�\}}|dk	}|r�t|j�s�tjd||ff|j��n0|jd	j	|kr�tjd
||jd	j	ff|j��|�
tj|||�n|�
tj
|�dS)NzC(?<=^)[\t ]*(%(?!%)|##)[\t ]*((?:(?:\\\r?\n)|[^\r\n])*)(?:\r?\n|\Z)Frrmrlz(end)?(\w+)\s*(.*)zInvalid control line: '%s'z!No starting keyword '%s' for '%s'r=z'Keyword '%s' doesn't match keyword '%s'T)r$rrnr9rr:rr8rrBrJrrA�Comment)rr$�operatorr�m2rErBrrrrX�sH�

��

�����zLexer.match_control_linecCs2|�dtj�}|r*|�tj|�d��dSdSdS)z*matches the multiline version of a commentz<%doc>(.*?)</%doc>rTFN)r$rr7rJrrvr9rjrrrrY�s
zLexer.match_comment)NNN)N)�__name__�
__module__�__qualname__r�propertyrr$r r<rJrrrMrTr_rZr[rVr]r^r\rWrXrYrrrrrs,�


(2
*:2
&r)
�__doc__rOr�makorrZ
mako.pygenrrrrrrr�<module>s

F1le Man4ger