%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/mako/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/mako/__pycache__/lexer.cpython-312.pyc

�

���e�?��T�dZddlZddlZddlmZddlmZddlmZiZGd�d�Z	y)zGprovides the Lexer class for parsing template strings into parse trees.�N)�
exceptions)�	parsetree)�adjust_whitespacec��eZdZ	dd�Zed��Zdd�Zd�Zd�Zd�Z	e
jd�Zd	�Z
d
�Zd�Zd�Zd
�Zd�Zd�Zd�Zd�Zd�Zd�Zy)�LexerNc�$�||_||_tj|j�|_d|_d|_d|_d|_g|_	g|_
g|_||_|�g|_
yt|d�s	|g|_
y||_
y)N�r�__iter__)�text�filenamer�TemplateNode�template�matched_lineno�matched_charpos�lineno�match_position�tag�control_line�
ternary_stack�encoding�preprocessor�hasattr)�selfrr�input_encodingrs     �,/usr/lib/python3/dist-packages/mako/lexer.py�__init__zLexer.__init__s�����	� ��
�!�.�.�t�}�}�=��
���� ������������������&��
��� "�D����z�2�!-��D�� ,�D��c�`�|j|j|j|jd�S)N)�sourcer�posr)rrrr)rs r�exception_kwargszLexer.exception_kwargs*s.���i�i��)�)��'�'��
�
�	
�	
rc���	t||f}|j	|�S#t$r;|rtj||�ntj|�}|t||f<Y�TwxYw)z>compile the given regexp, cache the reg, and call match_reg().)�
_regexp_cache�KeyError�re�compile�	match_reg)r�regexp�flags�regs    r�matchzLexer.match3sb��	1�����0�C�
�~�~�c�"�"��	�	1�/4�"�*�*�V�U�+�"�*�*�V�:L�C�-0�M�6�5�/�*�	1�s��AA"�!A"c���|j}|j|j|j�}|r�|j�\}}||k(r|dzn||_|j|_|dz
}|dk\r0||jkr!|jd|dzjd�}||z
|_|xj|j||jjd�z
c_|S)z�match the given regular expression object to the current text
        position.

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

        r	rN�
)
rr+r�spanrr�
textlength�rfindr�count)rr*�mpr+�start�end�cps       rr'zLexer.match_reg>s����
 �
 ���	�	�$�)�)�T�%8�%8�9��� �:�:�<�L�U�C�-0�E�\�#��'�s�D��"&�+�+�D���a��B��Q�w�2����/��Y�Y�x��a��(�.�.�t�4��#%��7�D� ��K�K�4�9�9�R�$�*=�*=�>�D�D�T�J�J�K��rc���|j}dj|�}d}d}d}	|jd�}|r�|jdtj�}|r�8|jd|z�}|rV|r|dkDsO|dkDsJ|dkDsE|j
||jt
|jd��z
|jd�fS|s#|jd|ztj�}|r�||jd�jd�z
}||jd�jd	�z}||jd�jd
�z
}||jd�jd�z}||jd�jd�z
}||jd�jd
�z}���tjddj|�zfi|j���)N�|rz#.*\nz+(\"\"\"|\'\'\'|\"|\')[^\\]*?(\\.[^\\]*?)*\1z(%s)r	z(.*?)(?=\"|\'|#|%s)�{�}�(�)�[�]zExpected: %s�,)r�joinr+r%�Sr�len�groupr1r�SyntaxExceptionr!)	r�
watch_nestingr�startpos�text_re�brace_level�paren_level�
bracket_levelr+s	         r�parse_until_textzLexer.parse_until_textTs����&�&���)�)�D�/�������
���J�J�x�(�E����J�J�>�����E����J�J�w��0�1�E��� �1�_��a��=�1�;L��I�I� �4�#6�#6��U�[�[��^�9L�#L���K�K��N�	����
�
�#9�G�#C�R�T�T�J����u�{�{�1�~�3�3�C�8�8���u�{�{�1�~�3�3�C�8�8���u�{�{�1�~�3�3�C�8�8���u�{�{�1�~�3�3�C�8�8������Q��!5�!5�c�!:�:�
�����Q��!5�!5�c�!:�:�
���,�,�����$��/��37�3H�3H��
rc��|jd|j�|jd|j�|jd|j�|j|d<||i|��}t|j�r)|jdjj|�n%|jjj|�|jr�|jd}|jj|�t|tj�r|j|j�sF|j r:|j dr+|j ddjj|�t|tj"�rEt|j�r|jd|_|jj|�yt|tj��rU|j&r5|jj)�|j j)�y|j*r7|jj|�|j jg�y|jrG|jdj|j�r|j dj|�y|jrq|jdj|j�sHt-j.d|j�d|jdj�d�fi|j0���yyy)	Nrrr r����	Keyword 'z#' not a legal ternary for keyword '�')�
setdefaultrrrrrAr�nodes�appendrr�
isinstancer�ControlLine�
is_ternary�keywordr�Tag�parent�isend�pop�
is_primaryrrCr!)r�nodecls�args�kwargs�node�
control_frames      r�append_nodezLexer.append_node|s������(�D�I�I�.����(�D�$7�$7�8����%��!5�!5�6�!�]�]��z����'��'���t�x�x�=��H�H�R�L���%�%�d�+��M�M���&�&�t�,�
��� �-�-�b�1�M����&�&�t�,��t�Y�%:�%:�;�%�0�0����>��&�&��&�&�r�*��"�"�2�&�r�*�0�0�7�7��=��d�I�M�M�*��4�8�8�}�"�h�h�r�l����H�H�O�O�D�!�
��i�3�3�
4��z�z��!�!�%�%�'��"�"�&�&�(�����!�!�(�(��.��"�"�)�)�"�-��"�"�t�'8�'8��'<�'G�'G����(��"�"�2�&�-�-�d�3��"�"�4�+<�+<�R�+@�+K�+K����,�!�0�0��|�|�T�%6�%6�r�%:�%B�%B�D���+�+���,�"�5rz #.*coding[:=]\s*([-\w.]+).*\r?\nc�>�t|t�r<|jj|�}|xr|j	d�xs|xsd}||fS|jtj�r�|ttj�d}d}|jj|jdd��}|��|j	d�dk7rtjd|j	d�z|jdd�dd|��|jj|jdd��}|r|j	d�n|xsd}|r	|j|�}||fS||fS#t$r-tjd|z|jdd�dd|��wxYw)z�given string/unicode or bytes/string, determine encoding
        from magic encoding comment, return body as unicode
        or raw if decode_raw=False

        r	zutf-8N�ignorezHFound utf-8 BOM in file, with conflicting magic encoding comment of '%s'rz0Unicode decode operation of encoding '%s' failed)
rR�str�
_coding_rer+rB�
startswith�codecs�BOM_UTF8rA�decoder�CompileException�UnicodeDecodeError)rr�
decode_raw�known_encodingr�mr�parsed_encodings        r�decode_raw_streamzLexer.decode_raw_stream�s����d�C� ����%�%�d�+�A��'�Q�W�W�Q�Z�D�>�D�W�H��T�>�!��?�?�6�?�?�+���F�O�O�,�.�/�D�%�O����%�%�d�k�k�'�8�&D�E�A��}������w�!6� �1�1�5�78�w�w�q�z�B��K�K���2����
�����%�%�d�k�k�'�8�&D�E�A�,-�a�g�g�a�j�>�3L�W�O��

��{�{�?�3����$�$���$�$��&�
� �1�1�F�%�&��K�K���2����
��
�s�
E&�&6Fc���|j|jd|j|j�\|_|_|jD]}||j�|_�|j|j�t|j�|_	|j|jkDrn�|j�rn�|j�r�=|j�r�N|j�r�_|j�r�p|j�r��|j!�r��|j#�r��|j%�r��|j|jkDrnt'j(d��t|j*�r:t'j,d|j*dj.zfi|j0���t|j2�rut'j,d|j2dj.z|j|j2dj4|j2dj6|j��|j8S)NTzassertion failed�Unclosed tag: <%%%s>rLz"Unterminated control keyword: '%s')rorrrrr'rdrAr/r�	match_end�match_expression�match_control_line�
match_comment�match_tag_start�
match_tag_end�match_python_block�
match_percent�
match_textr�
MakoExceptionrrCrUr!rrr r)r�preprocs  r�parsezLexer.parse�s���#'�#9�#9��I�I�t�T�]�]�D�M�M�$
� ��
�t�y��(�(�	+�G���	�	�*�D�I�	+�
	
���t���'��d�i�i�.�����"�"�T�_�_�4���~�~����$�$�&���&�&�(���!�!�#���#�#�%���!�!�#���&�&�(���!�!�#����� ���"�"�T�_�_�4���*�*�+=�>�>��t�x�x�=��,�,�&����"��)=�)=�=���'�'��
��t� � �!��,�,�4��#�#�B�'�/�/�0��	�	��!�!�"�%�,�,��!�!�"�%�)�)��
�
�
�
��}�}�rc��d}|j|tjtjztjz�}|sy|j�\}}}||_i}|r>tjd|�D]%}|\}}	}
|	xs|
}|jdd�}|||<�'|jtj||�|r|jj�y|dk(r�|jdtj�}|s:tjd|jd	jzfi|j ���|jtj"|j%d
��|j'�Sy)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>)rqrLr	T)r+r%�Ir@�X�groupsrU�findall�replacer`rrVrrYrrCr!�TextrBrw)rr*r+rU�attrrX�
attributes�att�key�val1�val2rs            rrvzLexer.match_tag_starts_���� �
�
���D�D�2�4�4�K�"�$�$��
��
��$�|�|�~����u�����
���z�z�<�d��
'��#&���T�4��|�t���|�|�F�D�1��"&�
�3��

'�	
��������<���H�H�L�L�N����
��J�J�4�b�d�d�;�E�� �0�0�*�T�X�X�b�\�-A�-A�A���+�+���
���Y�^�^�U�[�[��^�<��%�%�'�'�rc���|jd�}|r�t|j�s2tjd|jd�zfi|j���|jdj|jd�k7rMtjd|jd��d|jdj�d�fi|j���|jj�yy	)
Nz\</%[\t ]*([^\t ]+?)[\t ]*>z(Closing tag without opening tag: </%%%s>r	rLzClosing tag </%z> does not match tag: <%�>TF)	r+rArrrCrBr!rUrY�rr+s  rrwzLexer.match_tag_endFs����
�
�9�:����t�x�x�=� �0�0�>��k�k�!�n�%���+�+���
���"��%�%����Q��7� �0�0��{�{�1�~�t�x�x��|�';�';�=���+�+���

�H�H�L�L�N��rc�r�|jdtj�}|sy|j�}|r|Sy)Nz\ZFT)r+r%r@rB)rr+�strings   rrrzLexer.match_endZs2���
�
�5�"�$�$�'�����������M�rc���|jdtj�}|rE|jtj
|j
d�dz|j
d�z�yy)Nz(?<=^)(\s*)%%(%*)r	�%�TF)r+r%�Mr`rr�rBr�s  rryzLexer.match_percentesS���
�
�/����6������������A��� 4�u�{�{�1�~� E�
��rc���|jdtjtjz�}|r4|j	d�}|r |jtj|�yy)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
                )r	TF)r+r%r�r@rBr`rr�)rr+rs   rrzzLexer.match_textosU���
�
�
� 
�D�D�2�4�4�K�#
��(��;�;�q�>�D��� � �����6��rc��|jd�}|rr|j|j}}|jdd�\}}t	|�dz}|jtj||jd�dk(||��yy)	Nz<%(!)?Fz%>r-r	�!�rr T)	r+rrrJrr`r�CoderB)rr+�liner rr4s      rrxzLexer.match_python_block�s����
�
�9�%����+�+�T�-A�-A�#�D��-�-�e�U�;�I�D�#�%�T�*�T�1�D�����������A��#�%���
�
��rc�J�|jd�}|sy|j|j}}|jddd�\}}|dk(r|jdd�\}}nd}|j	dd	�}|jtj||j�||�
�y)Nz\${FTz\|r9r7�rr-r�)	r+rrrJr�r`r�
Expression�strip)rr+r�r rr4�escapess       rrszLexer.match_expression�s����
�
�6�"�����'�'��)=�)=�c���)�)�$��t�<�	��c��#�:��0�0��t�<�L�G�S��G��|�|�F�D�)������ � ���M�M�O���	�	
�rc��|jdtj�}|sy|jd�}|jd�}|dk(�rtjd|�}|s#t	j
d|zfi|j���|jdd�\}}|du}|r�t|j�s't	j
d|�d	|�d
�fi|j���|jdj|k7r>t	j
d|�d
|jdj�d
�fi|j���|jtj|||�y|jtj|�y)NzC(?<=^)[\t ]*(%(?!%)|##)[\t ]*((?:(?:\\\r?\n)|[^\r\n])*)(?:\r?\n|\Z)Fr	r�r�z(end)?(\w+)\s*(.*)zInvalid control line: '%s'zNo starting keyword 'z' for 'rNrLrMz' doesn't match keyword 'T)r+r%r�rBrrCr!rArrUr`rrS�Comment)rr+�operatorr�m2rXrUs       rrtzLexer.match_control_line�sq���
�
�
��D�D�
��
���;�;�q�>���{�{�1�~���s�?����/��6�B�� �0�0�0�4�7���+�+��� �X�X�a��^�N�E�7���%�E���4�,�,�-�$�4�4�?F��M���/�/����&�&�r�*�2�2�g�=�$�4�4���!2�!2�2�!6�!>�!>�@���/�/���

���Y�2�2�G�U�D�I��
���Y�.�.��5�rc��|jdtj�}|r0|jtj
|j
d��yy)z*matches the multiline version of a commentz<%doc>(.*?)</%doc>r	TF)r+r%r@r`rr�rBr�s  rruzLexer.match_comment�s>���
�
�0�"�$�$�7������Y�.�.����A��?��r)NNN)N)�__name__�
__module__�__qualname__r�propertyr!r+r'rJr`r%r&rdror}rvrwrrryrzrxrsrtru�rrrrs���EI�-�,�
��
�	#��,&�P0�d����?�@�J�(%�T8�t0�d�(	���:�&�*$�Lrr)
�__doc__rfr%�makorr�
mako.pygenrr#rr�rr�<module>r�s+��N�
�	���(��
�N�Nr

Zerion Mini Shell 1.0