
    YeIiMJ                     <   d Z ddlZddlmZ ddlmZ ddlmZ ddlmZ  G d d          Z G d	 d
e          Z G d de          Z	 G d de          Z
 G d de          Z G d de          Z G d de          Z G d de          Z G d dee          Z G d de          Z G d de          Z G d de          Z G d  d!e          Z G d" d#e          Z G d$ d%e          Z G d& d'e          Z G d( d)e          Z G d* d+e          ZdS ),z5defines the parse tree components for Mako templates.    N)ast)
exceptions)filters)utilc                   :    e Zd ZdZd Zed             Zd Zd ZdS )Nodez(base class for a Node in the parse tree.c                 >    || _         || _        || _        || _        d S Nsourcelinenoposfilename)selfr   r   r   r   s        S/var/www/html/MCyber-Diagnostic/venv/lib/python3.11/site-packages/mako/parsetree.py__init__zNode.__init__   s"         c                 8    | j         | j        | j        | j        dS )Nr   r   r   s    r   exception_kwargszNode.exception_kwargs   s'     kk8	
 
 	
r   c                     g S r
    r   s    r   get_childrenzNode.get_children$       	r   c                 d    fd}t          d| j        j        z   |          } ||            d S )Nc                 `    |                                  D ]}|                               d S r
   )r   accept_visitor)nodenvisitors     r   traversez%Node.accept_visitor.<locals>.traverse(   s?    &&(( * *  ))))* *r   visit)getattr	__class____name__)r   r    r!   methods    `  r   r   zNode.accept_visitor'   sJ    	* 	* 	* 	* 	* 'DN,C"CXNNtr   N)	r%   
__module____qualname____doc__r   propertyr   r   r   r   r   r   r   r      sb        22! ! ! 
 
 X
      r   r   c                   .     e Zd ZdZ fdZd Zd Z xZS )TemplateNodez?a 'container' node that stores the overall collection of nodes.c                 l    t                                          ddd|           g | _        i | _        d S )N r   )superr   nodespage_attributes)r   r   r$   s     r   r   zTemplateNode.__init__4   s6    Q8,,,
!r   c                     | j         S r
   r0   r   s    r   r   zTemplateNode.get_children9   
    zr   c                 L    dt          j        | j                  d| j        dS )NzTemplateNode(, ))r   sorted_dict_reprr1   r0   r   s    r   __repr__zTemplateNode.__repr__<   s.     !$"67777JJJ
 	
r   )r%   r'   r(   r)   r   r   r9   __classcell__r$   s   @r   r,   r,   0   s\        II" " " " "
  
 
 
 
 
 
 
r   r,   c                   D     e Zd ZdZdZ fdZd Zd Zd Zd Z	d Z
 xZS )	ControlLinezdefines a control line, a line-oriented python line or end tag.

    e.g.::

        % if foo:
            (markup)
        % endif

    Fc                     t                      j        di | || _        || _        || _        |dv | _        g | _        | j        rg | _        g | _        d S t          j
        |fi | j        }|j        | _        |j        | _        d S )N)forifwhiletrywithr   )r/   r   textkeywordisend
is_primaryr0   _declared_identifiers_undeclared_identifiersr   PythonFragmentr   declared_identifiersundeclared_identifiers)r   rE   rF   rD   kwargscoder$   s         r   r   zControlLine.__init__Q   s    ""6"""	
!%JJ
: 	G)+D&+-D(((%dDDd.CDDD)-)BD&+/+FD(((r   c                     | j         S r
   r3   r   s    r   r   zControlLine.get_children`   r4   r   c                     | j         S r
   )rH   r   s    r   rK   z ControlLine.declared_identifiersc   s    ))r   c                     | j         S r
   )rI   r   s    r   rL   z"ControlLine.undeclared_identifiersf   s    ++r   c                 j    ddhddhdhd}||                     | j        t                                v S )zRreturn true if the given keyword is a ternary keyword
        for this ControlLineelseelifexceptfinally)r@   rB   r?   )getrE   set)r   rE   casess      r   
is_ternaryzControlLine.is_ternaryi   sF    
 6"i(8
 
 %))DL#%%8888r   c           	      V    d| j         d| j        d| j        d| j        | j        fd	S )NzControlLine(r6   r7   )rE   rD   rF   r   r   r   s    r   r9   zControlLine.__repr__u   s;     LLLIIIJJJ[$(###	
 	
r   )r%   r'   r(   r)   has_loop_contextr   r   rK   rL   rZ   r9   r:   r;   s   @r   r=   r=   C   s          G G G G G  * * *, , ,
9 
9 
9
 
 
 
 
 
 
r   r=   c                   (     e Zd ZdZ fdZd Z xZS )Textz#defines plain text in the template.c                 H     t                      j        di | || _        d S Nr   )r/   r   content)r   ra   rM   r$   s      r   r   zText.__init__   s+    ""6"""r   c                 6    d| j         d| j        | j        fdS )NzText(r6   r7   )ra   r   r   r   s    r   r9   zText.__repr__   s$     !%TX/F/F/FGGr   r%   r'   r(   r)   r   r9   r:   r;   s   @r   r^   r^   ~   sT        --    H H H H H H Hr   r^   c                   4     e Zd ZdZ fdZd Zd Zd Z xZS )Codezdefines a Python code block, either inline or module level.

    e.g.::

        inline:
        <%
            x = 12
        %>

        module level:
        <%!
            import logger
        %>

    c                      t                      j        di | || _        || _        t	          j        |fi | j        | _        d S r`   )r/   r   rD   ismoduler   
PythonCoder   rN   )r   rD   rg   rM   r$   s       r   r   zCode.__init__   sN    ""6"""	 N4AA4+@AA			r   c                     | j         j        S r
   )rN   rK   r   s    r   rK   zCode.declared_identifiers   s    y--r   c                     | j         j        S r
   )rN   rL   r   s    r   rL   zCode.undeclared_identifiers   s    y//r   c                 F    d| j         d| j        d| j        | j        fdS )NzCode(r6   r7   )rD   rg   r   r   r   s    r   r9   zCode.__repr__   s2     IIIMMM[$(###
 	
r   	r%   r'   r(   r)   r   rK   rL   r9   r:   r;   s   @r   re   re      st          B B B B B. . .0 0 0
 
 
 
 
 
 
r   re   c                   (     e Zd ZdZ fdZd Z xZS )Commentz6defines a comment line.

    # this is a comment

    c                 H     t                      j        di | || _        d S r`   )r/   r   rD   )r   rD   rM   r$   s      r   r   zComment.__init__   s+    ""6"""			r   c                 6    d| j         d| j        | j        fdS )NzComment(r6   r7   )rD   r   r   r   s    r   r9   zComment.__repr__   s$     $(IIITX/F/F/FGGr   rc   r;   s   @r   rn   rn      sX             H H H H H H Hr   rn   c                   4     e Zd ZdZ fdZd Zd Zd Z xZS )
Expressionz/defines an inline expression.

    ${x+y}

    c                      t                      j        di | || _        || _        t	          j        |fi | j        | _        t	          j        |fi | j        | _	        d S r`   )
r/   r   rD   escapesr   ArgumentListr   escapes_coderh   rN   )r   rD   rt   rM   r$   s       r   r   zExpression.__init__   sl    ""6"""	,WNN8MNNN4AA4+@AA			r   c                     g S r
   r   r   s    r   rK   zExpression.declared_identifiers   r   r   c                     | j         j                            | j        j                            t
          j                                                | j         j                  S r
   )rN   rL   unionrv   
differencer   DEFAULT_ESCAPESrK   r   s    r   rL   z!Expression.undeclared_identifiers   sR    y/554??' 
 
 *TY3
4
4		5r   c                 P    d| j         d| j        j        d| j        | j        fdS )NzExpression(r6   r7   )rD   rv   argsr   r   r   s    r   r9   zExpression.__repr__   s8     III"""[$(###
 	
r   rl   r;   s   @r   rr   rr      st         B B B B B  5 5 5
 
 
 
 
 
 
r   rr   c                   ,     e Zd ZdZi Z fdZd Z xZS )_TagMetazImetaclass to allow Tag to produce a subclass according to
    its keywordc                     t          | dd           | | j        | j        <   t                                          |||           d S )N__keyword__)r#   	_classmapr   r/   r   )clsclsnamebasesdict_r$   s       r   r   z_TagMeta.__init__   sE    3t,,8-0CM#/*%/////r   c           	      B   d|v r2|                     d          \  }}t          j        t          |||fi |S 	 t          j        |         } nB# t          $ r5 t          j        d|z  |d         |d         |d         |d                   w xY wt          j        | ||fi |S )N:zNo such tag: '%s'r   r   r   r   r   )	splittype__call__CallNamespaceTagr   r   KeyErrorr   CompileException)r   rE   
attributesrM   nsdefnames         r   r   z_TagMeta.__call__   s    '>>!--,,KB= "gz =C  		$W-CC 	 	 	-#g-h'h'5M
+   	 }S':@@@@@s   A ?B
)r%   r'   r(   r)   r   r   r   r:   r;   s   @r   r   r      s_          I0 0 0 0 0
A A A A A A Ar   r   c                   J     e Zd ZdZdZ fdZd Zd Zd Zd Z	d Z
d	 Z xZS )
Tagzabstract base class for tags.

    e.g.::

        <%sometag/>

        <%someothertag>
            stuff
        </%someothertag>

    Nc                 H     t                      j        di | | _        | _                             ||            fd|D             }t          |          r7t          j        dd                    d |D                       z  fi  j	        d _
        g  _        dS )aV  construct 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)

        c                 &    g | ]}|j         v|S r   )parsed_attributes).0rr   s     r   
<listcomp>z Tag.__init__.<locals>.<listcomp>,  s&    JJJ!43I*I*I1*I*I*Ir   zMissing attribute(s): %s,c              3   4   K   | ]}t          |          V  d S r
   )repr)r   ms     r   	<genexpr>zTag.__init__.<locals>.<genexpr>1  s(      881tAww888888r   Nr   )r/   r   rE   r   _parse_attributeslenr   r   joinr   parentr0   )	r   rE   r   expressionsnonexpressionsrequiredrM   missingr$   s	   `       r   r   zTag.__init__  s    8 	""6"""${N;;;JJJJhJJJw<< 	-.hh88888889 
 '   


r   c                     | j         d u S r
   )r   r   s    r   is_rootzTag.is_root9  s    {d""r   c                     | j         S r
   r3   r   s    r   r   zTag.get_children<  r4   r   c                    t                      }i | _        | j        D ]}||v rJg }t          j        dt          j                                      | j        |                   D ]}t          j        dt          j                                      |          }|rt          j	        |
                    d                                          fi | j        }|                    |j                  }|                    d|
                    d          z             |r"|                    t!          |                     d                    |          pt!          d          | j        |<   R||v rgt          j        d| j        |                   r#t'          j        d|d	| j        d
fi | j        t!          | j        |                   | j        |<   t'          j        d| j        d|dfi | j        || _        d S )Nz(\${(?:[^$]*?{.+|.+?)})z^\${(.+?)}$   z(%s)z + r.   z\${.+?}zAttribute 'z
' in tag 'z%' does not allow embedded expressionszInvalid attribute for tag 'z': '')rX   r   r   recompileSr   matchr   rh   grouprstripr   ry   rL   appendr   r   searchr   r   rE   !expression_undeclared_identifiers)	r   r   r   rL   keyexprxr   rN   s	            r   r   zTag._parse_attributes?  s3   !$!#? #	 #	Ck!!$>EEKKOC(  - -A 
>2488>>qAAA -"~GGAJJ--//   373H    2H1M1M 72 2. FQWWQZZ$78888 -DGG,,,.3jj.>.>.J$r((&s++&&9Z)=>> $55),dlll<  /  
 /34?33G.H.H&s++ 11|||SSS*  +  
 2H...r   c                     g S r
   r   r   s    r   rK   zTag.declared_identifiersh  r   r   c                     | j         S r
   )r   r   s    r   rL   zTag.undeclared_identifiersk  s    55r   c           
          | j         j        d| j        dt          j        | j                  d| j        | j        fd| j        d
S )N(r6   r7   )	r$   r%   rE   r   r8   r   r   r   r0   r   s    r   r9   zTag.__repr__n  sT    N###LLL!$/2222[$(###JJJ
 	
r   )r%   r'   r(   r)   r   r   r   r   r   rK   rL   r9   r:   r;   s   @r   r   r      s        
 
 K+ + + + +Z# # #  'H 'H 'HR  6 6 6
 
 
 
 
 
 
r   r   )	metaclassc                   2     e Zd ZdZ fdZd Z fdZ xZS )
IncludeTagincludec                      t                      j        ||dddfi | t          j        d|                    dd          z  fi | j        | _        d S )N)fileimportr}   r   r   z__DUMMY(%s)r}   r.   )r/   r   r   rh   rW   r   	page_argsr   rE   r   rM   r$   s       r   r   zIncludeTag.__init__{  s{    &	
 	
 	
 	
 	
 JNN62666
 
:>:O
 
r   c                     g S r
   r   r   s    r   rK   zIncludeTag.declared_identifiers  r   r   c                     | j         j                            dh                              | j         j                  }|                    t                                                                S )N__DUMMY)r   rL   rz   rK   ry   r/   )r   identifiersr$   s     r   rL   z!IncludeTag.undeclared_identifiers  s]    n;FFK
 

*T^8
9
9 	   !?!?!A!ABBBr   r%   r'   r(   r   r   rK   rL   r:   r;   s   @r   r   r   x  sn        K
 
 
 
 
  C C C C C C C C Cr   r   c                   (     e Zd ZdZ fdZd Z xZS )NamespaceTag	namespacec                 N    t                      j        ||dddfi | |                    ddt          t	          t          |                               z            | _        d|vrd|vrt          j        	 di | j	        d|v rd	|v rt          j        	 di | j	        d S d S )Nr   )nameinheritabler   moduler   r   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/   r   rW   hexabsidr   r   r   r   r   s       r   r   zNamespaceTag.__init__  s    7	
 	
 	
 	
 	
 NN6;SD]]9K9K+KLL	##
(B(B-#  '  
 ZH
$:$:-F '    $:$:r   c                     g S r
   r   r   s    r   rK   z!NamespaceTag.declared_identifiers  r   r   r%   r'   r(   r   r   rK   r:   r;   s   @r   r   r     sL        K    .      r   r   c                   (     e Zd ZdZ fdZd Z xZS )TextTagrD   c                      t                      j        ||dddfi | t          j        |                    dd          fi | j        | _        d S )Nr   filterr.   )r/   r   r   ru   rW   r   filter_argsr   s       r   r   zTextTag.__init__  sf    *b8bKKFKKK+NN8R((
 
,0,A
 
r   c                     | j         j                            t          j                                                                      | j                  S r
   r   rL   rz   r   r{   keysry   r   r   s    r   rL   zTextTag.undeclared_identifiers  sB    6AA#((**
 

%6
7
7	8r   )r%   r'   r(   r   r   rL   r:   r;   s   @r   r   r     sL        K
 
 
 
 
8 8 8 8 8 8 8r   r   c                   R     e Zd ZdZ fdZdZdZed             Zd Z	d Z
d Z xZS )DefTagdefc                    ddgd |D             z   } t                      j        |||ddfi | |d         }t          j        d|          rt	          j        	 di | j        t          j        d	|z   d
z   fi | j        | _	        | j	        j
        | _        |                    dd          | _        t          j        |                    dd          fi | j        | _        d S )Nbufferedcachedc                 <    g | ]}|                     d           |S cache_
startswithr   cs     r   r   z#DefTag.__init__.<locals>.<listcomp>  s9     0
 0
 0
Q\\(%;%;0
0
 0
 0
r   r   r   	decoratorr   r   ^[\w_]+$Missing parenthesis in %defzdef z:passr   r.   r   )r   )r/   r   r   r   r   r   r   r   FunctionDeclfunction_declfuncnamer   rW   r   ru   r   r   rE   r   rM   r   r   r$   s         r   r   zDefTag.__init__  sD   !8, 0
 0
!0
 0
 0
 
 	+	
 	
 	
 	
 	
 &!8K&& 	-- 151F   !-TMG#
 
'+'<
 
 &/	#R88+NN8R((
 
,0,A
 
r   Fc                     | j         j        S r
   )r   r   r   s    r   r   zDefTag.funcname  s    !**r   c                 &     | j         j        di |S r`   )r   get_argument_expressionsr   kws     r   r   zDefTag.get_argument_expressions  s    :t!:@@R@@@r   c                     | j         j        S r
   )r   allargnamesr   s    r   rK   zDefTag.declared_identifiers  s    !--r   c           	         g }| j         j        D ].}|t          t          j        |fi | j        j                  z  }/t          |                              | j	        j        
                    t          j                                                                                | j                  
                    | j         j                  S r
   )r   defaultslistr   rh   r   rL   rX   ry   r   rz   r   r{   r   r   r   )r   resr   s      r   rL   zDefTag.undeclared_identifiers  s    #, 	 	A4 . (  CC HHU 7BB+0022  
 U49::Z*677		
r   )r%   r'   r(   r   r   is_anonymousis_blockr*   r   r   rK   rL   r:   r;   s   @r   r   r     s        K
 
 
 
 
6 LH+ + X+A A A. . .
 
 
 
 
 
 
r   r   c                   d     e Zd ZdZ fdZdZed             Zed             Zd Z	d Z
d Z xZS )	BlockTagblockc                 N   g dd |D             z   } t                      j        |||ddfi | |                    d          }|r,t          j        d|          st          j        	 di | j        |s-|                    dd           rt          j        	 di | j        t          j	        |                    dd
          fi | j        | _
        || _        |                    dd
          | _        t          j        |                    dd
          fi | j        | _        d S )N)r   r   r}   c                 <    g | ]}|                     d           |S r   r   r   s     r   r   z%BlockTag.__init__.<locals>.<listcomp>  s9     8
 8
 8
Q\\(%;%;8
8
 8
 8
r   r   r   r   r   ,%block may not specify an argument signaturer}   #Only named %blocks may specify argsr.   r   r   )r
  )r  )r/   r   rW   r   r   r   r   r   r   FunctionArgs	body_declr   r   ru   r   r   s         r   r   zBlockTag.__init__  s   444 8
 8
!8
 8
 8
 
 	+	
 	
 	
 	
 	
 ~~f%% 	d33 	-> '    	
vt44 	-5 9=9N   )NN62&&
 
*.*?
 
 	#R88+NN8R((
 
,0,A
 
r   Tc                     | j         d u S r
   r   r   s    r   r  zBlockTag.is_anonymous$  s    yD  r   c                 &    | j         p
d| j        fz  S )Nz__M_anon_%d)r   r   r   s    r   r   zBlockTag.funcname(  s    y:MT[N::r   c                 &     | j         j        di |S r`   )r  r   r   s     r   r   z!BlockTag.get_argument_expressions,  s    6t~6<<<<<r   c                     | j         j        S r
   r  r   r   s    r   rK   zBlockTag.declared_identifiers/      ~))r   c                     | j         j                            t          j                                                                      | j                  S r
   r   r   s    r   rL   zBlockTag.undeclared_identifiers2  sD    3>>',,..  %6
7
7		8r   )r%   r'   r(   r   r   r  r*   r  r   r   rK   rL   r:   r;   s   @r   r  r    s        K
 
 
 
 
B H! ! X! ; ; X;= = =* * *8 8 8 8 8 8 8r   r  c                   .     e Zd ZdZ fdZd Zd Z xZS )CallTagcallc                      t                      j        ||dddfi | |d         | _        t          j        | j        fi | j        | _        t          j        |                    dd          fi | j        | _	        d S )Nr}   )r   r   r.   )
r/   r   
expressionr   rh   r   rN   r  rW   r  r   s       r   r   zCallTag.__init__=  s    Z&9i	
 	
CI	
 	
 	
 %V,N4?LLd6KLL	)NN62&&
 
*.*?
 
r   c                 T    | j         j                            | j        j                  S r
   rN   rK   ry   r  r   r   s    r   rK   zCallTag.declared_identifiersG       y-33DN4NOOOr   c                 T    | j         j                            | j         j                  S r
   rN   rL   rz   rK   r   s    r   rL   zCallTag.undeclared_identifiersJ  '    y/::I*
 
 	
r   r   r;   s   @r   r  r  :  s^        K
 
 
 
 
P P P
 
 
 
 
 
 
r   r  c                   *     e Zd Z fdZd Zd Z xZS )r   c           	          t                      j        |dz   |z   |t          |                                          dz   ddfi | |d|dd                    d | j                                        D                       d| _        t          j	        | j        fi | j
        | _        t          j        |                    d	d
          fi | j
        | _        d S )Nr   )r}   r   .r   r   c              3   6   K   | ]\  }}|d k    |d|V  dS )r}   =Nr   )r   kvs      r   r   z,CallNamespaceTag.__init__.<locals>.<genexpr>^  sC        Aq;; 11aa ;;; r   r7   r}   r.   )r/   r   tupler   r   r   itemsr  r   rh   r   rN   r  rW   r  )r   r   r   r   rM   r$   s        r   r   zCallNamespaceTag.__init__Q  s   Og%*//##$$y0	
 	
 	
 	
 	
 IIGGHH   288::      
 N4?LLd6KLL	)NN62&&
 
*.*?
 
r   c                 T    | j         j                            | j        j                  S r
   r  r   s    r   rK   z%CallNamespaceTag.declared_identifiersj  r  r   c                 T    | j         j                            | j         j                  S r
   r  r   s    r   rL   z'CallNamespaceTag.undeclared_identifiersm  r  r   )r%   r'   r(   r   rK   rL   r:   r;   s   @r   r   r   P  sY        
 
 
 
 
2P P P
 
 
 
 
 
 
r   r   c                   "     e Zd ZdZ fdZ xZS )
InheritTaginheritc                 D     t                      j        ||dddfi | d S )Nr   r   )r/   r   r   s       r   r   zInheritTag.__init__v  s@    ZB		
 	
=C	
 	
 	
 	
 	
r   )r%   r'   r(   r   r   r:   r;   s   @r   r,  r,  s  s=        K
 
 
 
 
 
 
 
 
r   r,  c                   (     e Zd ZdZ fdZd Z xZS )PageTagpagec                 &   g dd |D             z   } t                      j        |||ddfi | t          j        |                    dd          fi | j        | _        t          j        |                    dd          fi | j        | _        d S )N)r   r}   expression_filterenable_loopc                 <    g | ]}|                     d           |S r   r   r   s     r   r   z$PageTag.__init__.<locals>.<listcomp>  s)    ===1all8&<&<=Q===r   r   r}   r.   r3  )	r/   r   r   r  rW   r   r  ru   r   )r   rE   r   rM   r   r$   s        r   r   zPageTag.__init__  s    
 
 

 >=
===> 	*k2rLLVLLL)NN62&&
 
*.*?
 
 +NN.33
 
7;7L
 
r   c                     | j         j        S r
   r  r   s    r   rK   zPageTag.declared_identifiers  r  r   r   r;   s   @r   r0  r0  |  sL        K
 
 
 
 
 * * * * * * *r   r0  )r)   r   makor   r   r   r   r   r,   r=   r^   re   rn   rr   r   r   r   r   r   r   r   r  r  r   r,  r0  r   r   r   <module>r8     s   < ; 				                               >
 
 
 
 
4 
 
 
&8
 8
 8
 8
 8
$ 8
 8
 8
vH H H H H4 H H H"
 "
 "
 "
 "
4 "
 "
 "
JH H H H Hd H H H
 
 
 
 
 
 
 
BA A A A At A A A>x
 x
 x
 x
 x
$( x
 x
 x
 x
vC C C C C C C C4    3   <8 8 8 8 8c 8 8 8<
 <
 <
 <
 <
S <
 <
 <
~98 98 98 98 98s 98 98 98x
 
 
 
 
c 
 
 
, 
  
  
  
  
s  
  
  
F
 
 
 
 
 
 
 
* * * * *c * * * * *r   