o
    "a<                     @   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 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d-d,defffd.d/defffd0d1defffd2d3defffd4d5defffd6d7defffd8d9defffd:d5defffd;d5d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dBdCdefffdDdEdefffdFdGdefffdHdIdefffdJd)defffdKdLdefffdMdNdefffdOdPdefffdQdPdefffdRdSdefffdTdPdefffdUddefffdVddefffdWddefffdXdYd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dadbd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dmdldefffdnddefffdoddefffdpddefffdqddefffdrddefffdsddefffdtdud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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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dddefffR ZeD ]\ZZeegeR   qejjdkrddlmZmZ ejjdkrddlmZm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                   @   s   e Zd ZdS )r   N)__name__
__module____qualname__ r   r   +/usr/lib/python3/dist-packages/gast/gast.pyr   
   s    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argnameZargvalr   ZNBFieldsNamer   r   create_node   s   "z_make_node.<locals>.create_node)__init___fields_attributes)r   r   _sysmodulesr   type)r$   r   Z
AttributesZBasesr%   r   r#   r   
_make_node   s   
r,   Module)bodytype_ignoresr   ZInteractive)r.   Z
ExpressionFunctionType)argtypesreturnsZSuiteFunctionDef)namer    r.   decorator_listr2   type_commentlineno
col_offset
end_linenoend_col_offsetZAsyncFunctionDefClassDef)r4   baseskeywordsr.   r5   ZReturn)valueZDelete)targetsZAssign)r@   r?   r6   Z	AugAssign)targetopr?   Z	AnnAssign)rA   
annotationr?   simpleZPrint)destvaluesnlZFor)rA   iterr.   orelser6   ZAsyncForZWhile)testr.   rI   ZIfZWith)r   r.   r6   Z	AsyncWithZRaise)exccauseZTry)r.   handlersrI   	finalbodyZAssert)rJ   msgZImport)namesZ
ImportFrom)modulerP   levelExec)r.   globalslocalsZGlobalZNonlocalExprZPassZBreakZContinueZBoolOp)rB   rF   Z	NamedExpr)rA   r?   ZBinOp)leftrB   rightZUnaryOp)rB   operandZLambda)r    r.   ZIfExpZDict)keysrF   Set)eltsZListComp)elt
generatorsZSetCompZDictComp)keyr?   r^   ZGeneratorExpZAwaitZYieldZ	YieldFromZCompare)rW   opscomparatorsZCall)funcr    r>   ReprZFormattedValue)r?   
conversionformat_specZ	JoinedStr)rF   Constant)r?   kindZ	Attribute)r?   attrctxZ	Subscript)r?   r   ri   ZStarred)r?   ri   r$   )idri   rC   r6   ZList)r\   ri   ZTupleZLoadZStoreZDelZAugLoadZAugStoreZParamZSlice)lowerupperstepZAndZOrZAddZSubZMultZMatMultZDivZModZPowZLShiftZRShiftZBitOrZBitXorZBitAndZFloorDivZInvertZNotZUAddZUSubZEqZNotEqZLtZLtEZGtZGtEZIsZIsNotZInZNotInZcomprehension)rA   rH   ifsis_asyncZExceptHandler)r+   r4   r.   Z	arguments)r    posonlyargsvararg
kwonlyargskw_defaultskwargdefaultskeyword)argr?   alias)r4   asnameZwithitem)context_exproptional_varsZtype_ignore)r8   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   2  s   r   c                 C   s   t | tr	t| } t| S r   )
isinstancer   r   r   literal_eval)Znode_or_stringr   r   r   r   6  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   r3   r<   r-   r   	__class__r   r.   rV   r?   rf   inspectZcleandocgetattrr'   s)nodeZcleanr   Zholderr   r   r   get_docstring<  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*.
    r7   )r(   hasattrr   r   )Znew_nodeZold_noderh   r   r   r   copy_locationJ  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 )Nr8   r:   r9   r;   )r(   r   r8   r:   r9   r;   r   )r   r8   r9   r:   r;   child_fixr   r   r   _  s&   







z#fix_missing_locations.<locals>._fixr~   r   r   )r   r   r   r   fix_missing_locationsW  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.
    r8   r   r:   )r   r(   r   r8   r:   )r   nr   r   r   r   increment_linenoz  s   

r   )T)r~   )#sysr)   astr   r   r   r   r   r   r   r   r	   r
   r   r   r   r   r   ImportErrorr,   Z_nodesr4   Zdescrversion_infomajorZast2r   r   Zast3r   r   r   r   r   r   r   r   r   r   <module>   s    	"%(+.147:=@CFILORUWY_behknqtwz}                     !  $  '  *  -  0  5  6  7  8  9  :  =  B  C  F  G  H  I  J  K  L  M  N  O  P  Q  R  U  V  W  X  [  \  ]  ^  _  `  a  b  c  d  g  j  p  t  y  ~       
#