|
Server : LiteSpeed System : Linux server51.dnsbootclub.com 4.18.0-553.62.1.lve.el8.x86_64 #1 SMP Mon Jul 21 17:50:35 UTC 2025 x86_64 User : nandedex ( 1060) PHP Version : 8.1.33 Disable Function : NONE Directory : /opt/cppython/lib/python3.8/site-packages/mako/__pycache__/ |
U
O��g� � @ sr d Z ddlZddlmZ ddlmZ G dd� d�ZG dd� d�ZG d d
� d
e�ZG dd� d�ZG d
d� de�Z dS )zjutilities for analyzing expressions and blocks of Python
code, as well as generating Python from AST nodes� N)�
exceptions)�pyparserc @ s e Zd ZdZdd� ZdS )�
PythonCodez<represents information about a string containing Python codec K sV || _ t� | _t� | _t|t�r6tj|�� df|�}n|}tj | f|�}|�
|� d S )N�exec)�code�set�declared_identifiers�undeclared_identifiers�
isinstance�strr �parse�lstripZFindIdentifiers�visit��selfr �exception_kwargs�expr�f� r �5/opt/cppython/lib/python3.8/site-packages/mako/ast.py�__init__ s
zPythonCode.__init__N��__name__�
__module__�__qualname__�__doc__r r r r r r s r c @ s e Zd ZdZdd� ZdS )�ArgumentListzBparses a fragment of code as a comma-separated list of expressionsc K sz g | _ g | _t� | _t� | _t|t�rXt�d|�rFt�d|�sF|d7 }t j
|df|�}n|}t j| tf|�}|�
|� d S )Nz\Sz,\s*$�,r )Zcodeargs�argsr r r r
r �re�matchr r Z FindTupler r r r r r r 6 s
zArgumentList.__init__Nr r r r r r 2 s r c s e Zd ZdZ� fdd�Z� ZS )�PythonFragmentz�extends PythonCode to provide identifier lookups in partial control
statements
e.g.::
for x in 5:
elif y==9:
except (MyException, e):
c s� t �d|�� t j�}|s*tjd| f|��|�d�rF|d |�d�� }|�dd�\}}|dkrh|d }nb|dkrz|d }nP|d
kr�d| d }n:|dkr�d
| d }n$|dkr�|d }ntjd| f|��t� j |f|� d S )Nz^(\w+)(?:\s+(.*?))?:\s*(#|$)z0Fragment '%s' is not a partial control statement� � � )�for�if�while�pass�tryzpass
except:pass)�elif�elsezif False:pass
�exceptz try:pass
�withz!Unsupported control keyword: '%s')
r r �strip�Sr �CompileException�group�start�superr )r r r �m�keywordr �� __class__r r r U s4 ��
��zPythonFragment.__init__�r r r r r �
__classcell__r r r6 r r! H s r! c @ s0 e Zd ZdZddd�Zddd�Zedd � �Zd
S )
�FunctionDeclzfunction declarationTc K sp || _ tj|df|�}tj| f|�}|�|� t| d�sJtjd| f|��|sl| jrltjd| j d f|��d S )Nr �funcnamez'Code '%s' is not a function declarationz('**%s' keyword argument not allowed here���)
r r r Z ParseFuncr �hasattrr r0 �kwargs�
kwargnames)r r Zallow_kwargsr r r r r r r u s$
��
���zFunctionDecl.__init__Fc C s6 g }| j ddd� }| jddd� }| jddd� }| jddd� }| jr^|�d|�d� � |D ]f}|r~|�d||f � qb|r�|�d�}|dkr�|�|� q�|�d|t�|�� � f � qb|�|� qb| j
r�|�d|�d� � |D ]@}|s�|�s|�|� q�|�d�}|�d|t�|�� � f � q�|�� |S )aE Return the argument declarations of this FunctionDecl as a printable
list.
By default the return value is appropriate for writing in a ``def``;
set `as_call` to true to build arguments to be passed to the function
instead (assuming locals with the same names as the arguments exist).
Nr<