o
    i eC                     @   s  d dl Zd dlZd dlmZmZmZmZmZm	Z	 d dlm
Z
mZmZmZmZ d dlmZmZ zd dlmZ W n eyG   G dd deZY nw zd dlmZ W n eya   G d	d
 d
eZY nw dd Zg dddefffdddefffdddefffdddefffdddefffdddefffdddefffdddefffdddefffdddefffd d!defffd"d#defffd$d%defffd&d'defffd(d)defffd*d)defffd+d,defffd-d,defffd.d/defffd0d/defffd1d2defffd3d4defffd5d6defffd7d6defffd8d9defffd:d;defffd<d=defffd>d?defffd@d;defffdAd;defffdBddefffdCddefffdDddefffdEddefffdFdGdefffdHdIdefffdJdKdefffdLdMdefffdNdOdefffdPd,defffdQdRdefffdSdTdefffdUdVdefffdWdVdefffdXdYdefffdZdVdefffd[ddefffd\ddefffd]ddefffd^d_defffd`dadefffdbddefffdcdddefffdedfdefffdgdhdefffdidjdefffdkdldefffdmdndefffdodpdefffdqdrdefffdsdrdefffdtddefffduddefffdvddefffdwddefffdxddefffdyddefffdzd{de
fffd|ddefffd}ddefffd~dde	fffddde	fffddde	fffddde	fffddde	fffddde	fffddde	fffddde	fffddde	fffddde	fffddde	fffddde	fffddde	fffdddeefffdddeefffdddeefffdddeefffdddefffdddefffdddefffdddefffdddefffdddefffdddefffdddefffdddefffdddefffdddefffdddefffdddefffdddefffdddefffdddefffdddefffdddefffdddefffdddefffdddefffdddefffdddefffdddefffdddefffdddefffR ZeD ]\ZZeegeR   qejjdkrddlmZmZ ejjdkr#ddlmZmZ dd Zdd Zdd Z dddZ!ddĄ Z"ddƄ Z#dddȄZ$dS )    N)boolopcmpopexcepthandlerexprexpr_contextoperator)slicestmtunaryopmodAST)iter_child_nodeswalk)
TypeIgnorec                   @      e Zd ZdS )r   N__name__
__module____qualname__ r   r   8/var/www/myenv/lib/python3.10/site-packages/gast/gast.pyr   
       r   )patternc                   @   r   )r   Nr   r   r   r   r   r      r   r   c              
      s>   t   fdd}ttjt t|| |d d S )Nc                    s   |r+t |t  fdd|D  krtdt |D ]
\}}t| || q |r<| D ]\}}t| || q1d S d S )Nc                    s   g | ]}| v r|qS r   r   ).0k)Fieldsr   r   
<listcomp>   s    z3_make_node.<locals>.create_node.<locals>.<listcomp>z7{} constructor takes either 0 or {} mandatory arguments)len	TypeErrorformatzipsetattritems)selfargskwargsargnameargvalr   NBFieldsNamer   r   create_node   s   "z_make_node.<locals>.create_node)__init___fields_attributes)r   r!   _sysmodulesr   type)r*   r   
AttributesBasesr+   r   r(   r   
_make_node   s   
r4   Module)bodytype_ignoresr   Interactive)r6   
ExpressionFunctionType)argtypesreturnsSuiteFunctionDef)namer$   r6   decorator_listr<   type_commentlineno
col_offset
end_linenoend_col_offsetAsyncFunctionDefClassDef)r?   baseskeywordsr6   r@   Return)valueDelete)targetsAssign)rN   rL   rA   	AugAssign)targetoprL   	AnnAssign)rQ   
annotationrL   simplePrint)destvaluesnlFor)rQ   iterr6   orelserA   AsyncForWhile)testr6   r\   IfWith)r"   r6   rA   	AsyncWithMatch)subjectcasesRaise)exccauseTry)r6   handlersr\   	finalbodyTryStarAssert)r_   msgImport)names
ImportFrom)modulerp   levelExec)r6   globalslocalsGlobalNonlocalExprPassBreakContinueBoolOp)rR   rX   	NamedExpr)rQ   rL   BinOp)leftrR   rightUnaryOp)rR   operandLambda)r$   r6   IfExpDict)keysrX   Set)eltsListComp)elt
generatorsSetCompDictComp)keyrL   r   GeneratorExpAwaitYield	YieldFromCompare)r   opscomparatorsCall)funcr$   rJ   ReprFormattedValue)rL   
conversionformat_spec	JoinedStr)rX   Constant)rL   kind	Attribute)rL   attrctx	Subscript)rL   r   r   Starred)rL   r   r*   )idr   rT   rA   List)r   r   TupleLoadStoreDelAugLoadAugStoreParamSlice)lowerupperstepAndOrAddSubMultMatMultDivModPowLShiftRShiftBitOrBitXorBitAndFloorDivInvertNotUAddUSubEqNotEqLtLtEGtGtEIsIsNotInNotIncomprehension)rQ   r[   ifsis_asyncExceptHandler)r1   r?   r6   	arguments)r$   posonlyargsvararg
kwonlyargskw_defaultskwargdefaultskeyword)argrL   alias)r?   asnamewithitem)context_exproptional_vars
match_case)r   guardr6   
MatchValueMatchSingletonMatchSequence)patternsMatchMapping)r   r   rest
MatchClass)clsr   	kwd_attrskwd_patterns	MatchStar)r?   MatchAs)r   r?   MatchOrtype_ignore)rC   tag      )ast_to_gastgast_to_ast   c                  O   s   t tj| i |S N)r   _astparse)r$   r%   r   r   r   r   b  s   r   c                 C   s   ddl m} || S )Nr   )unparse)unparserr   )gast_objr   r   r   r   r   f  s   r   c                 C   s   t | tr	t| } t| S r   )
isinstancer   r   r   literal_eval)node_or_stringr   r   r   r   k  s   

r   Tc                 C   s   t | tttfstd| jj | jrBt | jd trDt | jd j	t
rF|r;dd l}| jd j	}|t||jd S | jd j	jS d S d S d S )Nz%r can't have docstringsr   )r   r>   rH   r5   r   	__class__r   r6   ry   rL   r   inspectcleandocgetattrr-   s)nodecleanr  holderr   r   r   get_docstringq  s   r  c                 C   s>   dD ]}||j v r|| j v rt||rt| |t|| q| S )z
    Copy source location (`lineno`, `col_offset`, `end_lineno`, and
    `end_col_offset` attributes) from *old_node* to *new_node* if possible,
    and return *new_node*.
    rB   )r.   hasattrr!   r  )new_nodeold_noder   r   r   r   copy_location  s   r  c                    s     fdd  | dddd | S )a{  
    When you compile a node tree with compile(), the compiler expects lineno
    and col_offset attributes for every node that supports them.  This is
    rather tedious to fill in for generated nodes, so this helper adds these
    attributes recursively where not already set, by setting them to the values
    of the parent node.  It works recursively starting at *node*.
    c                    s   d| j v rt| ds|| _n| j}d| j v r"t| ds|| _n| j}d| j v r3t| ds0|| _n| j}d| j v rDt| dsA|| _n| j}t| D ]
} ||||| qHd S )NrC   rE   rD   rF   )r.   r	  rC   rE   rD   rF   r   )r  rC   rD   rE   rF   child_fixr   r   r    s&   







z#fix_missing_locations.<locals>._fixr   r   r   )r  r   r  r   fix_missing_locations  s   r  c                 C   sR   t | D ]"}d|jv rt|ddpd| |_d|jv r&t|ddp"d| |_q| S )z
    Increment the line number and end line number of each node in the tree
    starting at *node* by *n*. This is useful to "move code" to a different
    location in a file.
    rC   r   rE   )r   r.   r  rC   rE   )r  nr  r   r   r   increment_lineno  s   

r  )T)r   )%sysr/   astr   r   r   r   r   r   r   r   r	   r
   r   r   r   r   r   ImportErrorr   r4   _nodesr?   descrversion_infomajorast2r   r   ast3r   r   r   r  r  r  r  r   r   r   r   <module>   s    	"%(+.147:=@CFILORUX[]_ehknqtwz}                     !  $  '  *  -  0  3  6  ;  <  =  >  ?  @  C  H  I  L  M  N  O  P  Q  R  S  T  U  V  W  X  [  \  ]  ^  a  b  c  d  e  f  g  h  i  j  m  p  v  z                                     "    &    ,    /
#