3/ >`dZddlZddlmZddlmZddlmZejrddl m Z Gdd eZ d ej d ej efd ZejejejejfZejejejejejfZd ej d ejejefd ZdS)z_Functions that expose information about templates that might be interesting for introspection. N)nodes) CodeGenerator)Frame) EnvironmentcHeZdZdZd fd ZdeddfdZd eddffd ZxZ S) TrackingCodeGeneratorz.We abuse the code generator for introspection. environmentrreturnNctt|ddt|_dS)Nz)super__init__setundeclared_identifiers)selfr __class__s /srv/buildsys-work-dir/castor/build_node/builder-2/WGSG1/unpkd_srcs/cloudlinux-venv-1.0.6/venv/lib/python3.11/site-packages/jinja2/meta.pyrzTrackingCodeGenerator.__init__s3 &79JKKK25%%###xcdS)z Don't write.N)rrs rwritezTrackingCodeGenerator.writesrframect||jjD]6\}\}}|dkr(||jjvr|j|7dS)z$Remember all undeclared identifiers.resolveN) r enter_framesymbolsloadsitemsr globalsradd)rr_actionparamrs rrz!TrackingCodeGenerator.enter_frames E""""'-"5";";"="= 7 7 A""uD4D4L'L'L+//666 7 7r)r rr N) __name__ __module__ __qualname____doc__rstrrrr __classcell__)rs@rr r s88888888st7747777777777rr astr cbt|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 rfind_undeclared_variablesr/!s.&$CO44G MM#  ))rc#K|tD]$}|j}t|tjsxt|tjtjfrM|jD]D}t|tjr$t|j tr |j V@dVEndVt|j tr |j Vt|tj rFt|j ttfr%|j D]}t|tr|V dV&dS)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_typestemplate isinstancerConstTupleListrvaluer)Includetuplelist)r+noder3 template_names rfind_referenced_templatesr>=sk" Z((!!#}(EK00 (U[%*$=>> %-^##M"-==#%m&93??6"/"5555# #  hnc * * . em , ,  NUDM2 2  "* ( ( mS11('''' ( JJJJC!!r)r(typingtrcompilerrr TYPE_CHECKINGr rr TemplateSetr)r/Extends FromImportImportr9r2Union_RefTypeIteratorOptionalr>rrrrMs5######?)((((((77777M777&*5>*aeCj****0mU-u|U] K 75=%"2EL%-O P25>2ajC6Q222222r