Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
template.cpython-313.pyc399 linesDownload Raw Back to __pycache__
1�

2��j;����SrSSKrSSKJr SSKrSSKrSSKrSSKrSSK	r	SSK3Jr SSKJ
r
 SSKJrJrJr SSKJrJrJrJrJrJrJrJr SSKr\R6(aSSKJrJr S	r"S4S5r\"5r S\!S
\!S\!4Sjr""SS5r#"SS5r$"SS\$5r%"SS\$5r&"SS5r'"SS\'5r("SS\'5r)"SS\'5r*"S S!\'5r+"S"S#\'5r,"S$S%\'5r-"S&S'\'5r."S(S)\'5r/"S*S+\'5r0"S,S-\'5r1"S.S/\15r2"S0S1\'5r3"S2S3\45r5"S4S55r6"S6S75r7S8\!S\!4S9jr8S?S:\7S;\#S<\\!S=\\!S\)45S>jjr9g)@a�A simple template system that compiles templates to Python code.6 7Basic usage looks like::8 9    t = template.Template("<html>{{ myvalue }}</html>")10    print(t.generate(myvalue="XXX"))11 12`Loader` is a class that loads templates from a root directory and caches13the compiled templates::14 15    loader = template.Loader("/home/btaylor")16    print(loader.load("test.html").generate(myvalue="XXX"))17 18We compile all templates to raw Python. Error-reporting is currently... uh,19interesting. Syntax for the templates::20 21    ### base.html22    <html>23      <head>24        <title>{% block title %}Default title{% end %}</title>25      </head>26      <body>27        <ul>28          {% for student in students %}29            {% block student %}30              <li>{{ escape(student.name) }}</li>31            {% end %}32          {% end %}33        </ul>34      </body>35    </html>36 37    ### bold.html38    {% extends "base.html" %}39 40    {% block title %}A bolder title{% end %}41 42    {% block student %}43      <li><span style="bold">{{ escape(student.name) }}</span></li>44    {% end %}45 46Unlike most other template systems, we do not put any restrictions on the47expressions you can include in your statements. ``if`` and ``for`` blocks get48translated exactly into Python, so you can do complex expressions like::49 50   {% for student in [p for p in people if p.student and p.age > 23] %}51     <li>{{ escape(student.name) }}</li>52   {% end %}53 54Translating directly to Python means you can apply functions to expressions55easily, like the ``escape()`` function in the examples above. You can pass56functions in to your template just like any other variable57(In a `.RequestHandler`, override `.RequestHandler.get_template_namespace`)::58 59   ### Python code60   def add(x, y):61      return x + y62   template.execute(add=add)63 64   ### The template65   {{ add(1, 2) }}66 67We provide the functions `escape() <.xhtml_escape>`, `.url_escape()`,68`.json_encode()`, and `.squeeze()` to all templates by default.69 70Typical applications do not create `Template` or `Loader` instances by71hand, but instead use the `~.RequestHandler.render` and72`~.RequestHandler.render_string` methods of73`tornado.web.RequestHandler`, which load templates automatically based74on the ``template_path`` `.Application` setting.75 76Variable names beginning with ``_tt_`` are reserved by the template77system and should not be used by application code.78 79Syntax Reference80----------------81 82Template expressions are surrounded by double curly braces: ``{{ ... }}``.83The contents may be any python expression, which will be escaped according84to the current autoescape setting and inserted into the output.  Other85template directives use ``{% %}``.86 87To comment out a section so that it is omitted from the output, surround it88with ``{# ... #}``.89 90 91To include a literal ``{{``, ``{%``, or ``{#`` in the output, escape them as92``{{!``, ``{%!``, and ``{#!``, respectively.93 94 95``{% apply *function* %}...{% end %}``96    Applies a function to the output of all template code between ``apply``97    and ``end``::98 99        {% apply linkify %}{{name}} said: {{message}}{% end %}100 101    Note that as an implementation detail apply blocks are implemented102    as nested functions and thus may interact strangely with variables103    set via ``{% set %}``, or the use of ``{% break %}`` or ``{% continue %}``104    within loops.105 106``{% autoescape *function* %}``107    Sets the autoescape mode for the current file.  This does not affect108    other files, even those referenced by ``{% include %}``.  Note that109    autoescaping can also be configured globally, at the `.Application`110    or `Loader`.::111 112        {% autoescape xhtml_escape %}113        {% autoescape None %}114 115``{% block *name* %}...{% end %}``116    Indicates a named, replaceable block for use with ``{% extends %}``.117    Blocks in the parent template will be replaced with the contents of118    the same-named block in a child template.::119 120        <!-- base.html -->121        <title>{% block title %}Default title{% end %}</title>122 123        <!-- mypage.html -->124        {% extends "base.html" %}125        {% block title %}My page title{% end %}126 127``{% comment ... %}``128    A comment which will be removed from the template output.  Note that129    there is no ``{% end %}`` tag; the comment goes from the word ``comment``130    to the closing ``%}`` tag.131 132``{% extends *filename* %}``133    Inherit from another template.  Templates that use ``extends`` should134    contain one or more ``block`` tags to replace content from the parent135    template.  Anything in the child template not contained in a ``block``136    tag will be ignored.  For an example, see the ``{% block %}`` tag.137 138``{% for *var* in *expr* %}...{% end %}``139    Same as the python ``for`` statement.  ``{% break %}`` and140    ``{% continue %}`` may be used inside the loop.141 142``{% from *x* import *y* %}``143    Same as the python ``import`` statement.144 145``{% if *condition* %}...{% elif *condition* %}...{% else %}...{% end %}``146    Conditional statement - outputs the first section whose condition is147    true.  (The ``elif`` and ``else`` sections are optional)148 149``{% import *module* %}``150    Same as the python ``import`` statement.151 152``{% include *filename* %}``153    Includes another template file.  The included file can see all the local154    variables as if it were copied directly to the point of the ``include``155    directive (the ``{% autoescape %}`` directive is an exception).156    Alternately, ``{% module Template(filename, **kwargs) %}`` may be used157    to include another template with an isolated namespace.158 159``{% module *expr* %}``160    Renders a `~tornado.web.UIModule`.  The output of the ``UIModule`` is161    not escaped::162 163        {% module Template("foo.html", arg=42) %}164 165    ``UIModules`` are a feature of the `tornado.web.RequestHandler`166    class (and specifically its ``render`` method) and will not work167    when the template system is used on its own in other contexts.168 169``{% raw *expr* %}``170    Outputs the result of the given expression without autoescaping.171 172``{% set *x* = *y* %}``173    Sets a local variable.174 175``{% try %}...{% except %}...{% else %}...{% finally %}...{% end %}``176    Same as the python ``try`` statement.177 178``{% while *condition* %}... {% end %}``179    Same as the python ``while`` statement.  ``{% break %}`` and180    ``{% continue %}`` may be used inside the loop.181 182``{% whitespace *mode* %}``183    Sets the whitespace mode for the remainder of the current file184    (or until the next ``{% whitespace %}`` directive). See185    `filter_whitespace` for available options. New in Tornado 4.3.186�N)�StringIO)�escape)�app_log)�187ObjectDict�exec_in�unicode_type)�Any�Union�Callable�List�Dict�Iterable�Optional�TextIO)�Tuple�ContextManager�xhtml_escapec��\rSrSrSrg)�_UnsetMarker���N)�__name__�188__module__�__qualname__�__firstlineno__�__static_attributes__r��VD:\code\apps\devtools\python\user_packages\Python313\site-packages\tornado/template.pyrr�s��rr�mode�text�returnc���US:XaU$US:Xa2[R"SSU5n[R"SSU5nU$US:Xa[R"SSU5$[S	U-5e)189arTransform whitespace in ``text`` according to ``mode``.190 191Available modes are:192 193* ``all``: Return all whitespace unmodified.194* ``single``: Collapse consecutive whitespace with a single whitespace195  character, preserving newlines.196* ``oneline``: Collapse all runs of whitespace into a single space197  character, removing all newlines in the process.198 199.. versionadded:: 4.3200�all�singlez([\t ]+)� z201(\s*\n\s*)�202�onelinez(\s+)zinvalid whitespace mode %s)�re�sub�	Exception)rr s  r�filter_whitespacer+�sm���u�}���	
��	��v�v�k�3��-���v�v�m�T�4�0����	
��	��v�v�h��T�*�*��4�t�;�<�<rc���\rSrSrSrSS\\S4S\\\4S\S\	SS	\\203\4S204\	\\\4S\	\SS4S
jjrS\
S\4SjrS\	SS\4SjrS\	SS\S4SjrSrg)�Template��z�A compiled template.205 206We compile into Python from the given template_string. You can generate207the template from variables with generate().208z<string>N�template_string�name�loader�209BaseLoader�compress_whitespace�210autoescape�211whitespacer!c���[R"U5UlU[LaUb[	S5eU(aSOSnUcVU(aUR212(a
UR213nO1UR
S5(dUR
S5(aSnOSnUce[US5 [U[5(dXPl214O$U(aURUl215O[Ul216U(aURO0Ul[U[R"U5U5n[U[Xp55UlUR#U5UlX0l[)[R*"UR$5SURR-S	S2175-SSS
9Ulg![aG [1UR$5R35n[4R6"SURU5 ef=f)a;Construct a Template.218 219:arg str template_string: the contents of the template file.220:arg str name: the filename from which the template was loaded221    (used for error message).222:arg tornado.template.BaseLoader loader: the `~tornado.template.BaseLoader` responsible223    for this template, used to resolve ``{% include %}`` and ``{% extend %}`` directives.224:arg bool compress_whitespace: Deprecated since Tornado 4.3.225    Equivalent to ``whitespace="single"`` if true and226    ``whitespace="all"`` if false.227:arg str autoescape: The name of a function in the template228    namespace, or ``None`` to disable escaping by default.229:arg str whitespace: A string specifying treatment of whitespace;230    see `filter_whitespace` for options.231 232.. versionchanged:: 4.3233   Added ``whitespace`` parameter; deprecated ``compress_whitespace``.234Nz2cannot set both whitespace and compress_whitespacer$r#z.htmlz.js�z%s.generated.py�.�_�execT)�dont_inheritz%s code:235%s)r�236native_strr0�_UNSETr*r5�endswithr+�237isinstancerr4�_DEFAULT_AUTOESCAPE�	namespace�_TemplateReader�_File�_parse�file�_generate_python�coder1�compile�238to_unicode�replace�compiled�_format_code�rstripr�error)	�selfr/r0r1r3r4r5�reader�formatted_codes	         r�__init__�Template.__init__s���6�%�%�d�+��	��f�,��%�� T�U�U�%8��e�J����&�+�+�#�.�.�239��=�=��)�)�T�]�]�5�-A�-A�!)�J�!&�J��%�%�%��*�b�)��*�l�3�3�(�O�
�$�/�/�D�O�1�D�O�-3��)�)���� ��v�'8�'8��'I�:�V���$��v� 4�5��	��)�)�&�1��	���	�240$��!�!�$�)�)�,�!�D�I�I�$5�$5�c�3�$?�?��!�	�D�M���	�)�$�)�)�4�;�;�=�N��M�M�.�$�)�)�^�D��	�s�AF'�'AG8�kwargsc�T^�[R[R[R[R[R[R241[[R[[4TRRSS5[U4SjS9S.nURTR5 URU5 [TR U5 ["R$"[&/[4US5n[(R*"5 U"5$)z0Generate this template with the given arguments.r8r9c�>�TR$�N)rG)r0rOs �r�<lambda>�#Template.generate.<locals>.<lambda>`s	���T�Y�Yr)�242get_source)rr�243url_escape�json_encode�squeeze�linkify�datetime�_tt_utf8�_tt_string_typesr�244__loader__�_tt_execute)rrr[r\r]r^r_�utf8r�bytesr0rJr�updaterArrK�typing�castr�	linecache�245clearcache)rOrTrA�executes`   r�generate�Template.generateQs�����)�)�"�/�/� �+�+�!�-�-��~�~��~�~� ����!-�u� 5��	�	�)�)�#�s�3�$�0F�G�246�	�	������(����� ���
�
�y�)��+�+�h�r�5�y�1�9�]�3K�L��	�����y�rc�V�[5n0nURU5nUR5 UHnURX5 M [	X#XSR2475nUSR
U5 UR5UR5 $!UR5 f=f�Nr)	r�_get_ancestors�reverse�find_named_blocks�_CodeWriter�templaterl�getvalue�close)rOr1�buffer�named_blocks�	ancestors�ancestor�writers       rrF�Template._generate_pythonls������	��L��+�+�F�3�I�����%���*�*�6�@�&� ��v��|�?T�?T�U�F��a�L�!�!�&�)��?�?�$��L�L�N��F�L�L�N�s�A9B�B(rCc�L�UR/nURRRHrn[U[5(dMU(d[S5eUR
URUR5nURURU55 Mt U$)Nz1{% extends %} block found, but no template loader)248rE�body�chunksr?�
_ExtendsBlock�249ParseError�loadr0�extendrp)rOr1ry�chunkrts     rrp�Template._get_ancestors{s����Y�Y�K�	��Y�Y�^�^�*�*�E��%��/�/��$�N���"�;�;�u�z�z�4�9�9�=��� � ��!8�!8��!@�A�+��r)r4rGrKrEr1r0rA)rrrr�__doc__r=r250�strrer�boolrrRr	rlrFrrprrrrr-r-�s�����)-�9?�9?�$(�I��s�E�z�*�I��I���&�	I�251#�4��#5�6�I��U�3��#4�5�6�
I��S�M�I�252�I�V�����6
�x��'=�
�#�
�253�X�l�%;�254��W�
�255rr-c	��\rSrSrSr\SS4S\\S\\\\	4S\\SS4Sjjr256SS	jrSS257\S\\S\4SjjrSS258\S\\S\
4S
jjrS259\S\
4SjrSrg)r2i�z�Base class for template loaders.260 261You must use a template loader to use template constructs like262``{% extends %}`` and ``{% include %}``. The loader caches all263templates after they are loaded the first time.264Nr4rAr5r!c�~�XlU=(d 0UlX0l0Ul[R265"5Ulg)a0Construct a template loader.266 267:arg str autoescape: The name of a function in the template268    namespace, such as "xhtml_escape", or ``None`` to disable269    autoescaping by default.270:arg dict namespace: A dictionary to be added to the default template271    namespace, or ``None``.272:arg str whitespace: A string specifying default behavior for273    whitespace in templates; see `filter_whitespace` for options.274    Default is "single" for files ending in ".html" and ".js" and275    "all" for other files.276 277.. versionchanged:: 4.3278   Added ``whitespace`` parameter.279N)r4rAr5�	templates�	threading�RLock�lock)rOr4rAr5s    rrR�BaseLoader.__init__�s0��*%��"��b���$������O�O�%��	rc�^�UR 0UlSSS5 g!,(df   g=f)z'Resets the cache of compiled templates.N)r�r��rOs r�reset�BaseLoader.reset�s��
�Y�Y��D�N��Y�Y�s��280,r0�parent_pathc��[5e)z@Converts a possibly-relative path to absolute (used internally).��NotImplementedError�rOr0r�s   r�resolve_path�BaseLoader.resolve_path�s��!�#�#rc���URXS9nUR XR;aURU5URU'URUsSSS5 $!,(df   g=f)zLoads a template.)r�N)r�r�r��_create_templater�s   rr��BaseLoader.load�sU��� � �� �?��
�Y�Y��>�>�)�'+�'<�'<�T�'B����t�$��>�>�$�'��Y�Y�s�<A"�"281A0c��[5erWr��rOr0s  rr��BaseLoader._create_template����!�#�#r)r4r�rAr�r5)r!NrW)rrrrr�r@rr�r
r	rRr�r�r-r�r�rrrrr2r2�s����%8�.2�$(�	&��S�M�&��D��c��N�+�&��S�M�	&�282283�&�@ �284$��$�8�C�=�$�C�$�(��(�8�C�=�(�H�(�$�S�$�X�$rr2c�n^�\rSrSrSrS\S\SS4U4SjjrS
S\S	\\S\4S285jjr	S\S\2864SjrSrU=r
$)�Loaderi�z:A template loader that loads from a single root directory.�root_directoryrTr!Nc�n>�[TU]"S0UD6 [RR	U5Ulg�Nr)�superrR�os�path�abspath�root)rOr�rT�	__class__s   �rrR�Loader.__init__�s'���
���"�6�"��G�G�O�O�N�3��	rr0r�c�V�U(Ga URS5(Gd	URS5(d�URS5(d�[RRURU5n[RR[RR
U55n[RR
[RRXA55nURUR5(aU[UR5S-SnU$)N�<�/�)�287startswithr�r��joinr��dirnamer��len)rOr0r��current_path�file_dir�
relative_paths      rr��Loader.resolve_path�s�����*�*�3�/�/��*�*�3�/�/��O�O�C�(�(��7�7�<�<��	�	�;�?�L��w�w���r�w�w���|�'D�E�H��G�G�O�O�B�G�G�L�L��,H�I�M��'�'��	�	�2�2�$�S����^�a�%7�%9�:���rc���[RRURU5n[	US5n[UR
5XS9nUsSSS5 $!,(df   g=f)N�rb�r0r1)r�r�r�r��openr-�read)rOr0r��frts     rr��Loader._create_template�sG���w�w�|�|�D�I�I�t�,��
�$��
�������t�A�H���
�
�s�A�288A))r�rW)rrrrr�r�r	rRrr�r-r�r�
__classcell__�r�s@rr�r��sV���D�4�s�4�c�4�d�4����8�C�=��C���S��X��rr�c�x^�\rSrSrSrS\\\4S\SS4U4SjjrS
S\S	\	\S\4S289jjr290S\S\4SjrSr
U=r$)�291DictLoaderi�z/A template loader that loads from a dictionary.�dictrTr!Nc�2>�[TU]"S0UD6 Xlgr�)r�rRr�)rOr�rTr�s   �rrR�DictLoader.__init__�s���
���"�6�"��	rr0r�c��U(a�URS5(dlURS5(dVURS5(d@[R"U5n[R"[R"X155nU$)Nr�r�)r��	posixpathr��normpathr�)rOr0r�r�s    rr��DictLoader.resolve_path�sd����*�*�3�/�/��*�*�3�/�/��O�O�C�(�(� �(�(��5�H��%�%�i�n�n�X�&D�E�D��rc�0�[URUXS9$)Nr�)r-r�r�s  rr��DictLoader._create_template�s����	�	�$��d�@�@r)r�rW)rrrrr�r
r�r	rRrr�r-r�rr�r�s@rr�r��sb���9��T�#�s�(�^��s��t��	��	�8�C�=�	�C�	�A�S�A�X�A�Arr�c�X�\rSrSrS\S4SjrSSjrS\\S\	\292S4SS4S	jrS293rg)�_Nodei�r!c��gr�rr�s r�294each_child�_Node.each_child�s��rNc��[5erWr��rOr{s  rrl�_Node.generate�r�rr1rx�_NamedBlockc�T�UR5HnURX5 M grW)r�rr)rOr1rx�childs    rrr�_Node.find_named_blocks�s#���_�_�&�E��#�#�F�9�'rr�r{rsr!N)
rrrrrr�rlrr2r
r�rrrrrrr�r��sD���H�W�-��$�:��z�*�:�:>�s�M�?Q�:R�:�	
�:rr�c�H�\rSrSrS\SSSS4SjrSSjrS\S	4S295jrSr	g)
rCirtr~�296_ChunkListr!Nc�*�XlX lSUlgro)rtr~�line)rOrtr~s   rrR�_File.__init__s�� �
��	���	rc�n�URSUR5 UR5 URSUR5 URSUR5 URR	U5 URSUR5 SSS5 g!,(df   g=f)Nzdef _tt_execute():�_tt_buffer = []�_tt_append = _tt_buffer.append�$return _tt_utf8('').join(_tt_buffer))�297write_liner��indentr~rlr�s  rrl�_File.generates{�����.��	�	�:�
�]�]�_����/����;����>��	�	�J��I�I���v�&����D�d�i�i�P�	�_�_�s�A0B&�&298B4r�c��UR4$rW�r~r�s rr��_File.each_child����	�	�|�r)r~r�rtr�)299rrrrr-rRrlrr�rrrrrCrCs3�������$��300Q��H�W�-�rrCc�J�\rSrSrS\\SS4SjrS301SjrS\S4Sjr	S	r302g)r�irr!Nc��XlgrW�r)rOrs  rrR�_ChunkList.__init__s���rc�L�URHnURU5 M grW)rrl)rOr{r�s   rrl�_ChunkList.generates���[�[�E��N�N�6�"�!rr�c��UR$rWr�r�s rr��_ChunkList.each_childs���{�{�rr�r�)rrrrrr�rRrlrr�rrrrr�r�s/���t�E�{��t��#��H�W�-�rr�c303�v�\rSrSrS\S\S\S\SS4304SjrS\	S	4S305jr306SSjrS\\
S
\\S4SS4SjrSrg)r�i#r0r~rtr�r!Nc�4�XlX lX0lX@lgrW)r0r~rtr�)rOr0r~rtr�s     rrR�_NamedBlock.__init__$s���	��	� �
��	rr�c��UR4$rWr�r�s rr��_NamedBlock.each_child*r�rc���URURnURURUR5 UR307R
U5 SSS5 g!,(df   g=frW)rxr0�includertr�r~rl)rOr{�blocks   rrl�_NamedBlock.generate-sJ���#�#�D�I�I�.��
�^�^�E�N�N�D�I�I�
6��J�J����'�7�
6�
6�s�A%�%308A3r1rxc�L�XUR'[RXU5 grW)r0r�rr)rOr1rxs   rrr�_NamedBlock.find_named_blocks2s ��#'�T�Y�Y��
����l�;r)r~r�r0rtr�)rrrrr�r�r-�intrRrr�rlrr2r
rrrrrrr�r�#sm���S��������QU���H�W�-��(�309<��z�*�<�:>�s�M�?Q�:R�<�	
�<rr�c�&�\rSrSrS\SS4SjrSrg)r�i9r0r!Nc��XlgrW�r0r�s  rrR�_ExtendsBlock.__init__:s���	rr)rrrrr�rRrrrrr�r�9s���S��T�rr�c�^�\rSrSrS\SSS\SS4SjrS	\\S310\	\\3114SS4SjrSSjrS
r
g)�
_IncludeBlocki>r0rPrBr�r!Nc�>�XlURUlX0lgrW)r0�
template_namer�)rOr0rPr�s    rrR�_IncludeBlock.__init__?s���	�#�[�[����	rr1rxc��UceURURUR5nURR	X5 grW)r�r0rrErr)rOr1rx�includeds    rrr�_IncludeBlock.find_named_blocksDs<���!�!�!��;�;�t�y�y�$�*<�*<�=���
�
�'�'��=rc�6�URceURRURUR5nUR	X R3125 URRRU5 SSS5 g!,(df   g=frW)	r1r�r0rr�r�rEr~rl)rOr{r	s   rrl�_IncludeBlock.generateKsf���}�}�(�(�(��=�=�%�%�d�i�i��1C�1C�D��
�^�^�H�i�i�
0��M�M���'�'��/�1�
0�
0�s�&B313�314 315B)r�r0rr�)rrrrr�r�rRrr2r
r�rrrlrrrrrr>sU���S��*;��3��4��316>��z�*�>�:>�s�K�?O�:P�>�	
�>�0rrc�L�\rSrSrS\S\S\SS4SjrS\S4S	jr	SS317jr318Srg)
�_ApplyBlockiR�methodr�r~r!Nc�(�XlX lX0lgrW)rr�r~)rOrr�r~s    rrR�_ApplyBlock.__init__Ss�����	��	rr�c��UR4$rWr�r�s rr��_ApplyBlock.each_childXr�rc��SUR-nU=RS-
slURSU-UR5 UR5 URSUR5 URSUR5 URRU5 URSUR5 SSS5 URSURSUS	3UR5 g!,(df   N<=f)319Nz_tt_apply%dr�z	def %s():r�r�r�z_tt_append(_tt_utf8(�(z()))))�
apply_counterr�r�r�r~rlr)rOr{�method_names   rrl�_ApplyBlock.generate[s���#�f�&:�&:�:������!�����+��3�T�Y�Y�?�
�]�]�_����/����;����>��	�	�J��I�I���v�&����D�d�i�i�P�	�320	���"�4�;�;�-�q��
�U�C�T�Y�Y�	321��_�s
�A0C:�:322D)r~r�rr��rrrrr�r�r�rRrr�rlrrrrrrRs9���s��#��U��t��323�H�W�-��324rrc�L�\rSrSrS\S\S\SS4SjrS\\4Sjr	SS	jr325S326rg)�
_ControlBlockii�	statementr�r~r!Nc�(�XlX lX0lgrW)rr�r~)rOrr�r~s    rrR�_ControlBlock.__init__js��"���	��	rc��UR4$rWr�r�s rr��_ControlBlock.each_childor�rc��URSUR-UR5 UR5 URRU5 URSUR5 SSS5 g!,(df   g=f)N�%s:�pass)r�rr�r�r~rlr�s  rrl�_ControlBlock.generatersX�����%�$�.�.�0�$�)�)�<�
�]�]�_��I�I���v�&����f�d�i�i�0��_�_�s�8A;�;327B	)r~r�rr�rrrrrris8���#��S����$��328�H�U�O��1rrc�4�\rSrSrS\S\SS4SjrS	SjrSrg)329�_IntermediateControlBlockizrr�r!Nc��XlX lgrW�rr��rOrr�s   rrR�"_IntermediateControlBlock.__init__{���"���	rc��URSUR5 URSUR-URUR5S-3305 g)Nr#r"r�)r�r�r�indent_sizer�s  rrl�"_IntermediateControlBlock.generatesD�����&�$�)�)�,����%�$�.�.�0�$�)�)�V�=O�=O�=Q�TU�=U�Vr�r�rr��	rrrrr�r�rRrlrrrrr&r&zs"���#��S��T��Wrr&c�4�\rSrSrS\S\SS4SjrS	SjrSrg)331�332_Statementi�rr�r!Nc��XlX lgrWr(r)s   rrR�_Statement.__init__�r+rc�P�URURUR5 grW)r�rr�r�s  rrl�_Statement.generate�s�����$�.�.�$�)�)�4rr/r�r0rrrr2r2�s!���#��S��T��5rr2c	�<�\rSrSrS333S\S\S\SS4SjjrSSjrS	r	g)�_Expressioni��334expressionr��rawr!Nc�(�XlX lX0lgrW�r9r�r:)rOr9r�r:s    rrR�_Expression.__init__�s��$���	��rc��URSUR-UR5 URSUR5 URSUR5 UR(dJURR335b3URSURR336-UR5 URSUR5 g)Nz_tt_tmp = %szEif isinstance(_tt_tmp, _tt_string_types): _tt_tmp = _tt_utf8(_tt_tmp)z&else: _tt_tmp = _tt_utf8(str(_tt_tmp))z_tt_tmp = _tt_utf8(%s(_tt_tmp))z_tt_append(_tt_tmp))r�r9r�r:�current_templater4r�s  rrl�_Expression.generate�s������.�4�?�?�:�D�I�I�F����V��I�I�	337�	���B�D�I�I�N��x�x�F�3�3�>�>�J�
���1�F�4K�4K�4V�4V�V��	�	�
�	���/����;rr<)Fr�)338rrrrr�r�r�rRrlrrrrr8r8�s(���3��c������339<rr8c�8^�\rSrSrS\S\SS4U4SjjrSrU=r$)�_Modulei�r9r�r!Nc�*>�[TU]SU-USS9 g)Nz_tt_modules.T�r:)r�rR)rOr9r�r�s   �rrR�_Module.__init__�s���
����*�4�d���Err)	rrrrr�r�rRrr�r�s@rrBrB�s'���F�3�F�c�F�d�F�FrrBc�8�\rSrSrS\S\S\SS4SjrS340SjrS	rg)�_Texti��valuer�r5r!Nc�(�XlX lX0lgrW)rHr�r5)rOrHr�r5s    rrR�_Text.__init__�s���341��	�$�rc���URnSU;a[URU5nU(a4URS[R342"U5-UR5 gg)Nz<pre>z_tt_append(%r))rHr+r5r�rrdr�)rOr{rHs   rrl�_Text.generate�sP���343�344���%��%�d�o�o�u�=�E�����.����U�1C�C�T�Y�Y�O�r)r�rHr5r�r0rrrrGrG�s)��%�c�%��%�#�%�$�%�345	PrrGc	�L�\rSrSrSrSS\S\\S\SS4SjjrS\4S	jr	S346r347g)r�i�z�Raised for template syntax errors.348 349``ParseError`` instances have ``filename`` and ``lineno`` attributes350indicating the position of the error.351 352.. versionchanged:: 4.3353   Added ``filename`` and ``lineno`` attributes.354N�message�filename�linenor!c�(�XlX lX0lgrW�rNrOrP)rOrNrOrPs    rrR�ParseError.__init__�s����!�
��rc�N�SURURUR4-$)Nz%s at %s:%drRr�s r�__str__�ParseError.__str__�s ������d�m�m�T�[�[�I�I�Ir)rOrPrNro)rrrrr�r�rr�rRrUrrrrr�r��sE���KL����&.�s�m��DG��	
��J��Jrr�c355��\rSrSrS\S\\\4S\\	S\356SS4357SjrS\4S	jr
SSjrS\358S
\SS3594SjrSS
\S\S\\SS4SjjrSrg)rsi�rErxr1r?r!Nc�^�XlX lX0lX@lSUl/UlSUlgro)rErxr1r?r�
include_stack�_indent)rOrErxr1r?s     rrR�_CodeWriter.__init__�s1���	�(���� 0����������rc��UR$rW�rZr�s rr-�_CodeWriter.indent_size�s���|�|�rrc�,^�"U4SjS5nU"5$)Nc�>>�\rSrSrSU4SjjrS\SS4U4SjjrSrg)	�$_CodeWriter.indent.<locals>.Indenteri�r!c�2>�T=RS-
slT$)Nr�r]�r9rOs �r�	__enter__�._CodeWriter.indent.<locals>.Indenter.__enter__�s�������!���r�argsNc�T>�TRS:�deT=RS-slg)Nrr�r]�r9rfrOs  �r�__exit__�-_CodeWriter.indent.<locals>.Indenter.__exit__�s#����|�|�a�'�'�'�����!�rr�r!rs�rrrrrdr	rirr�s�r�Indenterra�s ���
�
"�3�
"�4�
"�
"rrmr)rOrms` rr��_CodeWriter.indent�s���	"�	"��z�rrtr�c�^�TRRTRU45 UTl"U4SjS5nU"5$)Nc�>>�\rSrSrSU4SjjrS\SS4U4SjjrSrg)	�,_CodeWriter.include.<locals>.IncludeTemplatei�r!c�>�T$rWrrcs �rrd�6_CodeWriter.include.<locals>.IncludeTemplate.__enter__�s����rrfNc�J>�TRR5STlgro)rY�popr?rhs  �rri�5_CodeWriter.include.<locals>.IncludeTemplate.__exit__�s���(,�(:�(:�(>�(>�(@��(C��%r)r?rkrlr�s�r�IncludeTemplaterq�s$���
�
D�3�
D�4�
D�
Drrw)rY�appendr?)rOrtr�rws`   rr��_CodeWriter.include�sA������!�!�4�#8�#8�$�"?�@� (���	D�	D�� � r�line_numberr�c�^�UcURnSURRU4-nUR(aOURVVs/sHupVSURU4-PM nnnUSSR	[U55--
n[
SU-U-U-URS9 gs snnf)Nz	  # %s:%dz%s:%dz	 (via %s)z, z    )rE)rZr?r0rYr��reversed�printrE)rOr�rzr��line_comment�tmplrPrys        rr��_CodeWriter.write_line�s����>��\�\�F�"�d�&;�&;�&@�&@�+�%N�N�����DH�DV�DV��DV�.�4��4�9�9�f�-�-�DV�
��
�K�$�)�)�H�Y�4G�*H�H�H�L�
�f�v�o��$�|�3�$�)�)�D��	s�B))rZrr?rErYr1rx)r!rrW)rrrrrr
r�r�rr2r-rRr�r-r�r�r�rrrrrsrs�s���
��
��3��+�,�
���$�	
�360#�
�361�

��S��362�!��!��!�8H�!�DH�E��E�&)�E�3;�C�=�E�	
�E�Errsc	���\rSrSrS\S\S\SS4SjrSS\S	\S363\\S\4SjjrSS\\S\4S
jjr	S\4Sjr364S\4SjrS\\\
4S\4SjrS\4SjrS\SS4SjrSrg)rBi
r0r r5r!Nc�D�XlX lX0lSUlSUlg)Nr�r)r0r r5r��pos)rOr0r r5s    rrR�_TemplateReader.__init__s���	��	�$����	���r�needle�start�endc���US:�dU5eURnX$-
nUcURRX5nO'X4-
nX2:�deURRXU5nUS:waXT-nU$)Nr�����)r�r �find)rOr�r�r�r��indexs      rr��_TemplateReader.findsr����z� �5� �z��h�h��
����;��I�I�N�N�6�1�E��J�C��<��<��I�I�N�N�6�#�6�E��B�;��L�E��r�countc� �Uc"[UR5UR-365nURU-nU=RURR	SURU5-
slURURUnX lU$)Nr&)r�r r�r�r�)rOr��newpos�ss    r�consume�_TemplateReader.consume#sl���=���	�	�N�T�X�X�-�E����E�!���	�	�T�Y�Y�_�_�T�4�8�8�V�<�<�	��I�I�d�h�h��(�����rc�F�[UR5UR-366$rW)r�r r�r�s r�	remaining�_TemplateReader.remaining,s���4�9�9�~����(�(rc�"�UR5$rW)r�r�s r�__len__�_TemplateReader.__len__/s���~�~��r�keyc�\�[U[5(ag[U5nURU5up4nUc
URnOX0R-
nUbX@R-
nUR367[X4U5$US:aUR368U$UR369URU-$ro)r?�slicer��indicesr�r )rOr��sizer��stop�steps      r�__getitem__�_TemplateReader.__getitem__2s����c�5�!�!��t�9�D� #���D� 1��E���}��������!������� ���9�9�U�5��5�6�6�
�1�W��9�9�S�>�!��9�9�T�X�X��^�,�,rc�4�URURS$rW)r r�r�s rrU�_TemplateReader.__str__Bs���y�y�����$�$r�msgc�B�[XRUR5erW)r�r0r�)rOr�s  r�raise_parse_error�!_TemplateReader.raise_parse_errorEs����i�i����3�3r)r�r0r�r r5)rNrW)rrrrr�rRr�rr�r�r�r�r370r�r�rUr�rrrrrBrB
s����S���������3��s��X�c�]��c���X�c�]��c��)�3�)� �� �-�u�S�%�Z�0�-�S�-� %��%�4�S�4�T�4rrBrGc	���UR5nS[[[U5S-55-nSR[	U5VVs/sHup4X#S-U4-PM snn5$s snnf)Nz%%%dd  %%s371r�r7)�372splitlinesr��reprr��	enumerate)rG�lines�format�ir�s     rrLrLIs_���O�O��E�
�c�$�s�5�z�A�~�"6�7�
7�F�
�7�7�I�e�<L�M�<L�y��F�!�e�T�]�*�<L�M�N�N��Ms�
A*373rPrt�in_block�in_loopc�^
�[/5nSnURSU5nUS:XdUS-UR5:XaeU(aURSU-5 URR[
UR5URUR55 U$XS-S;aUS-
nM�US-UR5:aXS-S:XaXS-S:XaUS-
nM�US:�aJURU5nURR[
X`RUR55 URS5nURnUR5(aLUSS	:XaCURS5 URR[
XxUR55 GM�US374:Xa[URS5n	U	S:XaURS5 URU	5R5n375URS5 GMUS
:Xa�URS5n	U	S:XaURS5 URU	5R5n376URS5 U377(dURS5 URR[X�55 GM�US:XdU5eURS5n	U	S:XaURS5 URU	5R5n378URS5 U379(dURS5 U380RS5up�n
U
R5n
1SkS1S1S1S.nURU5nUbaU(dURUSUS35 X/;aURUSUS35 URR[X�55 GM�US:XaU(dURS5 U$US;Ga�US :XaGM�US!:XaEU
RS"5RS#5n
U
(dURS$5 [U
5nGOUS%;a$U
(dURS&5 [!X�5nO�US':XaEU
RS"5RS#5n
U
(dURS(5 [#X�U5nO�US):Xa$U
(dURS*5 [!X�5nOvUS+:Xa"U
R5nUS,:XaSnUUlGMUS-:Xa&U
R5n['US.5 UUl	GM;US/:Xa[X�SS09nOUS1:Xa[)X�5nURRW5 GM{US2;a�US3;a
[+XX�5nO US4:Xa[+XUS5nO[+XX�5nUS4:Xa%U
(dURS55 [-X�U5nO8US6:Xa&U
(dURS75 [/U
UX5nO[1X�U5nURRU5 GM5US8;aQU(d#URS9R3US:S;155 URR[!X�55 GM�URS<U-5 GM�)=NTr�{r�r�z Missing {%% end %%} block for %s)r��%�#��!z{#z#}zMissing end comment #}z{{z}}zMissing end expression }}zEmpty expressionz{%z%}zMissing end block %}zEmpty block tag ({% %})r%>�if�for�try�whiler�r�)�else�elif�except�finallyz	 outside z blockz block cannot be attached to r�zExtra {% end %} block)381�extendsr��set�import�from�commentr4r5r:�moduler�r��"�'zextends missing file path)r�r�zimport missing statementr�zinclude missing file pathr�zset missing statementr4�Noner5r7r:rDr�)�applyr�r�r�r�r�)r�r�r�zapply missing method namer�zblock missing name)�break�continuez{} outside {} blockr�r�zunknown operator: %r)r�r�r�r�rrxrGr�r�r5�stripr8�	partition�getr&r�r2rr4r+rBrDrr�rr�)rPrtr�r�r~�curly�cons�start_bracer�r��contents�operator�space�suffix�intermediate_blocks�allowed_parentsr��fnr�382block_bodys                    rrDrDOs)���b�>�D�383�����K�K��U�+�E���{�e�a�i�6�+;�+;�+=�=���,�,�:�X�E�����"�"��&�.�.�*�F�K�K��9J�9J�K�����a�i� ��7���384���385��	�F�,�,�.�.��1�9�%��,��1�9�%��,���386�����1�9��>�>�%�(�D��K�K���u�T�;�;��8I�8I�J�K��n�n�Q�'���{�{�������&��)�s�"2��N�N�1���K�K���u�[��8I�8I�J�K���$���+�+�d�#�C��b�y��(�(�)A�B��~�~�c�*�0�0�2�H��N�N�1����$���+�+�d�#�C��b�y��(�(�)D�E��~�~�c�*�0�0�2�H��N�N�1����(�(�);�<��K�K���{�8�:�;���d�"�/�K�/�"��k�k�$����"�9��$�$�%;�<��>�>�#�&�,�,�.�����q����$�$�%>�?�"*�"4�"4�S�"9���������2��F��g��w�	387��.�1�1�(�;���&���(�(�H�:�Y��>O�v�)V�W��.��(�(��j� =�h�Z�v�N��
�K�K���8��H�I����
���(�(�)@�A��K�
�388�389��9�$���9�$����c�*�0�0��5����,�,�-H�I�%�f�-���/�/���,�,�-G�H�"�8�2���Y�&����c�*�0�0��5����,�,�-H�I�%�f�d�;���U�"���,�,�-D�E�"�6�0���\�)��\�\�^����<��B�&(��#���\�)��|�|�~��!�$��+�$(��!���U�"�#�F�d�;���X�%���-���K�K���u�%��
�H�
H��+�+�#�F�h�I�390��W�$�$�F�h��E�391�#�F�h�H�392��7�"���,�,�-H�I�#�F�*�=���W�$���,�,�-A�B�#�F�J��G��%�h�j�A���K�K���u�%��
�.�
.���(�(�)�0�0��E�7�;K�L��
�K�K���z�(�9�:��
�$�$�%;�h�%F�G�r)NN):r�r_�iorri�os.pathr�r�r(r��tornador�tornado.logr�tornado.utilrrrrgr	r393rrr
rrr�
TYPE_CHECKINGrrr@rr=r�r+r-r2r�r�r�rCr�r�r�rrrr&r2r8rBrGr*r�rsrBrLrDrrr�<module>r�s��� u�n�����	����:�:�O�O�O�
�	���,�$��	�	�394���=�C�=�s�=�s�=�2I�I�X:$�:$�z�Z��8A��A�,:�:��E��$	��	�<�%�<�,�E��3950�E�0�(396�%�397�.1�E�1�"W��W�5��5�<�%�<�.F�k�F�398P�E�P�$J��J�.7E�7E�t94�94�xO�s�O�s�O�#�!�	FH��FH��FH��s�m�FH��c�]�	FH�399�FHr
codekingpro/portable-devtools · Team Ai