ok

Mini Shell

Direktori : /opt/cloudlinux/venv/lib/python3.11/site-packages/coverage/__pycache__/
Upload File :
Current File : //opt/cloudlinux/venv/lib/python3.11/site-packages/coverage/__pycache__/templite.cpython-311.pyc

�

�܋f�*���dZddlmZddlZddlmZmZmZmZm	Z	m
Z
mZmZm
Z
Gd�de��ZGd�de��ZGd	�d
��ZGd�d��ZdS)
z�A simple Python template renderer, for a nano-subset of Django syntax.

For a detailed discussion of this code, see this chapter from 500 Lines:
http://aosabook.org/en/500L/a-template-engine.html

�)�annotationsN)	�Any�Callable�Dict�List�NoReturn�Optional�Set�Union�castc��eZdZdZdS)�TempliteSyntaxErrorz*Raised when a template has a syntax error.N��__name__�
__module__�__qualname__�__doc__���d/builddir/build/BUILD/cloudlinux-venv-1.0.6/venv/lib64/python3.11/site-packages/coverage/templite.pyrrs������4�4��Drrc��eZdZdZdS)�TempliteValueErrorz7Raised when an expression won't evaluate in a template.Nrrrrrrs������A�A��Drrc�P�eZdZdZddd�Zdd	�Zdd�Zdd�Zd
Zdd�Z	dd�Z
dd�ZdS)�CodeBuilderzBuild source code conveniently.r�indent�int�return�Nonec�"�g|_||_dS�N)�code�indent_level)�selfrs  r�__init__zCodeBuilder.__init__#s��35��	�"����r�strc�J�d�d�|jD����S)N�c3�4K�|]}t|��V��dSr )r%)�.0�cs  r�	<genexpr>z&CodeBuilder.__str__.<locals>.<genexpr>(s(����1�1�!�s�1�v�v�1�1�1�1�1�1r)�joinr!�r#s r�__str__zCodeBuilder.__str__'s%���w�w�1�1�t�y�1�1�1�1�1�1r�linec�P�|j�d|jz|dg��dS)zwAdd a line of source to the code.

        Indentation and newline will be added for you, don't provide them.

        � �
N)r!�extendr")r#r/s  r�add_linezCodeBuilder.add_line*s/��	
�	���#�� 1�1�4��>�?�?�?�?�?rc�b�t|j��}|j�|��|S)z!Add a section, a sub-CodeBuilder.)rr"r!�append)r#�sections  r�add_sectionzCodeBuilder.add_section2s-���d�/�0�0���	����!�!�!��r�c�0�|xj|jz
c_dS)z0Increase the current indent for following lines.N�r"�INDENT_STEPr-s rrzCodeBuilder.indent:������T�-�-����rc�0�|xj|jzc_dS)z0Decrease the current indent for following lines.Nr;r-s r�dedentzCodeBuilder.dedent>r=r�Dict[str, Any]c�b�|jdksJ�t|��}i}t||��|S)z:Execute the code, and return a dict of globals it defines.r)r"r%�exec)r#�
python_source�global_namespaces   r�get_globalszCodeBuilder.get_globalsBs@��� �A�%�%�%�%��D�	�	�
�+-���]�,�-�-�-��rN)r)rrrr)rr%)r/r%rr)rr�rr)rr@)rrrrr$r.r4r8r<rr?rErrrrr s�������)�)�#�#�#�#�#�2�2�2�2�@�@�@�@������K�.�.�.�.�.�.�.�.�	 �	 �	 �	 �	 �	 rrc�D�eZdZdZdd�Zdd
�Zdd�Zdd�Zdd d�Zd!d�Z	dS)"�Templitea�A simple template renderer, for a nano-subset of Django syntax.

    Supported constructs are extended variable access::

        {{var.modifier.modifier|filter|filter}}

    loops::

        {% for var in list %}...{% endfor %}

    and ifs::

        {% if var %}...{% endif %}

    Comments are within curly-hash markers::

        {# This will be ignored #}

    Lines between `{% joined %}` and `{% endjoined %}` will have lines stripped
    and joined.  Be careful, this could join words together!

    Any of these constructs can have a hyphen at the end (`-}}`, `-%}`, `-#}`),
    which will collapse the white space following the tag.

    Construct a Templite with the template text, then use `render` against a
    dictionary context to create a finished string::

        templite = Templite('''
            <h1>Hello {{name|upper}}!</h1>
            {% for topic in topics %}
                <p>You are interested in {{topic}}.</p>
            {% endif %}
            ''',
            {"upper": str.upper},
        )
        text = templite.render({
            "name": "Ned",
            "topics": ["Python", "Geometry", "Juggling"],
        })

    �textr%�contextsr@rrc
�H���i|_|D]}|j�|���t��|_t��|_t�����d����������}��d����d����d����d��g�d0��fd�}g}tj
d	|��}d
x}}	|D�]�}
|
�d���r%d\}}|
d
dk}|rd
}|
�d��r�D|
�d��rH|�|
||��
����}
��d|
z����|��|
||��
���
��}|ddkr�t|��dkr|�d|
��|�d����d|�|d��z��������j|ddkr�t|��dks|ddkr|�d|
��|�d��|�|d|j����d�|d|�|d������������?|ddkr|�d��d}	��d|d�d ��r�t|��dkr|�d!|
��|ddd"�}|s|�d#|
��|���}||kr|�d$|��|dkrd
}	��
������ |�d%|d����>|	r)tjd&d'|
�
����}
n|r|
���}
|
r"��t/|
�������|r|�d(|d)��|��|j|jz
D]}|�d*|�d+|�d,������d-������t1t2t4t6t8ft2d.t8fgt6f����d/��|_d"S)1z�Construct a Templite with the given `text`.

        `contexts` are dictionaries of values to use for future renderings.
        These are good for filters and global values.

        z&def render_function(context, do_dots):zresult = []zappend_result = result.appendzextend_result = result.extendzto_str = strrrc����t���dkr��d�dz��n>t���dkr+��dd����z���dd�=dS)z%Force `buffered` to the code builder.�zappend_result(%s)rzextend_result([%s])�, N)�lenr4r,)�bufferedr!s��r�flush_outputz'Templite.__init__.<locals>.flush_output�sw����8�}�}��!�!��
�
�1�H�Q�K�?�@�@�@�@��X����"�"��
�
�3�d�i�i��6I�6I�I�J�J�J�������rz(?s)({{.*?}}|{%.*?%}|{#.*?#})F�{)��������-z{#z{{z
to_str(%s)r�ifrSzDon't understand ifzif %s:rM�forr9�inzDon't understand forzfor c_{} in {}:��joinedT�endzDon't understand endNz
Too many endszMismatched end tagzDon't understand tagz\s*\n\s*r'zUnmatched action tag����c_z = context[�]zreturn ''.join(result).�render_functionrF)�context�update�set�all_vars�	loop_varsrr4rr8�re�split�
startswith�
_expr_code�stripr6rO�
_syntax_error�	_variable�format�popr?�sub�lstrip�reprrrrr%rrE�_render_function)r#rIrJra�	vars_coderQ�	ops_stack�tokens�squash�	in_joined�token�startr\�expr�words�end_what�
start_what�var_namerPr!s                  @@rr$zTemplite.__init__xs���������	)�	)�G��L����(�(�(�(�"%�%�%��
�#&�5�5����}�}���
�
�>�?�?�?����
�
�
��$�$�&�&�	��
�
�m�$�$�$��
�
�5�6�6�6��
�
�5�6�6�6��
�
�n�%�%�%� ��	�	�	�	�	�	�	��	���:�D�A�A��"�"����B	1�B	1�E�����$�$�A
1�"�
��s���)�s�*�����C��#�#�D�)�)�3M���%�%�d�+�+�0M��?�?�5��s��+;�+A�+A�+C�+C�D�D�D��O�O�L�4�$7�8�8�8�8�!�L�N�N�N�!�%��)�,�2�2�4�4�:�:�<�<�E��Q�x�4�'�'��u�:�:��?�?� �.�.�/D�e�L�L�L�!�(�(��.�.�.��
�
�h�����q��1J�1J�&J�K�K�K����
�
�
�
��q��U�*�*��u�:�:��?�?�e�A�h�$�.>�.>� �.�.�/E�u�M�M�M�!�(�(��/�/�/����u�Q�x���@�@�@��
�
�-�4�4� %�a�� $����a�� 9� 9���������
�
�
�
��q��X�-�-�!�(�(��2�2�2�$(�	�	��q��,�,�U�3�3�M��u�:�:��?�?� �.�.�/E�u�M�M�M�#(��8�A�B�B�<��(�G� �.�.���F�F�F�%.�]�]�_�_�
�%��1�1� �.�.�/C�X�N�N�N�#�x�/�/�(-�I�I� �K�K�M�M�M�M��*�*�+A�5��8�L�L�L�L��+��F�;��E�K�K�M�M�B�B�E�E��+�!�L�L�N�N�E��1��O�O�D��K�K�0�0�0���	F����5�y��}�E�E�E�������
���6�	H�	H�H����F�H�F�F��F�F�F�G�G�G�G��
�
�.�/�/�/����
�
�
� $���c�3�h���#�s�(�!3�4���
�
�����0�1�!
�!
����rrzc���d|vrb|�d��}|�|d��}|dd�D]&}|�||j��d|�d|�d�}�'n�d|vra|�d��}|�|d��}d	�d
�|dd�D����}d|�d	|�d�}n |�||j��d|z}|S)
z(Generate a Python expression for `expr`.�|rrMNr^�(�)�.rNc3�4K�|]}t|��V��dSr )rq)r)�ds  rr+z&Templite._expr_code.<locals>.<genexpr>s(����7�7��T�!�W�W�7�7�7�7�7�7rzdo_dots(zc_%s)rgrirlrdr,)r#rz�pipesr!�func�dots�argss       rrizTemplite._expr_code�s���$�;�;��J�J�s�O�O�E��?�?�5��8�,�,�D��a�b�b�	�
+�
+�����t�T�]�3�3�3�*�D�*�*�4�*�*�*���
+��D�[�[��:�:�c�?�?�D��?�?�4��7�+�+�D��9�9�7�7�d�1�2�2�h�7�7�7�7�7�D�-�d�-�-�d�-�-�-�D�D��N�N�4���/�/�/��D�=�D��r�msg�thingrrc�*�t|�d|�����)z6Raise a syntax error using `msg`, and showing `thing`.z: )r)r#r�r�s   rrkzTemplite._syntax_errors��!�S�"5�"5�E�"5�"5�6�6�6r�name�vars_set�Set[str]c��tjd|��s|�d|��|�|��dS)z�Track that `name` is used as a variable.

        Adds the name to `vars_set`, a set of variable names.

        Raises an syntax error if `name` is not a valid name.

        z[_a-zA-Z][_a-zA-Z0-9]*$zNot a valid nameN)rf�matchrk�add)r#r�r�s   rrlzTemplite._variablesH���x�2�D�9�9�	9����1�4�8�8�8����T�����rNra�Optional[Dict[str, Any]]c��t|j��}|r|�|��|�||j��S)z�Render this template by applying it to `context`.

        `context` is a dictionary of values to use in this rendering.

        )�dictrarbrr�_do_dots)r#ra�render_contexts   r�renderzTemplite.rendersG���d�l�+�+���	+��!�!�'�*�*�*��$�$�^�T�]�C�C�Cr�valuer�c	��|D]v}	t||��}nI#t$r<	||}n/#ttf$r}t	d|�d|����|�d}~wwxYwYnwxYwt|��r
|��}�w|S)z(Evaluate dotted expressions at run-time.zCouldn't evaluate r�N)�getattr�AttributeError�	TypeError�KeyErrorr�callable)r#r�r��dot�excs     rr�zTemplite._do_dots's����	 �	 �C�
���s�+�+����!�
�
�
��!�#�J�E�E��!�8�,����,�<�U�<�<�s�<�<��������������E�
��������
 ��������s.��
A�+�A�A�A�A�A�A)rIr%rJr@rr)rzr%rr%)r�r%r�rrr)r�r%r�r�rrr )rar�rr%)r�rr�r%rr)
rrrrr$rirkrlr�r�rrrrHrHNs�������(�(�R
�
�
�
�B����$7�7�7�7�
�
�
�
�
D�
D�
D�
D�
D������rrH)r�
__future__rrf�typingrrrrrr	r
rr�
ValueErrorrrrrHrrr�<module>r�sS����#�"�"�"�"�"�	�	�	�	�����������������������
	�	�	�	�	�*�	�	�	�
	�	�	�	�	��	�	�	�
+ �+ �+ �+ �+ �+ �+ �+ �\g�g�g�g�g�g�g�g�g�gr

Zerion Mini Shell 1.0