관리-도구
편집 파일: _ast_util.cpython-38.pyc
U +�eO � @ sd d Z ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ dd lm Z dd lm Z ddlmZ ddlmZ dd lm Z ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ dd lm Z ed!ed"iZ!ed#ed$ed%ed&e d'ed(ed)ed*ed+ed,ed-iZ"e d.ed/ed0ed1ed2ed3ed4ed5ed6ed7i Z#ed8ed9ed#e d$iZ$i Z%e%�&e!� e%�&e"� e%�&e#� e%�&e$� dGd<d=�Z'd>d?� Z(G d@dA� dA�Z)G dBdC� dCe)�Z*G dDdE� dEe)�Z+dFS )Hz� ast ~~~ This is a stripped down version of Armin Ronacher's ast module. :copyright: Copyright 2008 by Armin Ronacher. :license: Python License. � )�Add)�And)�AST)�BitAnd)�BitOr)�BitXor)�Div)�Eq)�FloorDiv)�Gt)�GtE)�If)�In)�Invert)�Is)�IsNot)�LShift)�Lt)�LtE)�Mod)�Mult)�Name)�Not)�NotEq)�NotIn)�Or)� PyCF_ONLY_AST)�RShift)�Sub)�UAdd)�USub�and�or�+�-�*�/z//�%z<<z>>�|�&�^z==�>z>=�in�iszis not�<z<=z!=znot in�~�not� <unknown>�execc C s t | ||t�S )z%Parse an expression into an AST node.)�compiler )�expr�filename�mode� r7 �</opt/hc_python/lib/python3.8/site-packages/mako/_ast_util.py�parseY s r9 c c s: | j D ].}z|t| |�fV W q tk r2 Y qX qdS )zAIterate over all fields of a node, only yielding existing fields.N)�_fields�getattr�AttributeError)�node�fieldr7 r7 r8 �iter_fields^ s r? c @ s( e Zd ZdZdd� Zdd� Zdd� 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. Don't use the `NodeVisitor` if you want to apply changes to nodes during traversing. For this a special visitor exists (`NodeTransformer`) that allows modifications. c C s d|j j }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__r; )�selfr= �methodr7 r7 r8 �get_visitorz s zNodeVisitor.get_visitorc C s$ | � |�}|dk r||�S | �|�S )z Visit a node.N)rF � generic_visit)rD r= �fr7 r7 r8 �visit� s zNodeVisitor.visitc C sT t |�D ]F\}}t|t�r:|D ]}t|t�r| �|� qqt|t�r| �|� qdS )z9Called if no explicit visitor function exists for a node.N)r? � isinstance�listr rI )rD r= r>