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/lib/python3.10/site-packages/mako/__pycache__/parsetree.cpython-310.pyc
o

%we?J�@sbdZddlZddlmZddlmZddlmZddlmZGdd�d�ZGd	d
�d
e�ZGdd�de�Z	Gd
d�de�Z
Gdd�de�ZGdd�de�ZGdd�de�Z
Gdd�de�ZGdd�deed�ZGdd�de�ZGdd�de�ZGdd�de�ZGd d!�d!e�ZGd"d#�d#e�ZGd$d%�d%e�ZGd&d'�d'e�ZGd(d)�d)e�ZGd*d+�d+e�ZdS),z5defines the parse tree components for Mako templates.�N)�ast)�
exceptions)�filters)�utilc@s4eZdZdZdd�Zedd��Zdd�Zdd	�Zd
S)�Nodez(base class for a Node in the parse tree.cCs||_||_||_||_dS�N��source�lineno�pos�filename)�selfr	r
rr�r�G/home/arjun/projects/env/lib/python3.10/site-packages/mako/parsetree.py�__init__s
z
Node.__init__cCs|j|j|j|jd�S)Nrr�r
rrr�exception_kwargss
�zNode.exception_kwargscC�gSrrrrrr�get_children$�zNode.get_childrencs,�fdd�}t�d|jj|�}||�dS)Ncs|��D]}|���qdSr)r�accept_visitor)�node�n��visitorrr�traverse(s�z%Node.accept_visitor.<locals>.traverse�visit)�getattr�	__class__�__name__)r
rr�methodrrrr'szNode.accept_visitorN)	r�
__module__�__qualname__�__doc__r�propertyrrrrrrrrs
rc�0eZdZdZ�fdd�Zdd�Zdd�Z�ZS)�TemplateNodez?a 'container' node that stores the overall collection of nodes.cs"t��ddd|�g|_i|_dS)N�r)�superr�nodes�page_attributes)r
r�rrrr4s
zTemplateNode.__init__cC�|jSr�r)rrrrr9�zTemplateNode.get_childrencCsdt�|j�|jfS)NzTemplateNode(%s, %r))r�sorted_dict_reprr*r)rrrr�__repr__<s
�zTemplateNode.__repr__)rr!r"r#rrr0�
__classcell__rrr+rr&0s
r&csLeZdZdZdZ�fdd�Zdd�Zdd�Zd	d
�Zdd�Z	d
d�Z
�ZS)�ControlLinez�defines a control line, a line-oriented python line or end tag.

    e.g.::

        % if foo:
            (markup)
        % endif

    Fcsrt�jdi|��||_||_||_|dv|_g|_|jr%g|_g|_dSt	j
|fi|j��}|j|_|j
|_dS)N)�for�if�while�try�withr)r(r�text�keyword�isend�
is_primaryr)�_declared_identifiers�_undeclared_identifiersr�PythonFragmentr�declared_identifiers�undeclared_identifiers)r
r9r:r8�kwargs�coder+rrrQs

zControlLine.__init__cCr,rr-rrrrr`r.zControlLine.get_childrencCr,r)r<rrrrr?cr.z ControlLine.declared_identifierscCr,r)r=rrrrr@fr.z"ControlLine.undeclared_identifierscCs*ddhddhdhd�}||�|jt��vS)zRreturn true if the given keyword is a ternary keyword
        for this ControlLine�else�elif�except�finally)r4r6r3)�getr9�set)r
r9�casesrrr�
is_ternaryis
�zControlLine.is_ternarycCsd|j|j|j|j|jffS)NzControlLine(%r, %r, %r, %r))r9r8r:r
rrrrrr0us
�zControlLine.__repr__)rr!r"r#�has_loop_contextrrr?r@rJr0r1rrr+rr2Cs
r2c�(eZdZdZ�fdd�Zdd�Z�ZS)�Textz#defines plain text in the template.c�t�jdi|��||_dS�Nr)r(r�content)r
rPrAr+rrr��
z
Text.__init__cC�d|j|j|jffS)NzText(%r, %r))rPr
rrrrrr0��z
Text.__repr__�rr!r"r#rr0r1rrr+rrM~srMc�8eZdZdZ�fdd�Zdd�Zdd�Zdd	�Z�ZS)
�Codez�defines a Python code block, either inline or module level.

    e.g.::

        inline:
        <%
            x = 12
        %>

        module level:
        <%!
            import logger
        %>

    cs8t�jdi|��||_||_tj|fi|j��|_dSrO)r(rr8�ismoduler�
PythonCoderrB)r
r8rWrAr+rrr�sz
Code.__init__cC�|jjSr)rBr?rrrrr?��zCode.declared_identifierscCrYr)rBr@rrrrr@�rZzCode.undeclared_identifierscCsd|j|j|j|jffS)NzCode(%r, %r, %r))r8rWr
rrrrrr0�s

�z
Code.__repr__�	rr!r"r#rr?r@r0r1rrr+rrV�srVcrL)�Commentz6defines a comment line.

    # this is a comment

    crNrO)r(rr8)r
r8rAr+rrr�rQzComment.__init__cCrR)NzComment(%r, %r))r8r
rrrrrr0�rSzComment.__repr__rTrrr+rr\�sr\crU)
�
Expressionz/defines an inline expression.

    ${x+y}

    csNt�jdi|��||_||_tj|fi|j��|_tj|fi|j��|_	dSrO)
r(rr8�escapesr�ArgumentListr�escapes_coderXrB)r
r8r^rAr+rrr�s
zExpression.__init__cCrrrrrrrr?�rzExpression.declared_identifierscCs$|jj�|jj�tj���|jj�Sr)rBr@�unionr`�
differencer�DEFAULT_ESCAPESr?rrrrr@�s��
�z!Expression.undeclared_identifierscCsd|j|jj|j|jffS)NzExpression(%r, %r, %r))r8r`�argsr
rrrrrr0�s

�zExpression.__repr__r[rrr+rr]�sr]cs,eZdZdZiZ�fdd�Zdd�Z�ZS)�_TagMetazImetaclass to allow Tag to produce a subclass according to
    its keywordcs0t|dd�dur||j|j<t��|||�dS)N�__keyword__)r�	_classmaprfr(r)�cls�clsname�bases�dict_r+rrr�sz_TagMeta.__init__c
Ks�d|vr|�d�\}}tjt|||fi|��Sztj|}Wnty9tjd||d|d|d|dd��wtj|||fi|��S)N�:zNo such tag: '%s'r	r
rrr)	�split�type�__call__�CallNamespaceTagrerg�KeyErrorr�CompileException)rhr9�
attributesrA�ns�defnamerrrro�s&����z_TagMeta.__call__)rr!r"r#rgrror1rrr+rre�s
recsTeZdZdZdZ�fdd�Zdd�Zdd�Zd	d
�Zdd�Z	d
d�Z
dd�Z�ZS)�Tagz�abstract base class for tags.

    e.g.::

        <%sometag/>

        <%someothertag>
            stuff
        </%someothertag>

    Ncs|t�jdi|��|�_|�_��||��fdd�|D�}t|�r6tjdd�dd�|D��fi�j	���d�_
g�_dS)	aVconstruct a new Tag instance.

        this constructor not called directly, and is only called
        by subclasses.

        :param keyword: the tag keyword

        :param attributes: raw dictionary of attribute key/value pairs

        :param expressions: a set of identifiers that are legal attributes,
         which can also contain embedded expressions

        :param nonexpressions: a set of identifiers that are legal
         attributes, which cannot contain embedded expressions

        :param \**kwargs:
         other arguments passed to the Node superclass (lineno, pos)

        csg|]	}|�jvr|�qSr)�parsed_attributes)�.0�rrrr�
<listcomp>,�z Tag.__init__.<locals>.<listcomp>zMissing attribute(s): %s�,css�|]}t|�VqdSr)�repr)rx�mrrr�	<genexpr>1s�zTag.__init__.<locals>.<genexpr>Nr)r(rr9rs�_parse_attributes�lenrrr�joinr�parentr))r
r9rs�expressions�nonexpressions�requiredrA�missingr+rrrs���
zTag.__init__cC�
|jduSr)r�rrrr�is_root9s
zTag.is_rootcCr,rr-rrrrr<r.zTag.get_childrenc	Cs<t�}i|_|jD]�}||vrcg}t�dtj��|j|�D]7}t�dtj��|�}|rLtj	|�
d���fi|j��}|�
|j�}|�d|�
d��q|rU|�t|��qd�|�p^td�|j|<q	||vr�t�d|j|�rtjd||jffi|j���t|j|�|j|<q	tjd	|j|ffi|j���||_dS)
Nz	(\${.+?})z^\${(.+?)}$�z(%s)z + r'z\${.+?}z>Attribute '%s' in tag '%s' does not allow embedded expressionsz$Invalid attribute for tag '%s': '%s')rHrwrs�re�compile�Srm�matchrrX�group�rstriprrar@�appendr}r��searchrrrr9�!expression_undeclared_identifiers)	r
r�r�r@�key�expr�xr~rBrrrr�?sR
�����������
zTag._parse_attributescCrrrrrrrr?hrzTag.declared_identifierscCr,r)r�rrrrr@kr.zTag.undeclared_identifierscCs*d|jj|jt�|j�|j|jf|jfS)Nz%s(%r, %s, %r, %r))	rrr9rr/rsr
rr)rrrrr0ns

�zTag.__repr__)
rr!r"r#rfrr�rr�r?r@r0r1rrr+rrv�s-)rv)�	metaclasscs4eZdZdZ�fdd�Zdd�Z�fdd�Z�ZS)�
IncludeTag�includecsBt�j||dddfi|��tjd|�dd�fi|j��|_dS)N)�file�importrdr�r�z__DUMMY(%s)rdr')r(rrrXrGr�	page_args�r
r9rsrAr+rrr{s����zIncludeTag.__init__cCrrrrrrrr?�rzIncludeTag.declared_identifierscs*|jj�dh��|jj�}|�t����S)N�__DUMMY)r�r@rbr?rar()r
�identifiersr+rrr@�s�
�z!IncludeTag.undeclared_identifiers�rr!r"rfrr?r@r1rrr+rr�xs

r�crL)�NamespaceTag�	namespacecs�t�j||dddfi|��|�ddttt|����|_d|vr/d|vr/tj	di|j	���d|vrAd	|vrCtj	
di|j	���dSdS)
Nr�)�name�inheritabler��modulerr�z	__anon_%sr��?'name' and/or 'import' attributes are required for <%namespace>r�r��4<%namespace> may only have one of 'file' or 'module')r�)r�)
r(rrG�hex�abs�idr�rrrrr�r+rrr�s.��	�����zNamespaceTag.__init__cCrrrrrrrr?�rz!NamespaceTag.declared_identifiers�rr!r"rfrr?r1rrr+rr��sr�crL)�TextTagr8cs>t�j||dddfi|��tj|�dd�fi|j��|_dS)Nr�filterr')r(rrr_rGr�filter_argsr�r+rrr�s
��zTextTag.__init__cC�|jj�tj����|j�Sr�r�r@rbrrc�keysrar�rrrrr@�s
��zTextTag.undeclared_identifiers)rr!r"rfrr@r1rrr+rr��sr�csLeZdZdZ�fdd�ZdZdZedd��Zdd�Z	d	d
�Z
dd�Z�ZS)
�DefTag�defcs�ddgdd�|D�}t�j|||ddfi|��|d}t�d|�r-tj		di|j���tjd
|dfi|j��|_	|j	j
|_|�dd
�|_
tj|�dd
�fi|j��|_dS)N�buffered�cachedcS�g|]	}|�d�r|�qS��cache_��
startswith�rx�crrrrz��

��z#DefTag.__init__.<locals>.<listcomp>�r�r��	decorator�r�r��^[\w_]+$�Missing parenthesis in %defzdef z:passr�r'r�)r�)r(rr�r�rrrrr�FunctionDecl�
function_decl�funcnamer�rGr�r_r��r
r9rsrAr�r�r+rrr�s>�����
��

��zDefTag.__init__FcCrYr)r�r�rrrrr��szDefTag.funcnamecK�|jjdi|��SrO)r��get_argument_expressions�r
�kwrrrr���zDefTag.get_argument_expressionscCrYr)r��allargnamesrrrrr?�rZzDefTag.declared_identifierscCs`g}|jjD]}|ttj|fi|j��j�7}qt|��|j	j�
tj�
����|j��
|jj�Sr)r��defaults�listrrXrr@rHrar�rbrrcr�r�r�)r
�resr�rrrr@�s&�����
�zDefTag.undeclared_identifiers)
rr!r"rfr�is_anonymous�is_blockr$r�r�r?r@r1rrr+rr��s
r�csTeZdZdZ�fdd�ZdZedd��Zedd��Zd	d
�Z	dd�Z
d
d�Z�ZS)�BlockTag�blockcs�gd�dd�|D�}t�j|||ddfi|��|�d�}|r0t�d|�s0tj	di|j���|sB|�d	d�rBtj	
di|j���tj	|�d	d�fi|j��|_
||_|�dd�|_tj
|�d
d�fi|j��|_dS)N)r�r�rdcSr�r�r�r�rrrrzr�z%BlockTag.__init__.<locals>.<listcomp>r�rr�r��,%block may not specify an argument signaturerd�#Only named %blocks may specify argsr'r�r�)r�)r�)r(rrGr�r�rrrrr�FunctionArgs�	body_declr�r�r_r�r�r+rrrsJ���
����
��
��zBlockTag.__init__TcCr�rr�rrrrr�$s
zBlockTag.is_anonymouscCs|jpd|jfS)Nz__M_anon_%d)r�r
rrrrr�(szBlockTag.funcnamecKr�rO)r�r�r�rrrr�,r�z!BlockTag.get_argument_expressionscCrYr�r�r�rrrrr?/rZzBlockTag.declared_identifierscCr�rr�rrrrr@2s
��zBlockTag.undeclared_identifiers)
rr!r"rfrr�r$r�r�r�r?r@r1rrr+rr��s!

r�cr%)�CallTag�callcs`t�j||dddfi|��|d|_tj|jfi|j��|_tj|�dd�fi|j��|_	dS)Nrd)r�r�r')
r(r�
expressionrrXrrBr�rGr�r�r+rrr=s
��

��zCallTag.__init__cC�|jj�|jj�Sr�rBr?rar�r�rrrrr?Gr�zCallTag.declared_identifierscC�|jj�|jj�Sr�rBr@rbr?rrrrr@J��zCallTag.undeclared_identifiersr�rrr+rr�:s

r�cs,eZdZ�fdd�Zdd�Zdd�Z�ZS)rpcs�t�j|d||t|���dddfi|��d||d�dd�|j��D��f|_tj	|jfi|j
��|_tj|�
dd	�fi|j
��|_dS)
Nrl)rdrz	%s.%s(%s)r|css(�|]\}}|dkrd||fVqdS)rdz%s=%sNr)rx�k�vrrrr^s�
��z,CallNamespaceTag.__init__.<locals>.<genexpr>rdr')r(r�tupler�r�rw�itemsr�rrXrrBr�rGr�)r
r�rursrAr+rrrQs,
��	
��

��zCallNamespaceTag.__init__cCr�rr�rrrrr?jr�z%CallNamespaceTag.declared_identifierscCr�rr�rrrrr@mr�z'CallNamespaceTag.undeclared_identifiers)rr!r"rr?r@r1rrr+rrpPsrpcs eZdZdZ�fdd�Z�ZS)�
InheritTag�inheritcs t�j||dddfi|��dS)Nr�r)r(rr�r+rrrvs

�
�zInheritTag.__init__)rr!r"rfrr1rrr+rr�ssr�crL)�PageTag�pagecsrgd�dd�|D�}t�j|||ddfi|��tj|�dd�fi|j��|_tj|�dd�fi|j��|_dS)N)r�rd�expression_filter�enable_loopcSr�r�r�r�rrrrz�r{z$PageTag.__init__.<locals>.<listcomp>rrdr'r�)	r(rrr�rGrr�r_r�)r
r9rsrAr�r+rrrs�
��
��zPageTag.__init__cCrYrr�rrrrr?�rZzPageTag.declared_identifiersr�rrr+rr�|sr�)r#r��makorrrrrr&r2rMrVr\r]rnrervr�r�r�r�r�r�rpr�r�rrrr�<module>s0;%!{?<#