Your IP : 52.15.113.71
�
S�Dg# � �b � d Z ddlmZ ddlmZ ddlmZ ddlmZ G d� de� � Zd� Z d � Z
d
S )z_Functions that expose information about templates that might be
interesting for introspection.
� )�nodes)� iteritems)�string_types)�
CodeGeneratorc �$ � e Zd ZdZd� Zd� Zd� ZdS )�TrackingCodeGeneratorz.We abuse the code generator for introspection.c �Z � t j | |dd� � t � � | _ d S )Nz<introspection>)r �__init__�set�undeclared_identifiers)�self�environments �k/builddir/build/BUILD/imunify360-venv-2.4.0/opt/imunify360/venv/lib/python3.11/site-packages/jinja2/meta.pyr
zTrackingCodeGenerator.__init__ s- � ���t�[�2C�EV�W�W�W�&)�e�e��#�#�#� c � � dS )zDon't write.N� )r
�xs r �writezTrackingCodeGenerator.write s � � � r c �� � t j | |� � t |j j � � D ]6\ }\ }}|dk r(|| j j vr| j � |� � �7dS )z$Remember all undeclared identifiers.�resolveN) r �enter_framer �symbols�loadsr �globalsr �add)r
�frame�_�action�params r r z!TrackingCodeGenerator.enter_frame sw � ��!�$��.�.�.�"+�E�M�,?�"@�"@� 7� 7��A������"�"�u�D�4D�4L�'L�'L��+�/�/��6�6�6�� 7� 7r N)�__name__�
__module__�__qualname__�__doc__r
r r r r r r r sG � � � � � �8�8�,� ,� ,�� � �7� 7� 7� 7� 7r r c �b � t | j � � }|� | � � |j S )a Returns a set of all variables in the AST that will be looked up from
the context at runtime. Because at compile time it's not known which
variables will be used depending on the path the execution takes at
runtime, all variables are returned.
>>> from jinja2 import Environment, meta
>>> env = Environment()
>>> ast = env.parse('{% set foo = 42 %}{{ bar + foo }}')
>>> meta.find_undeclared_variables(ast) == set(['bar'])
True
.. admonition:: Implementation
Internally the code generator is used for finding undeclared variables.
This is good to know because the code generator might raise a
:exc:`TemplateAssertionError` during compilation and as a matter of
fact this function can currently raise that exception as well.
)r r �visitr )�ast�codegens r �find_undeclared_variablesr( s. � �&