OwlCyberSecurity - MANAGER
Edit File: templite.cpython-311.pyc
� ������h�*���������������������������d�Z�ddlmZ�ddlZddlmZmZmZmZm Z m Z mZmZm Z ��G�d��de������������Z�G�d��de������������Z�G�d ��d ������������Z�G�d��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������������������������e�Zd�ZdZdS�)�TempliteSyntaxErrorz*Raised when a template has a syntax error.N��__name__� __module__�__qualname__�__doc__��������d/builddir/build/BUILD/cloudlinux-venv-1.0.8/venv/lib64/python3.11/site-packages/coverage/templite.pyr���r������s��������������4�4��Dr���r���c������������������������e�Zd�ZdZdS�)�TempliteValueErrorz7Raised when an expression won't evaluate in a template.Nr���r���r���r���r���r������s��������������A�A��Dr���r���c�������������������P�����e�Zd�ZdZddd�Zdd �Zdd�Zdd�Zd Zdd�Z dd�Z dd�ZdS�)�CodeBuilderzBuild source code conveniently.r����indent�int�return�Nonec�����������������"�����g�|�_���������||�_��������d�S��N)�code�indent_level)�selfr���s��� r����__init__zCodeBuilder.__init__#���s������35�� �"����r����strc�����������������J�����d����������������������d��|�j��������D���������������������������S�)N��c��������������3���4���K����|�]}t����������|������������V����d�S�r ���)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|�j��������z��|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��>�?�?�?�?�?r���c�����������������b�����t����������|�j��������������������}|�j�����������������������������|�������������|S�)z!Add a section, a sub-CodeBuilder.)r���r"���r!����append)r#����sections��� r����add_sectionzCodeBuilder.add_section2���s-�������d�/�0�0��� ����!�!�!��r�������c�����������������0�����|�xj���������|�j��������z ��c_���������dS�)z0Increase the current indent for following lines.N�r"����INDENT_STEPr-���s��� r���r���zCodeBuilder.indent:�������������T�-�-����r���c�����������������0�����|�xj���������|�j��������z��c_���������dS�)z0Decrease the current indent for following lines.Nr;���r-���s��� r����dedentzCodeBuilder.dedent>���r=���r����Dict[str, Any]c�����������������b�����|�j���������dk����sJ��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_globalsB���s@�������� �A�%�%�%�%��D� � � �+-���]�,�-�-�-��r���N)r���)r���r���r���r���)r���r%���)r/���r%���r���r���)r���r����r���r���)r���r@���)r���r���r���r���r$���r.���r4���r8���r<���r���r?���rE���r���r���r���r���r��� ���s���������������)�)�#��#��#��#��#�2��2��2��2�@��@��@��@����������K�.��.��.��.�.��.��.��.� �� �� �� �� �� r���r���c�������������������D�����e�Zd�ZdZdd�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@���r���r���c����������� ������H������i�|�_���������|D�]}|�j������������������������������|��������������t������������������������|�_��������t������������������������|�_��������t�����������������������������������������������d��������������������������������������������������������������������������������������}����������������������d�����������������������������������d�����������������������������������d�����������������������������������d�������������g��d0��fd�}g�}t����������j ��������d |������������}d x}} |D��]�} | ���������������������d�������������r%d\��}}| d ���������dk����}|rd }| ���������������������d������������r�D| ���������������������d������������rH|����������������������| ||����������� ����������������������������������������������} ����������������������d| z������������������|���������������| ||����������� ����������������������������������� ����������������������������������}|d���������dk����r�t����������|������������dk����r|����������������������d| �������������|���������������������d�����������������������������������d|����������������������|d���������������������z������������������������������������������������������j|d���������dk����r�t����������|������������dk����s|d���������dk����r|����������������������d| �������������|���������������������d�������������|����������������������|d���������|�j�������������������������������������������d���������������������|d���������|����������������������|d�������������������������������������������������������������������������������������?|d���������dk����r|���������������������d�������������d} ��d|d������������������������������d ������������r�t����������|������������dk����r|����������������������d!| �������������|d���������dd"����������}|s|����������������������d#| �������������|�����������������������������������}||k����r|����������������������d$|�������������|dk����rd } �� ��������������������������������������� |����������������������d%|d������������������������>| r)t����������j��������d&d'| � ����������������������������������������������} n|r| �����������������������������������} | r"����������������������t/����������| ����������������������������|r|����������������������d(|d)�����������������������|���������������|�j��������|�j��������z ��D�]}|���������������������d*|��d+|�d,�������������������������������������d-��������������������������������������������������t1����������t2����������t4����������t6����������t8����������f���������t2����������d.t8����������f���������gt6����������f���������������������������������������������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.extendzto_str = strr���r���c�������������������������t������������������������dk����r����������������������d��d���������z���������������n>t������������������������dk����r+����������������������dd�����������������������������������z�����������������dd�=�dS�)z%Force `buffered` to the code builder.����zappend_result(%s)r���zextend_result([%s])�, N)�lenr4���r,���)�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�������r���z(?s)({{.*?}}|{%.*?%}|{#.*?#})F�{)�����������-z{#z{{z to_str(%s)r����ifrS���zDon'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_varsr���r4���r���r8����re�split� startswith� _expr_code�stripr6���rO���� _syntax_error� _variable�format�popr?����sub�lstrip�reprr���r���r���r%���r���rE����_render_function)r#���rI���rJ���ra���� vars_coderQ���� ops_stack�tokens�squash� in_joined�token�startr\����expr�words�end_what� start_what�var_namerP���r!���s��� @@r���r$���zTemplite.__init__x���s�������������� )�� )�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�! ��! ����r���rz���c����������������������d|v�rb|����������������������d������������}|����������������������|d���������������������}|dd����������D�]&}|����������������������||�j���������������������d|��d|��d�}�'n�d|v�ra|����������������������d������������}|����������������������|d���������������������}d ���������������������d ��|dd����������D���������������������������}d|��d |��d�}n |����������������������||�j���������������������d|z��}|S�) z(Generate a Python expression for `expr`.�|r���rM���Nr^����(�)�.rN���c��������������3���4���K����|�]}t����������|������������V����d�S�r ���)rq���)r)����ds��� r���r+���z&Templite._expr_code.<locals>.<genexpr>��s(����������7�7��T�!�W�W�7�7�7�7�7�7r���zdo_dots(zc_%s)rg���ri���rl���rd���r,���)r#���rz����pipesr!����func�dots�argss��� r���ri���zTemplite._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�thingr���r���c�����������������*�����t����������|��d|���������������)z6Raise a syntax error using `msg`, and showing `thing`.z: )r���)r#���r����r����s��� r���rk���zTemplite._syntax_error��s������!�S�"5�"5�E�"5�"5�6�6�6r����name�vars_set�Set[str]c����������������������t����������j��������d|������������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��� r���rl���zTemplite._variable��sH��������x�2�D�9�9�� 9����1�4�8�8�8����T�����r���Nra����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. )�dictra���rb���rr����_do_dots)r#���ra����render_contexts��� r����renderzTemplite.render��sG��������d�l�+�+���� +��!�!�'�*�*�*��$�$�^�T�]�C�C�Cr����valuer����c����������� �����������|D�]v} �t����������||������������}nI#�t����������$�r<� �||���������}n/#�t����������t����������f$�r}t ����������d|�d|���������������|�d}~ww�xY�wY�nw�xY�wt����������|������������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��� r���r����zTemplite._do_dots'��s��������� �� �C� ���s�+�+����!�� �� �� ��!�#�J�E�E��!�8�,�������,�<�U�<�<�s�<�<����������������E� ���������� ��������s.����� A�+�A�A�A�A�A�A)rI���r%���rJ���r@���r���r���)rz���r%���r���r%���)r����r%���r����r���r���r���)r����r%���r����r����r���r���r ���)ra���r����r���r%���)r����r���r����r%���r���r���) r���r���r���r���r$���ri���rk���rl���r����r����r���r���r���rH���rH���N���s���������������(��(�R �� �� �� �B�������$7��7��7��7� �� �� �� � D�� D�� D�� D�� D�����������r���rH���)r���� __future__r���rf����typingr���r���r���r���r���r ���r ���r���r���� ValueErrorr���r���r���rH���r���r���r����<module>r�������sS��������#��"��"��"��"��"�� � � � �������������������������������������������� �� �� �� �� �*�� �� �� � �� �� �� �� ��� �� �� � + ��+ ��+ ��+ ��+ ��+ ��+ ��+ �\g��g��g��g��g��g��g��g��g��gr���