관리-도구
편집 파일: visitor.cpython-311.pyc
� S�Dg� � �N � d Z ddlmZ G d� de� � Z G d� de� � ZdS )zVAPI for traversing the AST nodes. Implemented by the compiler and meta introspection. � )�Nodec �$ � e Zd ZdZd� Zd� Zd� ZdS )�NodeVisitora Walks the abstract syntax tree and call visitor functions for every node found. The visitor functions may return values which will be forwarded by the `visit` method. Per default the visitor functions for the nodes are ``'visit_'`` + class name of the node. So a `TryFinally` node visit function would be `visit_TryFinally`. This behavior can be changed by overriding the `get_visitor` function. If no visitor function exists for a node (return value `None`) the `generic_visit` visitor is used instead. c �B � d|j j z }t | |d� � S )z�Return the visitor function for this node or `None` if no visitor exists for this node. In that case the generic visit function is used instead. �visit_N)� __class__�__name__�getattr)�self�node�methods �n/builddir/build/BUILD/imunify360-venv-2.4.0/opt/imunify360/venv/lib/python3.11/site-packages/jinja2/visitor.py�get_visitorzNodeVisitor.get_visitor s% � � �D�N�3�3���t�V�T�*�*�*� c �j � | � |� � }|� ||g|�R i |��S | j |g|�R i |��S )z Visit a node.)r � generic_visit)r r �args�kwargs�fs r �visitzNodeVisitor.visit s] � ����T�"�"���=��1�T�+�D�+�+�+�F�+�+�+�!�t�!�$�8��8�8�8��8�8�8r c �V � |� � � D ]} | j |g|�R i |�� �dS )z9Called if no explicit visitor function exists for a node.N)�iter_child_nodesr )r r r r s r r zNodeVisitor.generic_visit# sL � ��)�)�+�+� .� .�D��D�J�t�-�d�-�-�-�f�-�-�-�-� .� .r N)r � __module__�__qualname__�__doc__r r r � r r r r sK � � � � � � � �+� +� +�9� 9� 9�.� .� .� .� .r r c � � e Zd ZdZd� Zd� ZdS )�NodeTransformera� Walks the abstract syntax tree and allows modifications of nodes. The `NodeTransformer` will walk the AST and use the return value of the visitor functions to replace or remove the old node. If the return value of the visitor function is `None` the node will be removed from the previous location otherwise it's replaced with the return value. The return value may be the original node in which case no replacement takes place. c �� � |� � � D ]�\ }}t |t � � rxg }|D ]k}t |t � � r? | j |g|�R i |��}|��+t |t � � s|� |� � �V|� |� � �l||d d �<