Current File : //proc/self/root/lib/python3/dist-packages/jinja2/__pycache__/compiler.cpython-312.pyc
�

��gU�� �dZddlZddlmZddlmZddlmZddl	m
Z
ddlmZ
ddlmZdd	lmZd
dlmZd
dlmZd
d
lmZd
dlmZd
dlmZd
dlmZd
dlmZd
dlmZd
dlmZd
dlmZd
dlm Z d
dl!m"Z"ejFr
ddl$Z%d
dl&m'Z'ejPdejRdejTf��Z+dddddd d!d"d#�Z,d$e+d%e+fd&�Z-d'e.d%ejRd(ej^d)gdffd*�Z0d'e.d%ejRd(ejbd)gdffd+�Z2			dFd,ejfd-d.d/ejhe.d0ejhe.d1ejhejjd2e6d3e6d%ejhe.fd4�Z7d5ejTd%e6fd6�Z8d7ejrejtd8ejre.d%ejve.fd9�Z<Gd:�d;�Z=Gd<�d)�Z>Gd=�d>e?�Z@Gd?�d@e"�ZAGdA�dBe"�ZBGdC�dDeC�ZDGdE�d(e"�ZEy)Gz0Compiles nodes from the parser into Python code.�N)�contextmanager)�update_wrapper)�StringIO)�chain)�	iskeyword)�escape)�Markup�)�nodes)�TemplateAssertionError)�Symbols)�VAR_LOAD_ALIAS)�VAR_LOAD_PARAMETER)�VAR_LOAD_RESOLVE)�VAR_LOAD_UNDEFINED)�EvalContext)�	Optimizer)�_PassArg)�concat)�NodeVisitor)�Environment�F.)�boundz==z!=�>z>=�<z<=�inznot in)�eq�ne�gt�gteq�lt�lteqr�notin�f�returnc
���dddtjdddtjdtjf
�fd�}t	tj
t|���S)	N�self�
CodeGenerator�node�frame�Frame�kwargsr%c����|j�S|jjs=|jj||j�}||k7r|j||�S�|||fi|��S�N)�	optimizer�eval_ctx�volatile�visit)r'r)r*r,�new_noder$s     ��1/usr/lib/python3/dist-packages/jinja2/compiler.py�new_funczoptimizeconst.<locals>.new_func,sb����>�>�%�e�n�n�.E�.E��~�~�+�+�D�%�.�.�A�H��4���z�z�(�E�2�2���t�U�-�f�-�-�)r�Expr�t�Anyr�castr)r$r5s` r4�
optimizeconstr;+sV���
.��
.�%*�Z�Z�
.�8?�
.�KL�5�5�
.�	
���
.��!�&�&��H�-�q�1�1r6�opr(r+c	�Z��tdddtjdtddf�fd��}|S)Nr'r(r)r*r%c���|jjrw�|jjvr_|jd��d��|j	|j
|�|jd�|j	|j|�n^|jd�|j	|j
|�|jd��d��|j	|j|�|jd�y)Nz environment.call_binop(context, �, �(� �))�environment�	sandboxed�intercepted_binops�writer2�left�right�r'r)r*r<s   �r4�visitorz_make_binop.<locals>.visitor<s����
���&�&��d�&�&�9�9�9��J�J�9�"��r�B�C��J�J�t�y�y�%�(��J�J�t���J�J�t�z�z�5�)��J�J�s�O��J�J�t�y�y�%�(��J�J��2�$�a�y�!��J�J�t�z�z�5�)��
�
�3�r6)r;r�BinExprr+�r<rJs` r4�_make_binoprM;s<�����o��U�]�]��5��T����"�Nr6c	�Z��tdddtjdtddf�fd��}|S)Nr'r(r)r*r%c�H��|jjrJ�|jjvr2|jd��d��|j	|j
|�n0|jd�z�|j	|j
|�|jd�y)Nzenvironment.call_unop(context, r?r@rB)rCrD�intercepted_unopsrFr2r)rIs   �r4rJz_make_unop.<locals>.visitorTs}���
���&�&��d�&�&�8�8�8��J�J�8���b�A�B��J�J�t�y�y�%�(��J�J�s�R�x� ��J�J�t�y�y�%�(��
�
�3�r6)r;r�	UnaryExprr+rLs` r4�
_make_unoprRQs>�����o��U�_�_��U��t�����Nr6r)rCr�name�filename�stream�
defer_init�	optimizedc���t|tj�std��|j	||||||�}|j|�|�|jj�Sy)z+Generate the python source for a node tree.z Can't compile non template nodesN)�
isinstancer�Template�	TypeError�code_generator_classr2rU�getvalue)r)rCrSrTrUrVrW�	generators        r4�generater_esf���d�E�N�N�+��:�;�;��0�0��T�8�V�Z���I��O�O�D��
�~����(�(�*�*�r6�valuec�T�|�|tus|turyt|�ttt
tttthvryt|�tttthvrtd�|D��St|�tur td�|j!�D��Sy)z)Does the node have a safe representation?Tc3�2K�|]}t|����y�wr.��
has_safe_repr)�.0�vs  r4�	<genexpr>z has_safe_repr.<locals>.<genexpr>�s����3��=��#�3�s�c3�RK�|]\}}t|�xrt|����!y�wr.rc�re�krfs   r4rgz has_safe_repr.<locals>.<genexpr>�s&����S�T�Q��=��#�8�
�a�(8�8�S�s�%'F)�NotImplemented�Ellipsis�type�bool�int�float�complex�range�strr	�tuple�list�set�	frozenset�all�dict�items�r`s r4rdrd}s����}���/�5�H�3D���E�{�t�S�%��%��f�E�E���E�{�u�d�C��3�3��3�U�3�3�3��E�{�d���S�U�[�[�]�S�S�S�r6r�namesc��t|�}	|D]}|j|��	|jS#t$rY|jSwxYw)z�Check if the names passed are accessed undeclared.  The return value
    is a set of all the undeclared names from the sequence of names found.
    )�UndeclaredNameVisitorr2�VisitorExit�
undeclared)rr|rJr)s    r4�find_undeclaredr��s\��$�E�*�G�
��	 �D��M�M�$��	 �������
������
�s�2�	A	�A	c�b�eZdZdejejejfddfd�Zy)�MacroRefr)r%Nc�<�||_d|_d|_d|_y�NF)r)�accesses_caller�accesses_kwargs�accesses_varargs�r'r)s  r4�__init__zMacroRef.__init__�s!����	�$���$��� %��r6)	�__name__�
__module__�__qualname__r8�Unionr�Macro�	CallBlockr��r6r4r�r��s+��&�Q�W�W�U�[�[�%�/�/�%A�B�&�t�&r6r�c	��eZdZdZ		ddedejddejeddfd�Zd
d�Z	dd	e
ddfd
�Zd
d�Ze	Z
y)r+z&Holds compile time information for us.Nr0�parent�levelr%c�V�||_||_|�'t|��|_d|_d|_d|_nOt|j|��|_|j|_|j
|_|j|_d|_d|_d|_	d|_
d|_y)N�r�F)r0r�r
�symbols�require_output_check�buffer�block�toplevel�	rootlevel�
loop_frame�block_frame�
soft_frame)r'r0r�r�s    r4r�zFrame.__init__�s���!��
�����>�"��/�D�L�).�D�%�,0�D�K�+/�D�J�#�6�>�>��?�D�L�(.�(C�(C�D�%� �-�-�D�K����D�J���
�
��� ��� ���
 ��r6c���tj|j�}|jj	|j�|j
j
�|_|S)z!Create a copy of the current one.)�object�__new__�	__class__�__dict__�updater��copy�r'�rvs  r4r�z
Frame.copy�sC��
�^�^�D�N�N�
+��
�����4�=�=�)��\�\�&�&�(��
��	r6�isolatedc��|r.t|j|jjdz��St|j|�S)zReturn an inner frame.r
r�)r+r0r�r�)r'r�s  r4�innerzFrame.inner�s6�������d�l�l�.@�.@�1�.D�E�E��T�]�]�D�)�)r6c�B�|j�}d|_d|_|S)a&Return a soft frame.  A soft frame may not be modified as
        standalone thing as it shares the resources with the frame it
        was created of, but it's not a rootlevel frame any longer.

        This is only used to implement if-statements and conditional
        expressions.
        FT)r�r�r�r�s  r4�softz
Frame.soft�s"���Y�Y�[�������
��	r6)NN)r%r+�F)r�r�r��__doc__rr8�Optionalror�r�rnr�r��__copy__r�r6r4r+r+�sn��0�
'+�!%�	1 ��1 ��
�
�7�#�1 ��z�z�#��	1 �

�1 �f�*�d�*�w�*���Hr6c��eZdZdZy)rz?Exception used by the `UndeclaredNameVisitor` to signal a stop.N�r�r�r�r�r�r6r4rr�s��Ir6rc��eZdZdZd	d�Zdejddfd�Zdejddfd�Z	dejddfd�Zy)
�DependencyFinderVisitorz.A visitor that collects filter and test calls.r%Nc�@�t�|_t�|_yr.)rv�filters�tests�r's r4r�z DependencyFinderVisitor.__init__�s��#&�5���!$���
r6r)c�p�|j|�|jj|j�yr.)�
generic_visitr��addrSr�s  r4�visit_Filterz$DependencyFinderVisitor.visit_Filters&�����4� ���������#r6c�p�|j|�|jj|j�yr.)r�r�r�rSr�s  r4�
visit_Testz"DependencyFinderVisitor.visit_Tests$�����4� ��
�
���t�y�y�!r6c��y)zStop visiting at blocks.Nr�r�s  r4�visit_Blockz#DependencyFinderVisitor.visit_Block��r6�r%N)r�r�r�r�r�r�Filterr��Testr��Blockr�r�r6r4r�r��sO��8�'�$����$�$�$�"�u�z�z�"�d�"�'����'��'r6r�c��eZdZdZdej
eddfd�Zdejddfd�Z
dejddfd�Zy)	r~z�A visitor that checks if a name is accessed without being
    declared.  This is different from the frame visitor as it will
    not stop at closure frames.
    r|r%Nc�B�t|�|_t�|_yr.)rvr|r�)r'r|s  r4r�zUndeclaredNameVisitor.__init__s����Z��
�&)�e��r6r)c�.�|jdk(ra|j|jvrI|jj	|j�|j|jk(r
t��y|jj
|j�y)N�load)�ctxrSr|r�r�r�discardr�s  r4�
visit_Namez UndeclaredNameVisitor.visit_Namesh���8�8�v��$�)�)�t�z�z�"9��O�O����	�	�*����$�*�*�,�!�m�#�-�
�J�J���t�y�y�)r6c��y)zStop visiting a blocks.Nr�r�s  r4r�z!UndeclaredNameVisitor.visit_Block!r�r6)
r�r�r�r�r8�Iterablersr�r�Namer�r�r�r�r6r4r~r~sP���
,�a�j�j��o�,�$�,�*�u�z�z�*�d�*�&����&��&r6r~c��eZdZdZy)�CompilerExitz�Raised if the compiler encountered a situation where it just
    doesn't make sense to further process the code.  Any block that
    raises such an exception is not further processed.
    Nr�r�r6r4r�r�%s��r6r�c�Z�eZdZU			d�dddejedejedejejdeded	dfd
�Ze	d	efd��Z
ded
ed	dfd�Zd	efd�Z
ded	dfd�Z	d�deded	dfd�Zd�d�Zd�ded	dfd�Zd�dedejej(d	dfd�Zded	dfd�Z	d�dededejej(d	dfd�Zdej0ej(ded	dfd�Zded	dfd �Z	d�dedejej(d!ed	dfd"�Zd�dejej(d!ed	dfd#�Z	d�dej:ej<ej>ej@fded$ejejBeejDfd	dfd%�Z#dej0ej(d	dfd&�Z$ded	dfd'�Z%d�ded(ed	dfd)�Z&d�d*ed+ed	efd,�Z'ded	efd-�Z(dej:ejRejTfded	ejVee,ffd.�Z-d/e,ded	dfd0�Z.dej(d	efd1�Z/ded	efd2�Z0d�d3�Z1ded	dfd4�Z2d�d5�Z3d6ed	dfd7�Z4d6ed	dfd8�Z5d�d9�Z6d	efd:�Z7d	efd;�Z8ded	efd<�Z9d6ed	efd=�Z:d�d>�Z;ded	dfd?�Z<	d�dejzdejed	dfd@�Z>dej~ded	dfdA�Z@dej�ded	dfdB�ZBdej�ded	dfdC�ZDdej:ej�ej�fded	dfdD�ZGdej�ded	dfdE�ZHdej�ded	dfdF�ZIdej�ded	dfdG�ZKdej�ded	dfdH�ZMdejRded	dfdI�ZNdejTded	dfdJ�ZOdej�ded	dfdK�ZQdej�ded	dfdL�ZSdej�ded	dfdM�ZUGdN�dOej��ZWeXdPejDd	ejDfdQ��ZYdZZejeWe[dR<d	eWfdS�Z\dTej0ejDd	efdU�Z]dej�dedVeWd	efdW�Z_dej�dedVeWd	dfdX�Z`dej�dedVeWd	dfdY�Zadej�ded	dfdZ�Zcdej�ded	dfd[�Zedej�ded	dfd\�Zgdej�ded	dfd]�Zidej�ded	dfd^�Zkdej�ded	dfd_�Zmdej�ded	dfd`�ZodejVded	dfda�Zpdej�ded	dfdb�Zrdej�ded	dfdc�Zteudd�Zveude�Zweudf�Zxeudg�Zyeudh�Zzeudi�Z{eudj�Z|eudk�Z}eudl�Z~edd�Z�ede�Z�edm�Z�e�de�jded	dfdn��Z�e�de�jded	dfdo��Z�de�jded	dfdp�Z�e�de�jded	dfdq��Z�e�de�jded	dfdr��Z�de�jded	dfds�Z�e�dej:ej>ej@fdedted	e�j"dfdu��Z�e�dej>ded	dfdv��Z�e�dej@ded	dfdw��Z�e�de�j*ded	dfdx��Z�e�	d�dej<dedyed	dfdz��Z�de�j0ded	dfd{�Z�de�j4ded	dfd|�Z�de�j8ded	dfd}�Z�de�j<ded	dfd~�Z�de�j@ded	dfd�Z�de�jDded	dfd��Z�de�jHded	dfd��Z�de�jLded	dfd��Z�de�jPded	dfd��Z�de�jTded	dfd��Z�de�jXded	dfd��Z�de�j\ded	dfd��Z�de�j`ded	dfd��Z�de�jdded	dfd��Z�de�jhded	dfd��Z�y)�r(NrCrrSrTrUrVrWr%c��|�
t�}||_||_||_||_d|_||_d|_|rt|�|_i|_	i|_
d|_d|_d|_
i|_i|_g|_d|_d|_d|_d|_d|_d|_g|_g|_dg|_y)NFrr
T�context)rrCrSrTrU�created_block_contextrVr/r�import_aliases�blocks�extends_so_far�has_known_extends�code_linenor�r��
debug_info�_write_debug_info�
_new_lines�
_last_line�_first_write�_last_identifier�_indentation�
_assign_stack�_param_def_block�_context_reference_stack)r'rCrSrTrUrVrWs       r4r�zCodeGenerator.__init__-s����>��Z�F�&�����	� ��
����%*��"�$���04����&�{�3�D�N�13���13��� ���
"'������(*��
�)+���68���26���������!���!"������24���57���*3���%r6c��|jduSr.)r/r�s r4rWzCodeGenerator.optimizedvs���~�~�T�)�)r6�msg�linenozte.NoReturnc�F�t|||j|j��)z*Fail with a :exc:`TemplateAssertionError`.)rrSrT)r'r�r�s   r4�failzCodeGenerator.fail|s��$�S�&�$�)�)�T�]�]�K�Kr6c�J�|xjdz
c_d|j��S)zGet a new unique identifier.r
�t_)r�r�s r4�temporary_identifierz"CodeGenerator.temporary_identifier�s'������"���D�)�)�*�+�+r6r*c�j�|j�|_|j|j�d��y)z7Enable buffering for the frame from that point onwards.z = []N)r�r��	writeline�r'r*s  r4r�zCodeGenerator.buffer�s)���0�0�2������%�,�,��u�-�.r6�force_unescapedc� �|s�|jjr�|jd�|j�|jd|j�d��|j�|jd�|j�|jd|j�d��|j�y|jjr |jd|j�d��y|jd|j�d��y)z(Return the buffer contents of the frame.zif context.eval_ctx.autoescape:zreturn Markup(concat(�))�else:zreturn concat(rBN)r0r1r��indentr��outdent�
autoescape)r'r*r�s   r4�return_buffer_contentsz$CodeGenerator.return_buffer_contents�s�����~�~�&�&����@�A����
����!6�u�|�|�n�B�G�H��������w�'����
��������~�Q�?�@���������*�*����!6�u�|�|�n�B�G�H���������~�Q�7�8r6c�.�|xjdz
c_y)zIndent by one.r
N�r�r�s r4r�zCodeGenerator.indent�s�����Q��r6�stepc�.�|xj|zc_y)zOutdent by step.Nr�)r'r�s  r4r�zCodeGenerator.outdent�s�����T�!�r6r)c��|j�|jd|�y|j|j�d�|�y)z%Yield or write into the frame buffer.N�yield �.append()r�r�)r'r*r)s   r4�start_writezCodeGenerator.start_write�s3���<�<���N�N�8�T�*��N�N�e�l�l�^�8�4�d�;r6c�@�|j�|jd�yy)z1End the writing process started by `start_write`.NrB)r�rFr�s  r4�	end_writezCodeGenerator.end_write�s���<�<�#��J�J�s�O�$r6�sc�l�|j||�|j|�|j|�y)z4Simple shortcut for start_write + write + end_write.N)rrFr)r'rr*r)s    r4�simple_writezCodeGenerator.simple_write�s+��	
�����%��
�
�1�
����u�r6rc�x�	|jd�|D]}|j||��y#t$rYywxYw)z�Visit a list of nodes as block in a frame.  If the current frame
        is no buffer a dummy ``if 0: yield None`` is written automatically.
        �passN)r�r2r�)r'rr*r)s    r4�
blockvisitzCodeGenerator.blockvisit�sB��	��N�N�6�"��
(���
�
�4��'�
(���	��	�s�*-�	9�9�xc���|jr�|js�|jjd|jz�|xj|jz
c_|j
�8|jj|j
|jf�d|_d|_|jjd|jz�d|_|jj|�y)z&Write a string into the output stream.�
NFz    r)	r�r�rUrFr�r�r��appendr�)r'r	s  r4rFzCodeGenerator.write�s����?�?��$�$����!�!�$����"8�9�� � �D�O�O�3� ��)�)�5��O�O�*�*�D�,B�,B�D�DT�DT�+U�V�-1�D�*� %�D���K�K���f�t�'8�'8�8�9��D�O������!�r6�extrac�J�|j||�|j|�y)z!Combination of newline and write.N)�newlinerF)r'r	r)r
s    r4r�zCodeGenerator.writeline�s��	
���T�5�!��
�
�1�
r6c��t|jd|z�|_|�=|j|jk7r#|j|_|j|_yyy)z/Add one or more newlines before the next write.r
N)�maxr�r�r�r�)r'r)r
s   r4rzCodeGenerator.newline�sL���d�o�o�q�5�y�9��������t��� >�%)�[�[�D�"�"�k�k�D�O�!?�r6�extra_kwargsc��td�td�|jD�|xsd�D��}|jD]%}|j	d�|j||��'|se|jD]%}|j	d�|j||��'|�/|j
�D]\}}|j	d|�d|����|jr-|j	d�|j|j|�|�r|j�|j	d�n|j	d	�|jD]M}|j	|j�d
��|j|j|�|j	d��O|�/|j
�D]\}}|j	|�d
|�d���|j�?|j	d�|j|j|�|j	d�y|j	d
�y|j�.|j	d�|j|j|�yy)a+Writes a function call to the stream for the current node.
        A leading comma is added automatically.  The extra keyword
        arguments may not include python keywords otherwise a syntax
        error could occur.  The extra keyword arguments should be given
        as python dict.
        c3�bK�|]'}ttjt|�����)y�wr.)�is_python_keywordr8r:rs)rerjs  r4rgz*CodeGenerator.signature.<locals>.<genexpr>�s'����
��
�a�f�f�S�!�n�-�
�s�-/c3�4K�|]}|j���y�wr.)�key�rer	s  r4rgz*CodeGenerator.signature.<locals>.<genexpr>�s����7�a�A�E�E�7���r�r?N�=z, *z
, **dict({z, **{�: z}, **rB�}z, **)�anyrr,�argsrFr2rz�dyn_args�
dyn_kwargsrr`)	r'r)r*r�kwarg_workaround�arg�kwargrr`s	         r4�	signaturezCodeGenerator.signature�s
���
��7�4�;�;�7��9K��L�
�
��
�9�9�	#�C��J�J�t���J�J�s�E�"�	#� ����
)���
�
�4� ��
�
�5�%�(�
)��'�".�"4�"4�"6�3�J�C���J�J��C�5��%��1�2�3��=�=��J�J�u���J�J�t�}�}�e�,�����*��
�
�<�(��
�
�7�#����
!���
�
�e�i�i�]�"�-�.��
�
�5�;�;��.��
�
�4� �
!��'�".�"4�"4�"6�6�J�C���J�J�#���5�'��4�5�6����*��
�
�7�#��
�
�4�?�?�E�2��
�
�3���
�
�3��
�_�_�
(��J�J�v���J�J�t����.�)r6c
���t�}|D]}|j|��|j|jdf|j|jdffD�]\}}}t	|�D]�}||vr|j�||<|j
d�|j�|j
||�d|�d|�d��|j�|j
d�|j�|j
d�|j
d	||�d
��|j�|j
d|dd
�d|�d��|j�|j�����y)a�Find all filter and test names used in the template and
        assign them to variables in the compiled namespace. Checking
        that the names are registered with the environment is done when
        compiling the Filter and Test nodes. If the node is in an If or
        CondExpr node, the check is done at runtime instead.

        .. versionchanged:: 3.0
            Filters and tests in If and CondExpr nodes are checked at
            runtime instead of compile time.
        r�r��try:z = environment.�[�]zexcept KeyError:z
@internalcode�def z
(*unused):zraise TemplateRuntimeError("No N���� named z	 found."))	r�r2r�r��sortedr�r�r�r�)r'rrJr)�id_mapr|�
dependencyrSs        r4�pull_dependencieszCodeGenerator.pull_dependenciess]��*�+���	 �D��M�M�$��	 �+/�,�,�����)S��J�J��M�M��V
�*
�	�%�F�E�:�
�u�
�
���v�%�#'�#<�#<�#>�F�4�L����v�&����
����&��,���z�l�!�D�8�ST�U�V��������1�2����
�����/�����f�T�l�^�:�>�?����
����5�j��"�o�5F��d�X�Y�0����������)
�	r6c	��g}|jjj�D]�\}\}}|tk(r�|tk(r)|j|�d|j
��d|�d���E|tk(r|j|�d|����e|tk(r|j|���td��|r$|jdj|��d��yy)N� = r@rBzunknown load instruction�
 = missing)r��loadsrzrrr��get_resolve_funcrrr�NotImplementedError�join)r'r*�undefs�target�action�params      r4�enter_framezCodeGenerator.enter_frameEs�����',�}�}�':�':�'@�'@�'B�
	F�#�F�O�V�U��+�+���+�+����&���T�-B�-B�-D�,E�Q�u�i�q�Q�R��>�)����&���U�G�4�5��-�-��
�
�f�%�)�*D�E�E�
	F���N�N�e�j�j��0�1��<�=�r6�with_python_scopec��|sUg}|jjD]}|j|��|r$|jdj	|��d��yyy)Nr1r2)r�r3rr�r6)r'r*r<r7r8s     r4�leave_framezCodeGenerator.leave_frameUsY�� ��F��-�-�-�-�
&���
�
�f�%�
&�����%�*�*�V�"4�!5�Z�@�A��	!r6�async_value�
sync_valuec�6�|jjr|S|Sr.)rC�is_async)r'r?r@s   r4�choose_asynczCodeGenerator.choose_async]s��"�.�.�7�7�{�G�Z�Gr6c�,�|j��d|��S)Nr))rC)r'rSs  r4�funczCodeGenerator.func`s���#�#�%�&�d�4�&�1�1r6c
���|j�}|jj|�t|�}d}t	�}g}t|j�D]s\}}|jdk(r|}|jdvr|j|j�|j|jj|j���ut|jd�}	d|	vrZ|�'	|j|t|j�z
n*|j|jj%d��d|_d|	vr5d|vr1|j|jj%d��d|_d|	vr5d|vr1|j|jj%d��d|_d	|_|jj|�|j/|j1d
��ddj3|��d
�|�|j5�|j7|�|j9|�|j;|�t|j�D]�\}}|jj|j�}
|j/d|
�d��|j5�	|j|t|j�z
}|j/|
�d��|j=||�|j?|
�|jA���|jC�|jE|j|�|jG|d��|jI|d��|jA�||fS#t$r |j!d|j"�Y��vwxYw#t$r1|j/|
�d|j�d|j�d��Y��wxYw)z/Dump the function def of a macro or call block.N�caller)r,�varargs)rGr,rHzhWhen defining macros or call blocks the special "caller" argument must be omitted or be given a default.Tr,rHF�macror@r?�):�if � is missing:r1z = undefined("parameter z was not provided", name=rB)r��r<)%r�r��analyze_noder�rv�	enumeraterrSr�r�refr��body�defaults�len�
IndexErrorr�r��declare_parameterr�r�r�r�r�rEr6r�r�r;�push_parameter_definitionsr2�mark_parameter_storedr��pop_parameter_definitionsrr�r>)r'r)r*�	macro_ref�explicit_caller�skip_special_paramsr�idxr"r�rP�defaults            r4�
macro_bodyzCodeGenerator.macro_bodycsb�����
��
�
�
�"�"�4�(��T�N�	���!�e����!�$�)�)�,�	5�H�C���x�x�8�#�"%���x�x�0�0�#�'�'����1��K�K��
�
�)�)�#�(�(�3�4�	5�%�T�Y�Y�0O�P�
��z�!��*���M�M�/�C��	�	�N�"B�C����E�M�M�;�;�H�E�F�(,�I�%��z�!�h�6I�&I��K�K��
�
�7�7��A�B�(,�I�%��
�"�y�8K�'K��K�K��
�
�7�7�	�B�C�)-�I�&�&+��"�
�
�
�"�"�4�(����$�)�)�G�,�-�Q�t�y�y���.?�r�B�D�I����
����E��������'�'��.�!�$�)�)�,�	�H�C���-�-�#�#�C�H�H�-�C��N�N�S���\�2�3��K�K�M�	
+��-�-��c�$�)�)�n�(<�=�����#��c�{�+��
�
�7�E�*��&�&�s�+��L�L�N�	� 	
�&�&�(�����	�	�5�)��#�#�E�4�#�@�����$��7������i����e"���I�I�1����	���B�
�����e�3�C�H�H�<�@� �X�X�L��+��
�s$�-%N�7%N7�%N4�3N4�77O1�0O1rYc
�V�djd�|jjD��}t|jdd�}t	|jj�dk(r|dz
}|jd|�d|�d	|j�d|j�d|j�d
��y)z<Dump the macro definition for the def created by macro_body.r?c3�FK�|]}t|j����y�wr.)�reprrSrs  r4rgz*CodeGenerator.macro_def.<locals>.<genexpr>�s����H�q�d�1�6�6�l�H�s�!rSNr
�,zMacro(environment, macro, z, (z), z, context.eval_ctx.autoescape))	r6r)r�getattrrSrFr�r�r�)r'rYr*�	arg_tuplerSs     r4�	macro_defzCodeGenerator.macro_def�s����I�I�H�I�N�N�4G�4G�H�H�	��y�~�~�v�t�4���y�~�~�"�"�#�q�(����I��
�
�(����I�;�?��)�)�,�B�y�/I�/I�.L�M��)�)�,�,J�
L�	
r6c�^�d|j��}|j�|�d|j��}|S)z.Return a human readable position for the node.zline � in )r�rS)r'r)r�s   r4�positionzCodeGenerator.position�s5���T�[�[�M�
"���9�9� ��4�t�D�I�I�=�)�B��	r6c��djd�|jj�j�D��}d|�d�S)Nr?c3�0K�|]\}}|�d|�����y�w�rNr�)rerSr8s   r4rgz3CodeGenerator.dump_local_context.<locals>.<genexpr>�s'����
���f��h�b���!�
����{r)r6r��dump_storesrz)r'r*�items_kvs   r4�dump_local_contextz CodeGenerator.dump_local_context�sD���9�9�
� %�
�
� 9� 9� ;� A� A� C�
�
���H�:�R� � r6c��|jd�|jd�|jd�|jd�|jd�y)z�Writes a common preamble that is used by root and block functions.
        Primarily this sets up common local helpers and enforces a generator
        through a dead branch.
        z$resolve = context.resolve_or_missingz!undefined = environment.undefinedzconcat = environment.concatzcond_expr_undefined = Undefinedzif 0: yield NoneN�r�r�s r4�
write_commonszCodeGenerator.write_commons�sG��
	
���=�>����:�;����4�5�	
���8�9����)�*r6c�j�|jj|jj��y)aQPushes all parameter targets from the given frame into a local
        stack that permits tracking of yet to be assigned parameters.  In
        particular this enables the optimization from `visit_Name` to skip
        undefined expressions for parameters in macros as macros can reference
        otherwise unbound parameters.
        N)r�rr��dump_param_targetsr�s  r4rVz(CodeGenerator.push_parameter_definitions�s%��	
���$�$�U�]�]�%E�%E�%G�Hr6c�8�|jj�y)z+Pops the current parameter definitions set.N)r��popr�s r4rXz'CodeGenerator.pop_parameter_definitions�s�����!�!�#r6r8c�Z�|jr|jdj|�yy)z�Marks a parameter in the current parameter definitions as stored.
        This will skip the enforced undefined checks.
        r*N)r�r��r'r8s  r4rWz#CodeGenerator.mark_parameter_stored�s+��� � ��!�!�"�%�-�-�f�5�!r6c�:�|jj|�yr.)r�rrys  r4�push_context_referencez$CodeGenerator.push_context_reference�s���%�%�,�,�V�4r6c�8�|jj�yr.)r�rwr�s r4�pop_context_referencez#CodeGenerator.pop_context_reference�s���%�%�)�)�+r6c� �|jdS)Nr*�r�r�s r4�get_context_refzCodeGenerator.get_context_ref�s���,�,�R�0�0r6c�6�|jd}|dk(ry|�d�S)Nr*r��resolvez.resolverrys  r4r4zCodeGenerator.get_resolve_func�s*���.�.�r�2���Y������"�"r6c�L�|j��d|j|��d�S)Nz	.derived(rB)r�rpr�s  r4�derive_contextzCodeGenerator.derive_contexts,���&�&�(�)��4�3J�3J�5�3Q�2R�RS�T�Tr6c�>�|jsy||jdvS)z4Checks if a given target is an undeclared parameter.Fr*)r�rys  r4�parameter_is_undeclaredz%CodeGenerator.parameter_is_undeclareds$���$�$����.�.�r�2�2�2r6c�J�|jjt��y)z+Pushes a new layer for assignment tracking.N)r�rrvr�s r4�push_assign_trackingz"CodeGenerator.push_assign_tracking	s�����!�!�#�%�(r6c�T�|jj�}|js|js|jr|sy|D�cgc]
}|dddk7s�|��}}t|�dk(r�t
t|��}|jj|�}|jr|jd|�d|���y|jr|jd|�d|���y|jd|�d|���n�|jr|jd�n/|jr|jd	�n|jd
�t|�D]I\}}|r|jd�|jj|�}|j|�d|����K|jd
�|jsl|js_|r\t|�dk(r|jd|d�d��ydjtt|��}|jd|�d��yyyycc}w)zoPops the topmost level for assignment tracking and updates the
        context variables if necessary.
        Nr
�_z_loop_vars[�] = z_block_vars[�
context.vars[z_loop_vars.update({z_block_vars.update({�context.vars.update({r?r�})�context.exported_vars.add(rrBzcontext.exported_vars.update((r�)r�rwr�r�r�rS�next�iterr�rPr�rOrFr6�mapra)	r'r*�varsr	�public_namesrSrPr\�	names_strs	         r4�pop_assign_trackingz!CodeGenerator.pop_assign_tracking
s����!�!�%�%�'���!�!��$�$��N�N���#'�8�a�1�R�a�5�C�<��8��8��t�9��>���T�
�#�D��-�-�#�#�D�)�C��������T�H�D���>�?��� � �����d�X�T�#��?�@���N�N�]�4�(�$�s�e�<�=�������4�5��"�"����5�6����6�7�&�t�_�
/�	��T���J�J�t�$��m�m�'�'��-���
�
�d�X�R��u�-�.�	
/�

�J�J�t��� � ��)9�)9�l��<� �A�%����!;�L��O�;N�a�P�Q� �I�I�c�$��&=�>�	����!?�	�{�"�M�N�?K�)9� ��19s�
H%�H%c	�l�|�Jd��t|j|j�}ddlm}m}|jjrt||z�}nt|�}|jddj|�z�|jrdnd}|jtj�du}|jtj�D]]}	|	j|j vr*|j#d|	j�d	�|	j$�|	|j |	j<�_|jtj&�D]�}
|
j(|j*vs�|
j(}|j-�x|j*|<}d
|vr0|j/d
d�\}
}|jd|
�d|�d
|����{|jd|�d
|�����|jd|j���|j|j1d��d|�d�d��|j3�|j5�t7|�}dt9|j:d�vr/|j<j?d�}|j|�d��|j<jA|�dx|_!|_"|xr
|jF|_$|r|jd�|jK|�|jM|j:�|jO|j:|�|jQ|d��|jS�|r�|jFs!|j3�|jd�|j3�|jjs|jd�nB|jd�|j3�|jd�|jS�|jSd|jFz�|j jU�D�]�\}}	|j|j1d|z��d|�d�|	d�|j3�|j5�t7|�}d|_+t9|	j:d�}d|vr/|j<j?d�}|j|�d��d |vr5|j<j?d �}|j|�d!|�d"|�d#��|j<jA|	�||_,|jd$�|jK|�|jM|	j:�|jO|	j:|�|jQ|d��|jS����djd%�|j D��}|jd&|�d'�d��d(jd)�|jZD��}|jd*|���y)+Nzno root frame allowedr
)�exported�async_exportedzfrom jinja2.runtime import r?�z, environment=environmentzblock z defined twice�.zfrom z import z as zimport zname = �rootz(context, missing=missingrJ)r
r'r�z = TemplateReference(context)Tzparent_template = NonerM�if parent_template is not None:z4yield from parent_template.root_render_func(context)z=async for event in parent_template.root_render_func(context):zyield event�block_)r'�superr�z = context.super(z, block_rBz_block_vars = {}c3�*K�|]}|�d|�����
y�w)z: block_Nr�rs  r4rgz/CodeGenerator.visit_Template.<locals>.<genexpr>�s����!K�!�Q�E��!��"5�!K�s�z
blocks = {r�&c3�0K�|]\}}|�d|�����y�w)rNr�ris   r4rgz/CodeGenerator.visit_Template.<locals>.<genexpr>�s����G�t�q�!�1�#�Q�q�c�
�G�rlz
debug_info = ).rrCrS�runtimer�r�rBr,r�r6rV�findr�Extends�find_allr�r�r�r��ImportedName�
importnamer�r��rsplitrEr�rsr+r�rQr�rUrNr�r�r�r�r;r/rr>r�rzr�r�r�)r'r)r*r0r�r��exported_names�envenv�have_extendsr��import_�imp�alias�module�objrPrSr�r��
blocks_kv_str�debug_kv_strs                     r4�visit_TemplatezCodeGenerator.visit_Template:sH���}�5�5�5�}��t�/�/����;��5����$�$�#�H�~�$=�>�N�#�H�-�N����4�t�y�y��7P�P�Q�����,G���y�y����/�t�;���]�]�5�;�;�/�	,�E��z�z�T�[�[�(��	�	�F�5�:�:�.��?����N�&+�D�K�K��
�
�#�	,��}�}�U�%7�%7�8�	?�G��!�!��)<�)<�<��(�(��37�3L�3L�3N�N��#�#�C�(�5��#�:�"%�*�*�S�!�"4�K�F�C��N�N�U�6�(�(�3�%�t�E�7�#K�L��N�N�W�S�E��e�W�#=�>�	?�	
�������
�.�/�	
����y�y�� �!�!:�6�(�"�E�Q�	�	
�	
���
������h����_�T�Y�Y�	�:�:��-�-�1�1�&�9�C��N�N�c�U�"?�@�A�
�
�
�"�"�4�(�+/�/�����%1�%P�$�:P�:P�6P��"���N�N�3�4���������t�y�y�)�����	�	�5�)�����$��7�������)�)����
����@�A��K�K�M��#�#�,�,����U�V����S�����
����}�-������L�L��$�"8�"8�8�9�:� �;�;�,�,�.�	�K�D�%��N�N��9�9�X��_�-�.�.G��x�r�R���
�

�K�K�M���� � ��/�K�&*�K�#�(����5F�G�J���#�!�)�)�;�;�F�C�����#��&C�D�E��*�$�!�)�)�;�;�G�D�����#��&7��x�x��v�Q�O�P����,�,�U�3� $�K���N�N�-�.����[�)��"�"�5�:�:�.��O�O�E�J�J��4����[�D��A��L�L�N�7	�:�	�	�!K�t�{�{�!K�K�
�����]�O�2�6�a��@��x�x�G�t���G�G������|�&6�7�8r6c�P�d}|jrB|jry|jdkDr&|jd�|j	�|dz
}|j
r|j
|�}n|j�}|jr`|jd|j�d�|�|j	�|jd|j�d�|�|j�|jjs0|j�$|jd	|j�d
|�d�|�ne|j|j��d|j�d
|�d
�|�|j	�|jd|�|j�|j|�y)z.Call a block and register it for the template.rN�if parent_template is None:r
zif len(context.blocks[z]) <= 1:z+raise TemplateRuntimeError("Required block z not found")zyield from context.blocks[z][0](rBzfor event in context.blocks[rJ�event)r�r�r�r�r��scopedr�r��requiredrSr�rCrBr�rCr)r'r)r*r�r�s     r4r�zCodeGenerator.visit_Block�sl�����>�>��%�%���"�"�Q�&����<�=����
���
���;�;��)�)�%�0�G��*�*�,�G��=�=��N�N�3�D�I�I�=��I�4�P��K�K�M��N�N�=�d�i�i�]�,�W��
�
�L�L�N����(�(�U�\�\�-A��N�N�,�T�Y�Y�M��w�i�q�I�4�
�
�N�N��$�$�&�'�(#�#'�9�9�-�u�W�I�R�A��
�

�K�K�M����g�u�-��L�L�N����U�r6c��|js|jd|j�|jdkDrd|js!|jd�|j
�|jd�|jr
t��|j�|jd|�|j|j|�|jd|j�d��|jd�|j
�|jd	�|j�|jrd
|_|xjdz
c_y)
zCalls the extender.z,cannot use extend from a non top-level scoperr�z5raise TemplateRuntimeError("extended multiple times")z+parent_template = environment.get_template(r?rBz9for name, parent_block in parent_template.blocks.items():z8context.blocks.setdefault(name, []).append(parent_block)Tr
N)r�r�r�r�r�r�r�r�r�r2�templaterFrSr��r'r)r*s   r4�
visit_ExtendszCodeGenerator.visit_Extends�s���~�~��I�I�D�d�k�k�R�
����"��)�)����@�A����
��N�N�R�S��%�%�"�n�$��������D�d�K��
�
�4�=�=�%�(��
�
�R��	�	�}�A�&�'����R�S����
����Q�R�����
�?�?�%)�D�"�	
���q� �r6c��|jr!|jd�|j�d}t|jt
j�rTt|jjt�rd}nct|jjttf�r9d}n6t|jt
jt
jf�rd}|jd|�d�|�|j|j|�|jd|j�d��|jrs|j!�|jd	�|j�|jd
�|j!�|jd�|j�d}|j"r5|j|j%��d
|j'|��d��n;|j(j*r|jd�n|jd�d}|s2|j�|j-d|�|j!�|jr|j!�yy)zHandles includes.r&�get_or_select_template�get_template�select_templateztemplate = environment.r@r?rBzexcept TemplateNotFound:rr�FzUfor event in template.root_render_func(template.new_context(context.get_all(), True, z)):zGfor event in (await template._get_default_module_async())._body_stream:z6yield from template._get_default_module()._body_streamTr�N)�ignore_missingr�r�rYr�r�Constr`rsrtru�Tuple�Listr2rFrSr��with_contextrCrprCrBr)r'r)r*�	func_name�skip_event_yields     r4�
visit_IncludezCodeGenerator.visit_Includes�������N�N�6�"��K�K�M�,�	��d�m�m�U�[�[�1��$�-�-�-�-�s�3�*�	��D�M�M�/�/�%���?�-�	�
��
�
����U�Z�Z�'@�
A�)�I����0���1�=�t�D��
�
�4�=�=�%�(��
�
�R��	�	�}�A�&�'�����L�L�N��N�N�5�6��K�K�M��N�N�6�"��L�L�N��N�N�7�#��K�K�M� ������N�N��$�$�&�'�(��+�+�E�2�3�3�8�
�
�
�
�
&�
&��N�N�!�
�

�N�N�S�T�#����K�K�M����g�u�-��L�L�N�����L�L�N�r6c��|j|jd��d��|j|j|�|jd|j�d��|j
r;d|jd���}|j|�d|j
|��d��y|jd	|jd��d
��y)N�await zenvironment.get_template(r?z).�make_module�_asyncz(context.get_all(), True, rB�_get_default_modulez	(context))rFrCr2r�rSr�rp)r'r)r*�f_names    r4�_import_commonzCodeGenerator._import_common9s���	
�
�
�d�'�'��1�2�2K�L�M��
�
�4�=�=�%�(��
�
�R��	�	�}�B�'�(����"�4�#4�#4�X�#>�"?�@�F��J�J��(�4�T�5L�5L�U�5S�4T�TU�V�
�
�J�J�,�T�->�->�x�-H�,I��S�Tr6c�~�|j|jj|j��d�|�|jr|jd|j�d��|j
||�|jr<|jjd�s |jd|j�d��yyy)zVisit regular imports.r1r�r�r��context.exported_vars.discard(rBN)r�r�rPr8r�rFr��
startswithr�s   r4�visit_ImportzCodeGenerator.visit_ImportHs������%�-�-�+�+�D�K�K�8�9��=�t�D��>�>��J�J��t�{�{�o�T�:�;����D�%�(��>�>�$�+�+�"8�"8��"=��N�N�;�D�K�K�?�!�L�M�#>�>r6c	����|j|�|jd�|j|��g}g}|jD�]H}t	|t
�r|\}}n|}|j
�jj|��d|�d��|j
d�jj|��d��|j�|j|�jdd�jdd	�}d
|�d|��}|j
�jj|��d|�d
|�d��|j��js��|j|�|jd�r��8|j|���K|rst!|�dk(r6|d}|j
d|�d�jj|����n/dj#�fd�|D��}	|j
d|	�d��|r\t!|�dk(r|j
d|d�d��ydj#t%t&|��}
|j
d|
�d��yy)zVisit named imports.zincluded_template = z = getattr(included_template, z
, missing)rKrLrmz{{rz}}z9the template {included_template.__name__!r} (imported on z%) does not export the requested name z = undefined(fz, name=rBr�r
rr�r�r?c3�^�K�|]$}|�d�jj|������&y�wrk)r�rP)rerSr*s  �r4rgz1CodeGenerator.visit_FromImport.<locals>.<genexpr>}s1�����%�?C�t�h�b����!2�!2�4�!8� 9�:�%�s�*-r�r�r�z)context.exported_vars.difference_update((r�N)rrFr�r|rYrtr�r�rPr�rh�replacer�r�rr�rSr6r�ra)r'r)r*�	var_names�discarded_namesrSr�rh�message�names_kvr�s  `        r4�visit_FromImportzCodeGenerator.visit_FromImportSsT������T���
�
�)�*����D�%�(��	����J�J�	2�D��$��&�"���e����N�N��=�=�$�$�U�+�,�-/�/3�h�j�B�
�
�N�N�S����!2�!2�5�!9� :�,�G�H��K�K�M�
�}�}�T�*�2�2�3��=�E�E�c�4�P�H�!�!)�
�+7�7;�h�@�
�

�N�N��=�=�$�$�U�+�,�N�7�+�W�T�H�TU�V�
�
�L�L�N��~�~�� � ��'��'�'��,�#�*�*�5�1�9	2�<��9�~��"� ��|������t�h�d�5�=�=�;L�;L�T�;R�:S�T�U��9�9�%�GP�%������!7��z��E�F���?�#�q�(����!?��PQ�@R�?U�UV�W�X� �I�I�c�$��&@�A�	����?�	�{�"�M��r6c�"�|j�}d|_|j�}|j�}|jxsOdt|j	d��d�vxs/td�|j
tj�D��}d}|r|jjd�}|jj|d��|jr|jj|d	��|j�r�|j�}|jj|d
��|j|j!|��d�|j�|j#�|j%|�|j|j'dd
��|j)|j*|�|j-d�|j-|j'dd��|j-d�|j#�|jd|j�|j)|j|�|j-d�|j#�|jd�|j)|j*|�|j/d�|j1|d��|jrV|j|j!d��d�|�|j#�|j3|�|j2|_|r|j|�d��|j
tj4�D]>}	|	j6dk(s�|	j8dk(s�#|j;d|	j<��@|jr$|j�}
|j|
�d��|j|j'dd
�|�|j)|j*|�|r(|j-d|�d|j'd��d��n|j-d�|jr|j-�d��|jr|j-d�nn|j>j@r|s|j-d �|j)|jB|�|j>j@r|s|j-d!�|jr|j-d!�|jr|j-d"�n|j-|rd#nd�|j#�|j%|�|jd$�|jE|jF|�|jr|j
�d%��|j/�|j1||jxr
|j��|jrs|jd
�d��|j#�|j%|�|jE|j|�|j1|�|j/�|jr�|jI|�|j/�|jK||�|j-|j'd&��d'��|j>j@r|j-d �|j)|jB|�|j>j@r|j-d!�|j-d(�|jM|�|jNr3|jNd)jQ|jjR�yy)*NT�loop)rQ)�only)r�c3�4K�|]}|j���y�wr.)r�)rer�s  r4rgz*CodeGenerator.visit_For.<locals>.<genexpr>�s����H�E�5�<�<�H�rrQ)�
for_branch�else�testz(fiter):z
async for zfor rgzauto_aiter(fiter)�fiter�:rKr��rMz%(reciter, loop_render_func, depth=0):r2�storez8Can't assign to special loop variable in for-loop targetz = 1r?�AsynczLoopContext(r@�reciterzauto_aiter(rBz&, undefined, loop_render_func, depth):z
, undefined):z_loop_vars = {}z = 0r�zloop(z, loop)r*)*r�r��	recursiver��iter_child_nodesrr�rr�r�rUrN�else_r�r�r�rEr�r;rCr2r8rFr�r>r�r�r�rSr�r�rCrBr�rrQr�rrr��difference_update�stores)r'r)r*r��
test_frame�
else_frame�
extended_loop�loop_ref�loop_filter_funcrS�iteration_indicators           r4�	visit_ForzCodeGenerator.visit_For�s����[�[�]�
� $�
���[�[�]�
��[�[�]�
�
�N�N�
I���t�4�4�)�4�D�i�P�Q�
I��H�T�]�]�5�;�;�-G�H�H�		����!�)�)�;�;�F�C�H����'�'���'�@��:�:����+�+�D�V�+�D��9�9�#�8�8�:�����+�+�D�V�+�D��N�N�d�i�i�(8�9�:�(�C�T�Y�Y�O��K�K�M����Z�(��N�N�4�,�,�\�6�B�C��J�J�t�{�{�J�/��J�J�v���J�J�t�(�(�)<�g�F�G��J�J�s�O��K�K�M��N�N�5�$�)�)�,��J�J�t�y�y�*�-��J�J�s�O��K�K�M��N�N�8�$��J�J�t�{�{�J�/��L�L��O����Z�4��@�
�>�>��N�N��9�9�V�$�%�%J�K�T�
�
�K�K�M��K�K�
�#�!+� 1� 1�J����N�N�h�Z�z�2�3��M�M�%�*�*�-�	�D��x�x�7�"�t�y�y�F�':��	�	�N��K�K��	��:�:�"&�";�";�"=���N�N�1�2�$�7�8����t�(�(��v�>��E��
�
�4�;�;�
�+���J�J��H�:�T�$�*;�*;�G�*D�)E�\�R�S��J�J�v���9�9��J�J�*�+�1�-�.��>�>��J�J�y�!����(�(���
�
�=�)��J�J�t�y�y�%�(����(�(���
�
�3���9�9��J�J�s�O��>�>��J�J�?�@��J�J�-��S�A����
�����$����(�)�����	�	�:�.��:�:��N�N�1�2�$�7�8���������$�.�.�*K����^�	�	
��:�:��N�N�S�!4� 5�Q�7�8��K�K�M����Z�(��O�O�D�J�J�
�3����Z�(��L�L�N��>�>��'�'�
�3��L�L�N����U�D�)��J�J�$�+�+�H�5�6�e�<�=����(�(��
�
�=�)��J�J�t�y�y�%�(����(�(��
�
�3���J�J�y�!��N�N�5�!�������r�"�4�4�Z�5G�5G�5N�5N�O�r6c���|j�}|jd|�|j|j|�|j	d�|j�|j
|j|�|j�|jD]}}|jd|�|j|j|�|j	d�|j�|j
|j|�|j��|jrN|jd�|j�|j
|j|�|j�yy)NrKr�zelif r�)r�r�r2r�rFr�rrQr��elif_r�)r'r)r*�if_framer�s     r4�visit_IfzCodeGenerator.visit_Ifs����:�:�<�����u�d�#��
�
�4�9�9�h�'��
�
�3�����
�����	�	�8�,������Z�Z�	�E��N�N�7�E�*��J�J�u�z�z�8�,��J�J�s�O��K�K�M��O�O�E�J�J��1��L�L�N�
	��:�:��N�N�7�#��K�K�M��O�O�D�J�J��1��L�L�N�	r6c��|j||�\}}|j�|jrY|jj	d�s|jd|j�d��|j
d|j�d��|j|jj|j��d��|j||�y)Nr�r�rBr�r�r1)
r^rr�rSr�rFr�r�rPre)r'r)r*�macro_framerYs     r4�visit_MacrozCodeGenerator.visit_Macro*s���!%����u�!=���Y������>�>��9�9�'�'��,��
�
�7��	�	�}�A�F�G��N�N�]�4�9�9�-�t�<�=��
�
�e�m�m�'�'��	�	�2�3�3�7�8����y�+�.r6c��|j||�\}}|jd�|j||�|j||�|j	|j
|d��|j
|�y)Nz	caller = T)�forward_caller)r^r�rer�
visit_Call�callr)r'r)r*�
call_framerYs     r4�visit_CallBlockzCodeGenerator.visit_CallBlock4sc�� $����e� <��
�I����{�#����y�*�-������%�����	�	�5���>����u�r6c�v�|j�}|jj|�|j|�|j	|�|j|j|�|j||�|j|j|�|j|�|j|�yr.)r�r�rNr;r�rrQrr��filterrr>)r'r)r*�filter_frames    r4�visit_FilterBlockzCodeGenerator.visit_FilterBlock<s����{�{�}�����)�)�$�/�����&����L�!�����	�	�<�0������%����$�+�+�|�4����u������&r6c��|j�}|jj|�|j|�t	|j
|j�D]J\}}|j�|j||�|jd�|j||��L|j|j|�|j|�y�Nr1)
r�r�rNr;�zip�targets�valuesrr2rFrrQr>)r'r)r*�
with_framer8�exprs      r4�
visit_WithzCodeGenerator.visit_WithGs����[�[�]�
����'�'��-�����$�����d�k�k�:�	$�L�F�D��L�L�N��J�J�v�z�*��J�J�u���J�J�t�U�#�		$�
	
����	�	�:�.�����$r6c�^�|j|�|j|j|�yr.)rr2r)r�s   r4�visit_ExprStmtzCodeGenerator.visit_ExprStmtSs �����T���
�
�4�9�9�e�$r6c�t�eZdZUejej
defed<ejeed<y)�CodeGenerator._FinalizeInfo.�const�srcN)r�r�r�r8r��Callablers�__annotations__r�r6r4�
_FinalizeInforWs,���z�z�!�*�*�S�#�X�.�/�/�
�Z�Z��_�r6rr`c��t|�S)z�The default finalize function if the environment isn't
        configured with one. Or, if the environment has one, this is
        called on that function's output for constants.
        )rsr{s r4�_default_finalizezCodeGenerator._default_finalize[s���5�z�r6�	_finalizec�b�����j��jS�jx}�d}�jjr�d}�jj�tj
dtjdtjdijt	j���}d}|�(dtjdtjf��fd�}n4|�|�d	�}|dk(r(dtjdtjf���fd
�}�j||��_�jS)a�Build the finalize function to be used on constants and at
        runtime. Cached so it's only created once for all output nodes.

        Returns a ``namedtuple`` with the following attributes:

        ``const``
            A function to finalize constant data at compile time.

        ``src``
            Source code to output around nodes to be evaluated at
            runtime.
        Nzenvironment.finalize(r��context.eval_ctxrCr`r%c� ����|��Sr.r�)r`r]�env_finalizes ��r4�finalizez.CodeGenerator._make_finalize.<locals>.finalize�s���"�<��#6�7�7r6r?c�6�����j|��Sr.)rC)r`r]rr's ���r4rz.CodeGenerator._make_finalize.<locals>.finalize�s���&�|�D�4D�4D�e�'L�M�Mr6)rrrCrrr��eval_context�get�from_objr8r9r)r'rr�pass_argr]rs`   @@r4�_make_finalizezCodeGenerator._make_finalizees����>�>�%��>�>�!�"�3�3�3��7������$�$�)�C��+�+�4�4�L�� � �)��%�%�'9��$�$�m���c��!�!�,�/��	
��H���8�A�E�E�8�a�e�e�8���h�Z�r�*���}�,�N����N�!�%�%�N��+�+�H�c�:����~�~�r6�groupc�*�tt|��S)z�Given a group of constant values converted from ``Output``
        child nodes, produce a string to write to the template module
        source.
        )rar)r'r&s  r4�_output_const_reprz CodeGenerator._output_const_repr�s��
�F�5�M�"�"r6rc���|j|j�}|jjrt|�}t	|t
j�rt|�S|j|�S)aCTry to optimize a child of an ``Output`` node by trying to
        convert it to constant, finalized data at compile time.

        If :exc:`Impossible` is raised, the node is not constant and
        will be evaluated at runtime. Any other exception will also be
        evaluated at runtime for easier debugging.
        )	�as_constr0r�rrYr�TemplateDatarsr)r'r)r*rrs     r4�_output_child_to_constz$CodeGenerator._output_child_to_const�sW���
�
�e�n�n�-���>�>�$�$��5�M�E��d�E�.�.�/��u�:���~�~�e�$�$r6c��|jjr|jd�n9|jjr|jd�n|jd�|j�|j|j�yy)zXOutput extra source code before visiting a child of an
        ``Output`` node.
        z1(escape if context.eval_ctx.autoescape else str)(zescape(zstr(N)r0r1rFr�r�r'r)r*rs    r4�_output_child_prezCodeGenerator._output_child_pre�sb���>�>�"�"��J�J�J�K�
�^�^�
&�
&��J�J�y�!��J�J�v���<�<�#��J�J�x�|�|�$�$r6c�b�|jd�|j�|jd�yy)zWOutput extra source code after visiting a child of an
        ``Output`` node.
        rBN)rFrr.s    r4�_output_child_postz CodeGenerator._output_child_post�s)��	
�
�
�3���<�<�#��J�J�s�O�$r6c�~�|jr.|jry|jd�|j�|j	�}g}|j
D]�}	|js.t|t
j�stj��|j|||�}|r(t|dt�r|dj|��{|j|g���|j�[t|�dk(r|j|j�d��n|j|j�d��|j�|D]�}t|t�rG|j!|�}|j�|jd|z��E|j|dz��Z|j�|jd|�n|j#|�|j%|||�|j'||�|j)|||�|j���|j+d���|j�1|j-�|jt|�dk(rdnd	�|jr|j-�yy#t
jtf$r|j|�Y��bwxYw)
Nr�r*r
r�z	.extend((r�rbrBr�)r�r�r�r�r%rrrYr+�
Impossibler,�	Exceptionrrur�rSr(rr/r2r1rFr�)	r'r)r*rrQ�childr�item�vals	         r4�visit_OutputzCodeGenerator.visit_Output�sH���%�%��%�%���N�N�8�9��K�K�M��&�&�(��;=��
�Z�Z�	%�E�
��N�N�"�%��);�);�<��*�*�,�,��3�3�E�5�(�K���
�4��8�T�2��R�����&����U�G�$�/	%�2�<�<�#��4�y�A�~����%�,�,��x�8�9����%�,�,��y�9�:��K�K�M��	$�D��$��%��-�-�d�3���<�<�'��N�N�8�c�>�2��N�N�3��9�-��<�<�'��N�N�8�T�2��L�L��&��&�&�t�U�H�=��
�
�4��'��'�'��e�X�>��<�<�+��J�J�s�O�+	$�.�<�<�#��L�L�N��N�N�#�d�)�q�.�3�d�;��%�%��L�L�N�&��_�$�$�i�0�
����E�"��
�s�A
J�*J<�;J<c��|j�|j|�|j|j|�|j	d�|j|j
|�|j
|�yr)r�rr2r8rFr)r�r�s   r4�visit_AssignzCodeGenerator.visit_AssignsX���!�!�#����T���
�
�4�;�;��&��
�
�5���
�
�4�9�9�e�$�� � ��'r6c�v�|j�|j�}d|_|jj	|�|j|�|j
|�|j|j|�|j|�|j|j|�|jd�|j�|j|j|�n|jd|j�d��|jd�|j|�|j!|�y)NFz9 = (Markup if context.eval_ctx.autoescape else identity)(�concat(rB)r�r�r�r�rNr;r�rrQrr2r8rFrr�r�r>)r'r)r*r�s    r4�visit_AssignBlockzCodeGenerator.visit_AssignBlock#s����!�!�#��k�k�m��,1��(����(�(��.�����%����K� �����	�	�;�/����T���
�
�4�;�;��&��
�
�N�O��;�;�"����d�k�k�;�7��J�J���!3�!3� 4�A�6�7��
�
�3��� � ��'�����%r6c	��|jdk(rX|js|js|jr4|jr(|jdj|j�|jj|j�}|jdk(r`|jj|�}|�|dtk(r|j|�r&|jd|j�d|�d|�d��y|j|�y)	Nr�r*r�rz(undefined(name=z) if z is missing else rB)
r�r�r�r�r�r�rSr�rP�	find_loadrr�rF)r'r)r*rPr�s     r4r�zCodeGenerator.visit_Name;s����8�8�w���N�N�e�.�.�%�2C�2C��!�!��"�"�2�&�*�*�4�9�9�5��m�m����	�	�*��
�8�8�v���=�=�*�*�3�/�D�� ���G�1�1��4�4�S�9��
�
�&�t�y�y�m�5���=N�s�e�ST�U����
�
�3�r6c��|jj|j�}|jd|�d��|j	�|jd�|j�|j|�d|j�d��y)Nzif not isinstance(z
, Namespace):zMraise TemplateRuntimeError("cannot assign attribute on non-namespace object")r'r()r�rPrSr�r�r��attr)r'r)r*rPs    r4�visit_NSRefzCodeGenerator.visit_NSRefTsu���m�m����	�	�*�����+�C�5�
�>�?����
����
B�	
�	
�������#��a��	�	�}�A�.�/r6c���|j|j�}t|t�r|j	t|��y|j	t
|��yr.)r*r0rYrprFrsra)r'r)r*r7s    r4�visit_ConstzCodeGenerator.visit_Constbs>���m�m�E�N�N�+���c�5�!��J�J�s�3�x� ��J�J�t�C�y�!r6c���	|jt|j|j���y#tj
$r"|jd|j�d��YywxYw�Nz6(Markup if context.eval_ctx.autoescape else identity)(rB)rFrar*r0rr3�datar�s   r4�visit_TemplateDataz CodeGenerator.visit_TemplateDataisW��	��J�J�t�D�M�M�%�.�.�9�:�;�����	��J�J�H����
�UV�W�
�	�s�36�2A+�*A+c���|jd�d}t|j�D]*\}}|r|jd�|j||��,|j|dk(rd�yd�y)Nr@r*r?rz,)rB�rFrOrzr2�r'r)r*r\r6s     r4�visit_TuplezCodeGenerator.visit_Tupleqsd���
�
�3����"�4�:�:�.�	$�I�C����
�
�4� ��J�J�t�U�#�	$�	
�
�
�3�!�8�4�-��-r6c���|jd�t|j�D]*\}}|r|jd�|j||��,|jd�y)Nr'r?r(rJrKs     r4�
visit_ListzCodeGenerator.visit_ListzsS���
�
�3��"�4�:�:�.�	$�I�C����
�
�4� ��J�J�t�U�#�	$�	
�
�
�3�r6c�:�|jd�t|j�D]a\}}|r|jd�|j|j|�|jd�|j|j
|��c|jd�y)Nrmr?rr)rFrOrzr2rr`rKs     r4�
visit_DictzCodeGenerator.visit_Dict�su���
�
�3��"�4�:�:�.�	*�I�C����
�
�4� ��J�J�t�x�x��'��J�J�t���J�J�t�z�z�5�)�	*�	
�
�
�3�r6�+�-�*�/z//z**�%�and�orznot c��|jjrd}n|jjrd}nd}|j|�d��|jD]%}|j||�|jd��'|jd�y)Nz8(markup_join if context.eval_ctx.volatile else str_join)�markup_join�str_joinz((r?r�)r0r1r�rFrr2)r'r)r*r�r"s     r4�visit_ConcatzCodeGenerator.visit_Concat�sy���>�>�"�"�R�I�
�^�^�
&�
&�%�I�"�I��
�
�i�[��#�$��:�:�	�C��J�J�s�E�"��J�J�t��	�	
�
�
�4�r6c���|jd�|j|j|�|jD]}|j||��|jd�y)Nr@rB)rFr2r
�opsrIs    r4�
visit_ComparezCodeGenerator.visit_Compare�sK���
�
�3���
�
�4�9�9�e�$��(�(�	"�B��J�J�r�5�!�	"��
�
�3�r6c��|jdt|j�d��|j|j|�y)NrA)rF�	operatorsr<r2r
r�s   r4�
visit_OperandzCodeGenerator.visit_Operand�s3���
�
�Q�y����)�*�!�,�-��
�
�4�9�9�e�$r6c�:�|jjr|jd�|jd�|j|j|�|jd|j
�d��|jjr|jd�yy)N�(await auto_await(zenvironment.getattr(r?rBr�)rCrBrFr2r)rAr�s   r4�
visit_GetattrzCodeGenerator.visit_Getattr�sv�����$�$��J�J�+�,��
�
�)�*��
�
�4�9�9�e�$��
�
�R��	�	�}�A�&�'����$�$��J�J�t��%r6c�v�t|jtj�r[|j	|j
|�|j
d�|j	|j|�|j
d�y|jjr|j
d�|j
d�|j	|j
|�|j
d�|j	|j|�|j
d�|jjr|j
d�yy)Nr'r(rczenvironment.getitem(r?rBr�)	rYr"r�Slicer2r)rFrCrBr�s   r4�
visit_GetitemzCodeGenerator.visit_Getitem�s����d�h�h����,��J�J�t�y�y�%�(��J�J�s�O��J�J�t�x�x��'��J�J�s�O����(�(��
�
�/�0��J�J�-�.��J�J�t�y�y�%�(��J�J�t���J�J�t�x�x��'��J�J�s�O����(�(��
�
�4� �)r6c�:�|j�|j|j|�|jd�|j�|j|j|�|j�.|jd�|j|j|�yy)Nr�)�startr2rF�stopr�r�s   r4�visit_SlicezCodeGenerator.visit_Slice�sq���:�:�!��J�J�t�z�z�5�)��
�
�3���9�9� ��J�J�t�y�y�%�(��9�9� ��J�J�s�O��J�J�t�y�y�%�(�!r6�	is_filterc#�K�|jjr|jd�|r[|j|j|j�d��|jjj|j�}nZ|j|j|j�d��|jjj|j�}|�?|js3|rdnd}|jd|�d|j�d�|j�tjdtjd	tjd
ijtj|��}|�|j|�d��d��|j||�|jd�|jjr|jd
�yy�w)Nrcr@rr�zNo r+r�r�rrCr?rBr�)rCrBrFr�rSr"r�r�r�r�rr�r!r#r$)r'r)r*rlrE�	type_namer$s       r4�_filter_test_commonz!CodeGenerator._filter_test_common�s��������$�$��J�J�+�,���J�J�$�,�,�t�y�y�1�2�!�4�5��#�#�+�+�/�/��	�	�:�D��J�J�$�*�*�T�Y�Y�/�0��2�3��#�#�)�)�-�-�d�i�i�8�D�
�<�� 0� 0�$-��6�I��I�I��I�;�g�d�i�i�]�!�<�d�k�k�J�
���i��!�!�#5�� � �-�
��#����d�#�
�		����J�J�(��2��'�	����t�U�#��
�
�3�����$�$��J�J�t��%�s�GGc���|j||d�5|j�|j|j|�n�|jjr-|jd|j�d|j�d��nU|jjr |jd|j�d��n|jd|j�d��ddd�y#1swYyxYw)NTz(Markup(concat(z.)) if context.eval_ctx.autoescape else concat(r�zMarkup(concat(r<rB)ror)r2r0r1rFr�r�r�s   r4r�zCodeGenerator.visit_Filters���
�
%�
%�d�E�4�
8�
	6��y�y�$��
�
�4�9�9�e�,����(�(��
�
�%�e�l�l�^�4C�CH�<�<�.�PR�T�����*�*��
�
�^�E�L�L�>��<�=��
�
�W�U�\�\�N�!�4�5�
	6�
	6�
	6�s�CC�C(c��|j||d�5|j|j|�ddd�y#1swYyxYwr�)ror2r)r�s   r4r�zCodeGenerator.visit_Tests;��
�
%�
%�d�E�5�
9�	)��J�J�t�y�y�%�(�	)�	)�	)�s	�:�Ac�@�����j��d���fd�}�jd��j�j���jd��j�j���jd�|��jd�y)Nc����j��j�j��y�jd�j���d��y)Nz1cond_expr_undefined("the inline if-expression on z6 evaluated to false and no else section was defined."))�expr2r2rFrh)r*r)r's���r4�write_expr2z1CodeGenerator.visit_CondExpr.<locals>.write_expr2"sL����z�z�%��
�
�4�:�:�u�-���J�J���M�M�$�'�(�)*�+�
r6r@z if z else rBr�)r�rFr2�expr1r�)r'r)r*rus``` r4�visit_CondExprzCodeGenerator.visit_CondExprsl����
�
���		�	
�
�
�3���
�
�4�:�:�u�%��
�
�6���
�
�4�9�9�e�$��
�
�8���
��
�
�3�r6r�c�8�|jjr|jd�|jjr|jd�n|jd�|j	|j
|�|rddind}|jrddini}|jrddini}|r|j|fi|��n|s|rt|fi|��}|j|||�|jd�|jjr|jd�yy)	Nrczenvironment.call(context, z
context.call(rG�
_loop_vars�_block_varsrBr�)rCrBrFrDr2r)r�r�r�ryr$)r'r)r*r�r�loop_kwargs�block_kwargss       r4r�zCodeGenerator.visit_Call5s������$�$��J�J�+�,����%�%��J�J�3�4��J�J��'��
�
�4�9�9�e�$�/=��(�+�4��6;�6F�6F�|�\�2�B��9>�9J�9J�
�}�5�PR����L����<�|�<�
�L���<�|�<�L����t�U�L�1��
�
�3�����$�$��J�J�t��%r6c�x�|j|jdz�|j|j|�y)Nr)rFrr2r`r�s   r4�
visit_KeywordzCodeGenerator.visit_KeywordLs(���
�
�4�8�8�c�>�"��
�
�4�:�:�u�%r6c��|jd�|j|j|�|jd�y)NzMarkup(rB�rFr2r
r�s   r4�visit_MarkSafezCodeGenerator.visit_MarkSafeRs+���
�
�9���
�
�4�9�9�e�$��
�
�3�r6c��|jd�|j|j|�|jd�yrFr�r�s   r4�visit_MarkSafeIfAutoescapez(CodeGenerator.visit_MarkSafeIfAutoescapeWs.��	
�
�
�K�L��
�
�4�9�9�e�$��
�
�3�r6c�@�|jd|jz�y)Nzenvironment.�rFrSr�s   r4�visit_EnvironmentAttributez(CodeGenerator.visit_EnvironmentAttribute^s��	
�
�
�>�D�I�I�-�.r6c�Z�|jd|j�d|j���y)Nzenvironment.extensions[z].)rF�
identifierrSr�s   r4�visit_ExtensionAttributez&CodeGenerator.visit_ExtensionAttributecs'��	
�
�
�,�T�_�_�,?�r�$�)�)��M�Nr6c�T�|j|j|j�yr.)rFr�r�r�s   r4�visit_ImportedNamez CodeGenerator.visit_ImportedNamehs���
�
�4�&�&�t���7�8r6c�:�|j|j�yr.r�r�s   r4�visit_InternalNamez CodeGenerator.visit_InternalNameks���
�
�4�9�9�r6c�&�|jd�y)Nr�)rFr�s   r4�visit_ContextReferencez$CodeGenerator.visit_ContextReferencens��	
�
�
�9�r6c�D�|j|j|��yr.)rFr�r�s   r4�visit_DerivedContextReferencez+CodeGenerator.visit_DerivedContextReferencess��	
�
�
�4�&�&�u�-�.r6c�(�|jd|�y)N�continuerrr�s   r4�visit_ContinuezCodeGenerator.visit_Continuexs�����z�4�(r6c�(�|jd|�y)N�breakrrr�s   r4�visit_BreakzCodeGenerator.visit_Break{s�����w��%r6c���|j�}|jj|�|j|�|j	|j
|�|j
|�yr.)r�r�rNr;rrQr>)r'r)r*�scope_frames    r4�visit_ScopezCodeGenerator.visit_Scope~sO���k�k�m�����(�(��.�����%�����	�	�;�/�����%r6c���|j�}|j|�d|j|����|j|�d��|j|j|�|j|�|j
d��}|jj|�|j|�|j|j|�|j|�|j�y)Nr1z.vars = T)r�)r�r�r�r2r�r{r�r�rNr;rrQr>r})r'r)r*r�r�s     r4�visit_OverlayScopez CodeGenerator.visit_OverlayScope�s����'�'�)�����#��c�$�"5�"5�e�"<�!=�>�?����#��h�'�(��
�
�4�<�<��'��#�#�C�(��k�k�4�k�0�����(�(��.�����%�����	�	�;�/�����%��"�"�$r6c�~�|jD]�}|jd|j�d��|j|j|�	|jj|j�}t|j|j|���y#tj$rd|j_
Y��wxYw)Nzcontext.eval_ctx.r1T)�optionsr�rr2r`r*r0�setattrrr3r1)r'r)r*�keywordr7s     r4�visit_EvalContextModifierz'CodeGenerator.visit_EvalContextModifier�s����|�|�	:�G��N�N�.�w�{�{�m�3�?�@��J�J�w�}�}�e�,�
:��m�m�,�,�U�^�^�<���������S�9�	:��
�#�#�
/�*.����'�
/�s�%B�$B<�;B<c�J�|j�}|jj�}|j|�d��|j	||�|j
D]}|j
||��|jj|�|jd|�d��y)Nz = context.eval_ctx.save()zcontext.eval_ctx.revert(rB)r�r0�saver�r�rQr2�revert)r'r)r*�old_ctx_name�	saved_ctxr5s      r4�visit_ScopedEvalContextModifierz-CodeGenerator.visit_ScopedEvalContextModifier�s����0�0�2���N�N�'�'�)�	����,��'A�B�C��&�&�t�U�3��Y�Y�	%�E��J�J�u�e�$�	%�
�����i�(����1�,��q�A�Br6�NFTr�r�)r
r.)Nr)zasync r�)�r�r�r�r8r�rs�TextIOrnr��propertyrWror�r�r+r�r�r�r�r�Noderrrr�rrFr�rr��Callr�r��Mappingr9r$r/r;r>rCrEr�r�r�r�r^rerhrprsrVrXrWr{r}r�r4r�r�r�r�rZr�r�r�r�r��Includer��Import�
FromImportr�r�r��Forr��Ifr�r�r�FilterBlockr�Withr�ExprStmtr�
NamedTupler�staticmethodrrrr%r(r7r,r/r1�Outputr8�Assignr:�AssignBlockr=r�r��NSRefrBr�rDr+rHrLr�rN�DictrPrM�	visit_Add�	visit_Sub�	visit_Mul�	visit_Div�visit_FloorDiv�	visit_Pow�	visit_Mod�	visit_And�visit_OrrR�	visit_Pos�	visit_Neg�	visit_Notr;�Concatr[�Comparer^�Operandra�Getattrrd�Getitemrgrfrkr�Iteratorror�r��CondExprrwr��Keywordr~�MarkSafer��MarkSafeIfAutoescaper��EnvironmentAttributer��ExtensionAttributer�r�r��InternalNamer��ContextReferencer��DerivedContextReferencer��Continuer��Breakr��Scoper��OverlayScoper��EvalContextModifierr��ScopedEvalContextModifierr�r�r6r4r(r(,s���(,� ��G4�"�G4��j�j��o�G4��*�*�S�/�	G4�
�
�
�1�8�8�$�G4��
G4��G4�
�G4�R�*�4�*��*�
L��L�S�L�]�L�,�c�,�
/�E�/�d�/�5:�9��9�-1�9�	
�9�(�"�C�"��"�<��<�a�j�j����.D�<�PT�<��u����DH����"��*+�*�*�U�Z�Z�*@��	
��	��
�
�5�:�:� 6�	�u�	��	��s��t��IJ�����J�J�u�z�z�2��BE��	
��*�A�J�J�u�z�z�2�*�#�*�d�*�;?�	7/��g�g�e�j�j�%�,�,��
�
�:�;�7/��7/��j�j����3����:�!6�7�	7/�

�7/�r)�q�z�z�%�*�*�'=�)�$�)�V>��>�4�>� B��B�4�B�D�B�H��H�C�H�QT�H�2��2��2�Q ��G�G�E�K�K����8�9�Q �BG�Q �	
������	!�Q �f

�8�

�E�

�d�

��U�Z�Z��C��!��!�#�!�+�I��I�$�I�$�6�C�6�D�6�5�S�5�T�5�,�1��1�#�#�#�U�E�U�c�U�3�c�3�d�3�)�)O��)O�4�)O�\@D�t9��N�N�t9�+,�:�:�e�+<�t9�	
�t9�l)����)�E�)�d�)�V)!�%�-�-�)!��)!�$�)!�V1�%�-�-�1��1�$�1�f
U��G�G�E�L�L�%�*:�*:�:�;�
U�DI�
U�	
�
U�	N����	N�e�	N��	N�5�U�%5�%5�5�e�5��5�nIP�e�i�i�IP��IP�$�IP�V�U�X�X��e����*/����/�E�/�d�/��E�O�O��E��d��	'�e�&7�&7�	'��	'�$�	'�
%�u�z�z�
%�%�
%�D�
%�%�5�>�>�%�%�%�D�%������������1�5�5����,0�I�q�z�z�-�(�/�.�
�.�`#��
�
�1�5�5�(9�#�c�#�%��J�J�%�',�%�8E�%�	�%�*%��J�J�%�',�%�8E�%�	
�%� 	��J�J�	�',�	�8E�	�	
�	�M����M�e�M��M�^(����(�e�(��(�&�e�&7�&7�&��&�$�&�0�u�z�z��%��D��20����0�E�0�d�0�"����"�E�"�d�"��u�'9�'9��%��D��.����.�E�.�d�.��u�z�z��%��D���u�z�z��%��D���C� �I��C� �I��C� �I��C� �I� ��&�N��D�!�I��C� �I��E�"�I��4� �H��3��I��3��I��6�"�I�������e��������%�-�-����$����%�%�-�-�%��%�$�%��	�%�-�-�	��	�$�	��	��!�%�-�-�!��!�$�!��!�()����)�E�)�d�)��'��G�G�E�L�L�%�*�*�4�5�'�>C�'�PT�'�	
���D�	�'��'�R�6����6�e�6��6��6� �)�u�z�z�)�%�)�D�)��)���5�>�>��%��D����,�EJ���J�J��',��>B��	
����,&�%�-�-�&��&�$�&��5�>�>��%��D��
��.�.��7<��	
��/��.�.�/�7<�/�	
�/�
O��,�,�O�5:�O�	
�O�
9�u�'9�'9�9�%�9�D�9��u�'9�'9��%��D����*�*��38��	
��
/��1�1�/�:?�/�	
�/�
)�5�>�>�)�%�)�D�)�&����&�E�&�d�&�&����&�E�&�d�&�%�u�'9�'9�%�%�%�D�%�:��-�-�:�6;�:�	
�:�
C��3�3�
C�<A�
C�	
�
Cr6r�)Fr��typingr8�
contextlibr�	functoolsr�ior�	itertoolsrr�rr�
markupsaferr	r�r�
exceptionsr�
idtrackingr
rrrrrr/r�utilsrrrJr�
TYPE_CHECKING�typing_extensions�terCr�TypeVarrr9rr`r;rsrKrMrQrRrZr�r�rnr_rdr�r��Setr�r�r+�RuntimeErrorrr�r~r4r�r(r�r6r4�<module>r�s2��6��%�$���2����.��&�*�(�*�� ��� ��?�?�"�(�
�A�I�I�c����C����J�/�0���
�

��

��
�
�	
�	�
2�Q�
2�1�
2� �C��A�J�J������'P�RV�'V�W��,����Z�Z��%�/�/�7�;�T�A�B��2$(����
�.�.�����*�*�S�/���j�j��o�	�

�J�J�q�x�x� ���
����Z�Z��_��0�����4��"��:�:�e�j�j�!��*+�*�*�S�/���U�U�3�Z��&�&�P�P�fJ�,�J�'�k�'�&&�K�&�,�9��~C�K�~Cr6
¿Qué es la limpieza dental de perros? - Clínica veterinaria


Es la eliminación del sarro y la placa adherida a la superficie de los dientes mediante un equipo de ultrasonidos que garantiza la integridad de las piezas dentales a la vez que elimina en profundidad cualquier resto de suciedad.

A continuación se procede al pulido de los dientes mediante una fresa especial que elimina la placa bacteriana y devuelve a los dientes el aspecto sano que deben tener.

Una vez terminado todo el proceso, se mantiene al perro en observación hasta que se despierta de la anestesia, bajo la atenta supervisión de un veterinario.

¿Cada cuánto tiempo tengo que hacerle una limpieza dental a mi perro?

A partir de cierta edad, los perros pueden necesitar una limpieza dental anual o bianual. Depende de cada caso. En líneas generales, puede decirse que los perros de razas pequeñas suelen acumular más sarro y suelen necesitar una atención mayor en cuanto a higiene dental.


Riesgos de una mala higiene


Los riesgos más evidentes de una mala higiene dental en los perros son los siguientes:

  • Cuando la acumulación de sarro no se trata, se puede producir una inflamación y retracción de las encías que puede descalzar el diente y provocar caídas.
  • Mal aliento (halitosis).
  • Sarro perros
  • Puede ir a más
  • Las bacterias de la placa pueden trasladarse a través del torrente circulatorio a órganos vitales como el corazón ocasionando problemas de endocarditis en las válvulas. Las bacterias pueden incluso acantonarse en huesos (La osteomielitis es la infección ósea, tanto cortical como medular) provocando mucho dolor y una artritis séptica).

¿Cómo se forma el sarro?

El sarro es la calcificación de la placa dental. Los restos de alimentos, junto con las bacterias presentes en la boca, van a formar la placa bacteriana o placa dental. Si la placa no se retira, al mezclarse con la saliva y los minerales presentes en ella, reaccionará formando una costra. La placa se calcifica y se forma el sarro.

El sarro, cuando se forma, es de color blanquecino pero a medida que pasa el tiempo se va poniendo amarillo y luego marrón.

Síntomas de una pobre higiene dental
La señal más obvia de una mala salud dental canina es el mal aliento.

Sin embargo, a veces no es tan fácil de detectar
Y hay perros que no se dejan abrir la boca por su dueño. Por ejemplo…

Recientemente nos trajeron a la clínica a un perro que parpadeaba de un ojo y decía su dueño que le picaba un lado de la cara. Tenía molestias y dificultad para comer, lo que había llevado a sus dueños a comprarle comida blanda (que suele ser un poco más cara y llevar más contenido en grasa) durante medio año. Después de una exploración oftalmológica, nos dimos cuenta de que el ojo tenía una úlcera en la córnea probablemente de rascarse . Además, el canto lateral del ojo estaba inflamado. Tenía lo que en humanos llamamos flemón pero como era un perro de pelo largo, no se le notaba a simple vista. Al abrirle la boca nos llamó la atención el ver una muela llena de sarro. Le realizamos una radiografía y encontramos una fístula que llegaba hasta la parte inferior del ojo.

Le tuvimos que extraer la muela. Tras esto, el ojo se curó completamente con unos colirios y una lentilla protectora de úlcera. Afortunadamente, la úlcera no profundizó y no perforó el ojo. Ahora el perro come perfectamente a pesar de haber perdido una muela.

¿Cómo mantener la higiene dental de tu perro?
Hay varias maneras de prevenir problemas derivados de la salud dental de tu perro.

Limpiezas de dientes en casa
Es recomendable limpiar los dientes de tu perro semanal o diariamente si se puede. Existe una gran variedad de productos que se pueden utilizar:

Pastas de dientes.
Cepillos de dientes o dedales para el dedo índice, que hacen más fácil la limpieza.
Colutorios para echar en agua de bebida o directamente sobre el diente en líquido o en spray.

En la Clínica Tus Veterinarios enseñamos a nuestros clientes a tomar el hábito de limpiar los dientes de sus perros desde que son cachorros. Esto responde a nuestro compromiso con la prevención de enfermedades caninas.

Hoy en día tenemos muchos clientes que limpian los dientes todos los días a su mascota, y como resultado, se ahorran el dinero de hacer limpiezas dentales profesionales y consiguen una mejor salud de su perro.


Limpiezas dentales profesionales de perros y gatos

Recomendamos hacer una limpieza dental especializada anualmente. La realizamos con un aparato de ultrasonidos que utiliza agua para quitar el sarro. Después, procedemos a pulir los dientes con un cepillo de alta velocidad y una pasta especial. Hacemos esto para proteger el esmalte.

La frecuencia de limpiezas dentales necesaria varía mucho entre razas. En general, las razas grandes tienen buena calidad de esmalte, por lo que no necesitan hacerlo tan a menudo e incluso pueden pasarse la vida sin requerir una limpieza. Sin embargo, razas pequeñas como el Yorkshire o el Maltés, deben hacérselas todos los años desde cachorros si se quiere conservar sus piezas dentales.

Otro factor fundamental es la calidad del pienso. Algunas marcas han diseñado croquetas que limpian la superficie del diente y de la muela al masticarse.

Ultrasonido para perros

¿Se necesita anestesia para las limpiezas dentales de perros y gatos?

La limpieza dental en perros no es una técnica que pueda practicarse sin anestesia general , aunque hay veces que los propietarios no quieren anestesiar y si tiene poco sarro y el perro es muy bueno se puede intentar…… , pero no se va a poder pulir ni acceder a todas la zona de la boca …. Además los limpiadores dentales van a irrigar agua y hay riesgo de aspiración a vías respiratorias si no se realiza una anestesia correcta con intubación traqueal . En resumen , sin anestesia no se va hacer una correcta limpieza dental.

Tampoco sirve la sedación ya que necesitamos que el animal esté totalmente quieto, y el veterinario tenga un acceso completo a todas sus piezas dentales y encías.

Alimentos para la limpieza dental

Hay que tener cierto cuidado a la hora de comprar determinados alimentos porque no todos son saludables. Algunos tienen demasiado contenido graso, que en exceso puede causar problemas cardiovasculares y obesidad.

Los mejores alimentos para los dientes son aquellos que están elaborados por empresas farmacéuticas y llevan componentes químicos con tratamientos específicos para el diente del perro. Esto implica no solo limpieza a través de la acción mecánica de morder sino también un tratamiento antibacteriano para prevenir el sarro.

Conclusión

Si eres como la mayoría de dueños, por falta de tiempo , es probable que no estés prestando la suficiente atención a la limpieza dental de tu perro. Por eso te animamos a que comiences a limpiar los dientes de tu perro y consideres atender a su higiene bucal con frecuencia.

Estas simples medidas pueden conllevar a que tu perro tenga una vida más larga y mucho más saludable.

Si te resulta imposible introducir un cepillo de dientes a tu perro en la boca, pásate con él por clínica Tus Veterinarios y te explicamos cómo hacerlo.

Necesitas hacer una limpieza dental profesional a tu mascota?
Llámanos al 622575274 o contacta con nosotros

Deja un comentario

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *

¡Hola!