관리-도구
편집 파일: meta.cpython-311.pyc
� �܋f, � �` � d Z ddlZddlmZ ddlmZ ddlmZ ej rddl m Z G d� d e� � Zd ej dej e fd�Zej ej ej ej fZej ej ej ej ej f Zd ej dej ej e fd �ZdS )z_Functions that expose information about templates that might be interesting for introspection. � N� )�nodes)� CodeGenerator)�Frame)�Environmentc �H � � e Zd ZdZd� fd�Zdeddfd�Zd eddf� fd �Z� xZ S )�TrackingCodeGeneratorz.We abuse the code generator for introspection.�environmentr �returnNc �t �� t � � � |dd� � t � � | _ d S )Nz<introspection>)�super�__init__�set�undeclared_identifiers)�selfr � __class__s ��\/builddir/build/BUILD/cloudlinux-venv-1.0.6/venv/lib/python3.11/site-packages/jinja2/meta.pyr zTrackingCodeGenerator.__init__ s3 �� � ������&7�9J�K�K�K�25�%�%��#�#�#� �xc � � dS )zDon't write.N� )r r s r �writezTrackingCodeGenerator.write s � � � r �framec �� �� t � � � |� � |j j � � � D ]6\ }\ }}|dk r(|| j j vr| j � |� � �7dS )z$Remember all undeclared identifiers.�resolveN) r �enter_frame�symbols�loads�itemsr �globalsr �add)r r �_�action�paramr s �r r z!TrackingCodeGenerator.enter_frame s� �� � �����E�"�"�"�"'�-�"5�";�";�"=�"=� 7� 7��A������"�"�u�D�4D�4L�'L�'L��+�/�/��6�6�6�� 7� 7r )r r r N) �__name__� __module__�__qualname__�__doc__r �strr r r � __classcell__)r s @r r r s� �� � � � � �8�8�8� 8� 8� 8� 8� 8��s� �t� � � � �7�� 7�4� 7� 7� 7� 7� 7� 7� 7� 7� 7� 7r r �astr 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) == {'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. � �&