Files
intellecton/venv/lib/python3.12/site-packages/jinja2/__pycache__/meta.cpython-312.pyc
T

54 lines
5.4 KiB
Plaintext
Raw Normal View History

Ë
LÀj-ãóÖ—dZddlZddlmZddlmZddlmZejrddl m
Z
Gd„d e«Z d
ejd ejefd „Zej ej"ej$ej&fZej*ej ej"ej$ej&fZd
ejd ej.ej0efd
„Zy)z_Functions that expose information about templates that might be
interesting for introspection.
éNé)Únodes)Ú
CodeGenerator)ÚFrame)Ú EnvironmentcóH‡—eZdZdZd ˆfd„ Zdeddfd„Zdeddfˆfd„ ZˆxZ S)
ÚTrackingCodeGeneratorz.We abuse the code generator for introspection.ÚreturnNcóF•—t‰|�|dd«t«|_y)Nz<introspection>)ÚsuperÚ__init__ÚsetÚundeclared_identifiers)ÚselfÚ environmentÚ __class__s €úN/home/antigravity/intellecton/venv/lib/python3.12/site-packages/jinja2/meta.pyr
zTrackingCodeGenerator.__init__s ø€Ü
‰Ñ˜Ð&7Ð9JÔKÜ25³%ˆÕ#óÚxcó—y)z Don't write.N©)rrs rÚwritezTrackingCodeGenerator.writes�rÚframecóö•—t‰|�|«|jjj «D]B\}\}}|dk(sŒ||j
j vsŒ(|jj|«ŒDy)z$Remember all undeclared identifiers.ÚresolveN) r Ú enter_frameÚsymbolsÚloadsÚitemsrÚglobalsrÚadd)rrÚ_ÚactionÚparamrs €rrz!TrackingCodeGenerator.enter_framesjø€ä
‰Ñ˜EÔ"à"'§-¡-×"5Ñ"5×";Ñ";Ó"=ò 7Ñ ˆA‰�˜Ø˜Ó" u°D×4DÑ4D×4LÑ4LÒ'LØ×+Ñ+×/Ñ/°Õ6ñ 7r)rrr
N)
Ú__name__Ú
__module__Ú __qualname__Ú__doc__r
ÚstrrrrÚ
__classcell__)rs@rr r s6ø„Ù8õ8ð�sð˜tóð7 ð7¨4÷7ñ7rr Úastr
cóf—t|j«}|j|«|jS)aReturns 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+Úcodegens rÚfind_undeclared_variablesr/"s*€ô&$ C§O¡OÓ4€GØ ‡M�M�#ÔØ × )Ñ )Ð)rc#óÀK—|jt«D�]A}|j}t|tj
«s‰t|tj tjf«rZ|jD]J}t|tj
«r*t|jt«sŒ8|j–—ŒGd–—ŒLnd–—Œ³t|jt«r|j–—ŒÜt|tj«rHt|jttf«r(|jD]}t|t«sŒ|–—Œ�Œ>d–—�ŒDy­w)abFinds all the referenced templates from the AST. This will return an
iterator over all the hardcoded template extensions, inclusions and
imports. If dynamic inheritance or inclusion is used, `None` will be
yielded.
>>> from jinja2 import Environment, meta
>>> env = Environment()
>>> ast = env.parse('{% extends "layout.html" %}{% include helper %}')
>>> list(meta.find_referenced_templates(ast))
['layout.html', None]
This function is useful for dependency tracking. For example if you want
to rebuild parts of the website after a layout template has changed.
N)Úfind_allÚ
_ref_typesÚtemplateÚ