HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //home/arjun/projects/env/lib64/python3.10/site-packages/mako/__pycache__/ast.cpython-310.pyc
o

%we��@srdZddlZddlmZddlmZGdd�d�ZGdd�d�ZGd	d
�d
e�ZGdd�d�ZGd
d�de�Z	dS)zjutilities for analyzing expressions and blocks of Python
code, as well as generating Python from AST nodes�N)�
exceptions)�pyparserc@�eZdZdZdd�ZdS)�
PythonCodez<represents information about a string containing Python codecKs^||_t�|_t�|_t|t�rtj|��dfi|��}n|}tj	|fi|��}|�
|�dS)N�exec)�code�set�declared_identifiers�undeclared_identifiers�
isinstance�strr�parse�lstrip�FindIdentifiers�visit��selfr�exception_kwargs�expr�f�r�A/home/arjun/projects/env/lib/python3.10/site-packages/mako/ast.py�__init__s
zPythonCode.__init__N��__name__�
__module__�__qualname__�__doc__rrrrrr�rc@r)�ArgumentListzBparses a fragment of code as a comma-separated list of expressionscKs�g|_g|_t�|_t�|_t|t�r.t�d|�r#t�d|�s#|d7}t	j
|dfi|��}n|}t	j|tfi|��}|�
|�dS)Nz\Sz,\s*$�,r)�codeargs�argsrr	r
rr�re�matchrr
�	FindTuplerrrrrrr6s
zArgumentList.__init__Nrrrrrr2rrc� eZdZdZ�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):

    cs�t�d|��tj�}|stjd|fi|���|�d�r%|d|�d��}|�dd�\}}|dvr6|d}n3|dkr?|d	}n*|d
vrJd|d}n|dkrUd
|d}n|dkr^|d}ntjd|fi|���t�j	|fi|��dS)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)rrr�m�keywordr��	__class__rrrUs4��



��zPythonFragment.__init__�rrrrr�
__classcell__rrr<rr'Hsr'c@s0eZdZdZddd�Zddd�Zedd	��Zd
S)
�FunctionDeclzfunction declarationTcKs�||_tj|dfi|��}tj|fi|��}|�|�t|d�s+tjd|fi|���|s>|jr@tjd|j	dfi|���dSdS)Nr�funcnamez'Code '%s' is not a function declarationz('**%s' keyword argument not allowed here���)
rrr
�	ParseFuncr�hasattrrr6�kwargs�
kwargnames)rr�allow_kwargsrrrrrrrus&

��
����zFunctionDecl.__init__Fc	Cs4g}|jddd�}|jddd�}|jddd�}|jddd�}|jr/|�d|�d��|D]3}|r?|�d||f�q1|r_|�d�}|durP|�|�q1|�d|t�|��	�f�q1|�|�q1|j
rr|�d|�d��|D]}|sz|s�|�|�qt|�d�}|�d|t�|��	�f�qt|��|S)aEReturn 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).
        NrBz**rz%s=%s�*)�argnamesrF�defaults�
kwdefaultsrE�append�popr�ExpressionGenerator�value�varargs�reverse)	r�as_call�	namedeclsrIrFrJrK�name�defaultrrr�get_argument_expressions�sB	
��
��z%FunctionDecl.get_argument_expressionscCst|j�t|j�S)N)�tuplerIrF)rrrr�allargnames�szFunctionDecl.allargnamesN)T)F)rrrrrrV�propertyrXrrrrr@qs

9r@cr&)�FunctionArgsz.the argument portion of a function declarationcst�jd|fi|��dS)Nzdef ANON(%s):pass)r9r)rrrEr<rrr�szFunctionArgs.__init__r>rrr<rrZ�srZ)
rr#�makorrrrr'r@rZrrrr�<module>s")T