
    0Vh4                     \    d dl mZmZ d dlZd dlZ G d de      Z G d de      Zd Zd Zy)	    )	AstToGAst	GAstToAstNc                       e Zd Zd Zd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zy)
Ast2ToGAstc                 d    t        j                  | j                  |j                        g       }|S N)gastModule_visitbodyselfnodenew_nodes      9/home/dcms/DCMS/lib/python3.12/site-packages/gast/ast2.pyvisit_ModulezAst2ToGAst.visit_Module	   s*    ;;KK		"
     c           	      L   t        j                  | j                  |j                        | j                  |j                        | j                  |j
                        | j                  |j                        d d g       }t        j                  ||       d x|_        |_	        |S r   )
r	   FunctionDefr   nameargsr   decorator_listcopy_location
end_linenoend_col_offsetr   s      r   visit_FunctionDefzAst2ToGAst.visit_FunctionDef   s    ##KK		"KK		"KK		"KK++,
 	8T*8<<h5r   c           	      J   t        j                  | j                  |j                        | j                  |j                        g | j                  |j
                        | j                  |j                        g       }t        j                  ||       d x|_        |_	        |S r   )
r	   ClassDefr   r   basesr   r   r   r   r   r   s      r   visit_ClassDefzAst2ToGAst.visit_ClassDef   s    ==KK		"KK

#KK		"KK++,
 	8T*8<<h5r   c                     t        j                  | j                  |j                        | j                  |j                        d       }t        j
                  ||       d x|_        |_        |S r   )r	   Assignr   targetsvaluer   r   r   r   s      r   visit_AssignzAst2ToGAst.visit_Assign-   sZ    ;;KK%KK

#
 	8T*8<<h5r   c                 H   t        j                  | j                  |j                        | j                  |j                        | j                  |j
                        | j                  |j                        g       }t        j                  ||       d x|_        |_	        |S r   )
r	   Forr   targetiterr   orelser   r   r   r   s      r   	visit_ForzAst2ToGAst.visit_For8   sz    88KK$KK		"KK		"KK$
 	8T*8<<h5r   c                 <   t        j                  t        j                  | j                  |j                        | j                  |j
                              g| j                  |j                        d       }t        j                  ||       d x|_        |_	        |S r   )
r	   Withwithitemr   context_exproptional_varsr   r   r   r   r   s      r   
visit_WithzAst2ToGAst.visit_WithD   s    99]]D--.D../  KK		"
 	8T*8<<h5r   c                    | j                  |j                        }| j                  |j                        }| j                  |j                        }|}|<t	        j
                  ||gg       }t	        j                  ||       d x|_        |_        |t	        j                  |dt	        j                               }t	        j                  ||       d x|_        |_        t	        j
                  ||gg       }t	        j                  ||       d x|_        |_        t	        j                  |d       }t	        j                  ||       d x|_        |_        |S )Nwith_traceback)r   typeinsttbackr	   Callr   r   r   	AttributeLoadRaise)r   r   ntypeninstntbackwhatattrr   s           r   visit_RaisezAst2ToGAst.visit_RaiseQ   s#   DII&DII&TZZ(99UUGR0DtT*488DOd1>>$(8$))+FDtT*488DOd199D
 tT*488DOd1::dD)8T*8<<h5r   c                    t        j                  | j                  |j                        | j                  |j                        | j                  |j
                        g       }t        j                  ||       d x|_        |_        |S r   )	r	   Tryr   r   handlersr*   r   r   r   r   s      r   visit_TryExceptzAst2ToGAst.visit_TryExceptp   sj    88KK		"KK&KK$	
 	8T*8<<h5r   c                     t        j                  | j                  |j                        g g | j                  |j                              }t        j
                  ||       d x|_        |_        |S r   )r	   rB   r   r   	finalbodyr   r   r   r   s      r   visit_TryFinallyzAst2ToGAst.visit_TryFinally{   s]    88KK		"KK'	
 	8T*8<<h5r   c                     t        j                  | j                  |j                        | j                  |j                        d d       }t        j
                  ||       d x|_        |_        |S r   )r	   Namer   idctxr   r   r   r   s      r   
visit_NamezAst2ToGAst.visit_Name   s]    99KK KK!	
 	8T*8<<h5r   c                     t        j                  |j                  d       }t        j                  ||       d x|_        |_        |S r   )r	   Constantnr   r   r   r   s      r   	visit_NumzAst2ToGAst.visit_Num   A    ==FF
 	8T*8<<h5r   c                    | j                  |j                        }t        j                  | j                  |j                        || j                  |j
                              }t        j                  ||       d x|_        |_        |S r   )	r   slicer	   	Subscriptr$   rK   r   r   r   )r   r   	new_slicer   s       r   visit_SubscriptzAst2ToGAst.visit_Subscript   sl    KK

+	>>KK

#KK!

 	8T*8<<h5r   c                     t        j                  t        d       }t        j                  ||       d x|_        |_        |S r   )r	   rN   Ellipsisr   r   r   r   s      r   visit_EllipsiszAst2ToGAst.visit_Ellipsis   s=    ==
 	8T*8<<h5r   c                 8    | j                  |j                        S r   )r   r$   )r   r   s     r   visit_IndexzAst2ToGAst.visit_Index   s    {{4::&&r   c                     | j                  |j                        }t        j                  |t        j                               }t        j
                  ||       d x|_        |_        |S r   )r   dimsr	   Tupler9   r   r   r   )r   r   new_dimsr   s       r   visit_ExtSlicezAst2ToGAst.visit_ExtSlice   sO    ;;tyy)::h		48T*8<<h5r   c                     t        j                  |j                  d       }t        j                  ||       d x|_        |_        |S r   )r	   rN   sr   r   r   r   s      r   	visit_StrzAst2ToGAst.visit_Str   rQ   r   c                    |j                   rit        j                  | j                  |j                         t        j                               }t        j
                  ||       d x|_        |_        |g}ng }|j                  r1t        j                  d | j                  |j                              g}ng }t        j                  | j                  |j                        | j                  |j                        |z   | j                  |j                        |z         }t        j
                  ||       d x|_        |_        |S r   )starargsr	   Starredr   r9   r   r   r   kwargskeywordr7   funcr   keywords)r   r   starstarredrg   r   s         r   
visit_CallzAst2ToGAst.visit_Call   s    ==<<DMM :DIIKHDtT*488DOd1fGG;;ll4T[[)ABCFF99KK		"KK		"W,KK&/

 	8T*8<<h5r   c                    t        j                  | j                  |j                        | j                  |j                        | j                  |j
                        d      }t        j                  ||       d x|_        |_        |S )Nr   )r(   r)   ifsis_async)	r	   comprehensionr   r(   r)   ro   r   r   r   r   s      r   visit_comprehensionzAst2ToGAst.visit_comprehension   sl    %%;;t{{+TYY'DHH%	
 	8T*8<<h5r   c                 b   |j                   r3t        j                  |j                   t        j                               }nd }|j                  r3t        j                  |j                  t        j                               }nd }|j                   r3t        j                  |j                   t        j                               }nd }t        j                  | j                  |j                        g | j                  |      g g | j                  |      | j                  |j                              }|S r   )
varargastrI   Paramkwargr	   	argumentsr   r   defaultsr   r   rt   rw   r   s        r   visit_argumentszAst2ToGAst.visit_arguments   s    ;;XXdkk399;7FF::HHTZZ5EE;;XXdkk399;7FF>>KK		"KKKKKK&
 r   c                     t        j                  | j                  |j                        | j                  |j                              }d x|_        |_        d x|_        |_        |S r   )	r	   aliasr   r   asnamelineno
col_offsetr   r   r   s      r   visit_aliaszAst2ToGAst.visit_alias  sV    ::KK		"KK$
 154(-8<<h5r   N)__name__
__module____qualname__r   r   r    r%   r+   r1   r@   rD   rG   rL   rP   rV   rY   r[   r`   rc   rm   rr   r{   r    r   r   r   r      sf    	
>				'.	8r   r   c                   f    e Zd Zd Zd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd Zd Zd Zd Zd Zy)
GAstToAst2c                 b    t        j                  | j                  |j                              }|S r   )ru   r
   r   r   r   s      r   r   zGAstToAst2.visit_Module  s"    ::dkk$))45r   c                 *   t        j                  | j                  |j                        | j                  |j                        | j                  |j
                        | j                  |j                              }|j                  j                  r*t        j                  |j                  j                  |       |j                  j                  r*t        j                  |j                  j                  |       t        j                  ||       |S r   )
ru   r   r   r   r   r   r   rt   r   rw   r   s      r   r   zGAstToAst2.visit_FunctionDef  s    ??KK		"KK		"KK		"KK++,	
 99dii..599??diioot4(D)r   c                 *   t        j                  | j                  |j                        | j                  |j                        | j                  |j
                        | j                  |j                              }t        j                  ||       |S r   )ru   r   r   r   r   r   r   r   r   s      r   r    zGAstToAst2.visit_ClassDef$  si    <<KK		"KK

#KK		"KK++,	
 	(D)r   c                     t        j                  | j                  |j                        | j                  |j                              }t        j
                  ||       |S r   )ru   r"   r   r#   r$   r   r   s      r   r%   zGAstToAst2.visit_Assign/  sG    ::KK%KK

#

 	(D)r   c                 *   t        j                  | j                  |j                        | j                  |j                        | j                  |j
                        | j                  |j                              }t        j                  ||       |S r   )ru   r'   r   r(   r)   r   r*   r   r   s      r   r+   zGAstToAst2.visit_For8  sg    77KK$KK		"KK		"KK$	
 	(D)r   c                 *   t        j                  | j                  |j                  d   j                        | j                  |j                  d   j
                        | j                  |j                              }t        j                  ||       |S )Nr   )ru   r-   r   itemsr/   r0   r   r   r   s      r   r1   zGAstToAst2.visit_WithC  sk    88KK

1223KK

1334KK		"

 	(D)r   c                 4   t        |j                  t        j                        rt        |j                  j                  t        j
                        r{|j                  j                  j                  dk(  rX| j                  |j                  j                  j                        }| j                  |j                  j                  d         }n| j                  |j                        }d }t        j                  |d |      }t        j                  ||       |S )Nr3   r   )
isinstanceexcr	   r7   ri   r8   r?   r   r$   r   ru   r:   r   )r   r   raised	tracebackr   s        r   r@   zGAstToAst2.visit_RaiseL  s    dhh		*dhhmmT^^488==!11[[!4!45FDHHMM!$45I[[*FI99VT95(D)r   c                    |j                   rIt        j                  | j                  |j                        | j                  |j                               }nbt        j
                  | j                  |j                        | j                  |j                        | j                  |j                              }t        j                  ||       |S r   )	rF   ru   
TryFinallyr   r   	TryExceptrC   r*   r   r   s      r   	visit_TryzGAstToAst2.visit_TryY  s    >>~~DII&DNN+H
 }}DII&DMM*DKK(H
 	(D)r   c                     t        j                  | j                  |j                        | j                  |j                              }t        j
                  ||       |S r   )ru   rI   r   rJ   rK   r   r   s      r   rL   zGAstToAst2.visit_Namej  sG    88KK KK!
 	(D)r   c                 \   t        |j                  t        t        t        t
        t        f      r t        j                  |j                        }nF|j                  t        u rt        j                         }nt        j                  |j                        }t        j                  ||       |S r   )r   r$   boolintlongfloatcomplexru   NumrX   Strr   r   s      r   visit_ConstantzGAstToAst2.visit_Constantr  sk    djj4dE7"CDwwtzz*HZZ8#||~Hwwtzz*H(D)r   c           
      T   d }t        |j                  t        j                        rMt	        j
                  |j                  j                  D cg c]  } || j                  |             c}      }n! || j                  |j                              }t	        j                  ||j                         t	        j                  | j                  |j                        || j                  |j                              }t	        j                  ||       d x|_        |_        |S c c}w )Nc                     t        | t        j                  t        j                  f      r| S t        j                  |       S r   )r   ru   SlicerX   Index)rb   s    r   adjust_slicez0GAstToAst2.visit_Subscript.<locals>.adjust_slice}  s,    !cii67yy|#r   )r   rS   r	   r^   ru   ExtSliceeltsr   r   rT   r$   rK   r   r   )r   r   r   eltrU   r   s         r   rV   zGAstToAst2.visit_Subscript|  s    	$
 djj$**-15&B*- '34;;s3C&D &B CI %T[[%<=I)TZZ0==KK

#KK!

 	(D)8<<h5&Bs   D%c           	         |j                   rPt        |j                   d   t        j                        r)|j                   d d }|j                   d   j                  }n|j                   }d }|j
                  rB|j
                  d   j                  )|j
                  d d }|j
                  d   j                  }n|j
                  }d }t        j                  | j                  |j                        | j                  |      | j                  |      | j                  |      | j                  |            }t        j                  ||       |S )N)r   r   r	   rf   r$   rj   argru   r7   r   ri   r   )r   r   r   re   rj   rg   r   s          r   rm   zGAstToAst2.visit_Call  s    99DIIbM4<<@99Sb>Dyy}**H99DH==T]]2.22:}}Sb)H]]2&,,F}}HF88KK		"KKKK!KK!KK
 	(D)r   c                     t        j                  |j                  t        j                               }t        j                  ||       |S r   )ru   rI   r   rv   r   r   s      r   	visit_argzGAstToAst2.visit_arg  s1    88DHHciik2(D)r   c                 f   |j                   xr |j                   j                  }|j                  xr |j                  j                  }t        j                  | j                  |j                        | j                  |      | j                  |      | j                  |j                              }|S r   )rt   rJ   rw   ru   rx   r   r   ry   rz   s        r   r{   zGAstToAst2.visit_arguments  s{    /

,tzz}}==KK		"KKKKKK&	
 r   c                     t        j                  | j                  |j                        | j                  |j                              }|S r   )ru   r}   r   r   r~   r   s      r   r   zGAstToAst2.visit_alias  s7    99KK		"KK$
 r   N)r   r   r   r   r   r    r%   r+   r1   r@   r   rL   r   rV   rm   r   r{   r   r   r   r   r   r     sM    
 		",2
r   r   c                 4    t               j                  |       S r   )r   visitr   s    r   ast_to_gastr         <d##r   c                 4    t               j                  |       S r   )r   r   r   s    r   gast_to_astr     r   r   )	astnr   r   ru   r	   r   r   r   r   r   r   r   <module>r      s6    % 
 C CLv vr$$r   