0x1949 Team - FAZEMRX - MANAGER
Edit File: meta.cpython-310.pyc
o �:�`, � @ s� d Z ddlZddlmZ ddlmZ ddlmZ ejr!ddl m Z G dd � d e�Zd ejdej e fdd �ZejejejejfZejejejejejf Zd ejdejeje fdd�ZdS )z_Functions that expose information about templates that might be interesting for introspection. � N� )�nodes)� CodeGenerator)�Frame)�Environmentc sJ e Zd ZdZd� fdd�Zdeddfd d �Zdeddf� fdd �Z� Z S )�TrackingCodeGeneratorz.We abuse the code generator for introspection.�environmentr �returnNc s t � �|dd� t� | _d S )Nz<introspection>)�super�__init__�set�undeclared_identifiers)�selfr �� __class__� �-/usr/lib/python3/dist-packages/jinja2/meta.pyr s zTrackingCodeGenerator.__init__�xc C s dS )zDon't write.Nr )r r r r r �write s zTrackingCodeGenerator.write�framec sJ t � �|� |jj�� D ]\}\}}|dkr"|| jjvr"| j�|� qdS )z$Remember all undeclared identifiers.�resolveN) r �enter_frame�symbols�loads�itemsr �globalsr �add)r r �_�action�paramr r r r s ��z!TrackingCodeGenerator.enter_frame)r r r N) �__name__� __module__�__qualname__�__doc__r �strr r r � __classcell__r r r r r s r �astr c C s t | j�}|�| � |jS )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) == {'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 )r&