Your IP : 3.145.92.96


Current Path : /opt/alt/python39/lib64/python3.9/__pycache__/
Upload File :
Current File : //opt/alt/python39/lib64/python3.9/__pycache__/ast.cpython-39.opt-2.pyc

a

R�fs��@s�ddlZddlTddlmZmZddlmZmZd_ddd�d	d
�Zdd�Z	d`dd�dd�Z
dd�Zdd�Zdadd�Z
dd�Zdd�Zdbdd�Zdd�Zd d!�Zdd"�d#d$�Zd%d&�ZGd'd(�d(e�ZGd)d*�d*e�Zeed+��sd,d-�Zd.d/�Zeee�e_eee�e_Gd0d1�d1e�Z d2d3�Z!Gd4d5�d5ee d6�Z"Gd7d8�d8ee d6�Z#Gd9d:�d:ee d6�Z$Gd;d<�d<ee d6�Z%Gd=d>�d>ee d6�Z&e"e'e(e)fe#e*fe$e+fe%ed�e,fe&ed?�fiZ-e"e,fiZ.e,d<ed�d<e'd5e(d5e)d5e*d8e+d:ed?�d>iZ/Gd@dA�dAe0�Z1GdBdC�dCe1�Z2GdDdE�dEe1�Z3ee4dF��sBdGdH�Z5dIdJ�Z6ee5e6�e4_7GdKdL�dLe8�Z9GdMdN�dNe:�Z;GdOdP�dPe:�Z<GdQdR�dRe:�Z=dSe>ej?j@d�ZAGdTdU�dUe�ZBdVZCdWZDgeC�eD�RZEGdXdY�dYe�ZFdZd[�ZGd\d]�ZHeId^k�r�eH�dS)c�N)�*)�contextmanager�nullcontext)�IntEnum�auto�	<unknown>�execF)�
type_comments�feature_versioncCsFt}|r|tO}t|t�r(|\}}|}n|dur4d}t|||||d�S)N���)�_feature_version)Z
PyCF_ONLY_ASTZPyCF_TYPE_COMMENTS�
isinstance�tuple�compile)�source�filename�moder	r
�flags�major�minor�r�(/opt/alt/python39/lib64/python3.9/ast.py�parse!s

�rcs`t|t�rt|dd�}t|t�r&|j}dd���fdd���fdd������fd	d
���|�S)N�eval�rcSstd|����dS)Nzmalformed node or string: )�
ValueError��noderrr�_raise_malformed_nodeAsz+literal_eval.<locals>._raise_malformed_nodecs,t|t�rt|j�tttfvr&�|�|jS�N)r
�Constant�type�value�int�float�complexr)rrr�_convert_numCsz"literal_eval.<locals>._convert_numcsDt|t�r<t|jttf�r<�|j�}t|jt�r6|
S|S�|�Sr)r
ZUnaryOp�op�UAdd�USub�operand)rr*)r&rr�_convert_signed_numGs
z)literal_eval.<locals>._convert_signed_numcsZt|t�r|jSt|t�r*tt�|j��St|t�rDtt�|j��St|t	�r^t
t�|j��St|t�r�t|jt
�r�|jjdkr�|j|jkr�gkr�nnt
�St|t�r�t|j�t|j�krȈ|�ttt�|j�t�|j���St|t��rRt|jttf��rR�|j�}�|j�}t|ttf��rRt|t��rRt|jt��rJ||S||S�|�S)N�set) r
r r"�Tupler�map�elts�List�list�Setr,ZCall�func�Name�id�args�keywords�Dict�len�keys�values�dict�zipZBinOpr'�Add�Sub�left�rightr#r$r%)rr@rA��_convertr&r+rrrrCOs<




���


�

zliteral_eval.<locals>._convert)r
�strrZ
Expression�body)Znode_or_stringrrBr�literal_eval6s

rFT)�indentcsTd����fdd�	�t|t�s.td|jj���durHt�t�sHd���|�dS)Nrc	s��dur*�d7�d��}d��}nd}d}t|t��r�t|�}g}d}�}|jD]�}zt||�}	Wnty�d}YqXYn0|	dur�t||d�dur�d}qX�|	��\}	}
|o�|
}|r�|�d||	f�qX|�|	�qX��rh|j�rh|jD]t}zt||�}	Wnt�yYq�Yn0|	du�r<t||d�du�r<q�|	��\}	}
|�oR|
}|�d||	f�q�|�r�t|�d	k�r�d
|j	j
d�|�f|fSd|j	j
||�|�fdfSt|t��r�|�s�d
Sd||���fdd�|D��fdfSt
|�dfS)N��
z,
��, T.z%s=%s�z%s(%s)z%s(%s%s)F)z[]Tz[%s%s]c3s|]}�|��dVqdS�rNr)�.0�x)�_format�levelrr�	<genexpr>��z(dump.<locals>._format.<locals>.<genexpr>)r
�ASTr!�_fields�getattr�AttributeError�append�_attributesr9�	__class__�__name__�joinr1�repr)rrQ�prefix�sep�clsr6Z	allsimpler7�namer"�simple�rP�annotate_fields�include_attributesrG)rQrrPxsX




&zdump.<locals>._formatzexpected AST, got %r� )r)r
rT�	TypeErrorrZr[rD)rrdrerGrrcr�dumpls0
rhcCsVdD]L}||jvr||jvrt||d�}|dusDt||�r|�d�rt|||�q|S)N)�lineno�
col_offset�
end_lineno�end_col_offsetZend_)rYrV�hasattr�
startswith�setattr)�new_nodeZold_node�attrr"rrr�
copy_location�s��rrcs �fdd���|dddd�|S)Ncs�d|jvr"t|d�s||_n|j}d|jvrJt|dd�durD||_n|j}d|jvrlt|d�sf||_n|j}d|jvr�t|dd�dur�||_n|j}t|�D]}�|||||�q�dS)Nrirkrjrl)rYrmrirVrkrjrl�iter_child_nodes)rrirjrkrl�child��_fixrrrv�s$





z#fix_missing_locations.<locals>._fixrHrrrrrur�fix_missing_locations�srwrHcCsVt|�D]H}d|jvr(t|dd�||_d|jvrt|dd�}dur|||_q|S)Nrirrk)�walkrYrVrirk)r�nrtrkrrr�increment_lineno�s
��rzc	cs8|jD],}z|t||�fVWqty0Yq0qdSr)rUrVrW)r�fieldrrr�iter_fields�s

r|ccsLt|�D]>\}}t|t�r"|Vqt|t�r|D]}t|t�r0|Vq0qdSr)r|r
rTr1)rrar{�itemrrrrss


rscCs�t|ttttf�s"td|jj��|jr8t|jdt	�s<dS|jdj
}t|t�rZ|j}n"t|t
�rxt|j
t�rx|j
}ndS|r�ddl}|�|�}|S)Nz%r can't have docstringsr)r
�AsyncFunctionDef�FunctionDef�ClassDef�ModulergrZr[rE�Exprr"�Str�sr rD�inspectZcleandoc)rZclean�textr�rrr�
get_docstrings	

r�cCs�d}g}d}|t|�krx||}||7}|d7}|dkr`|t|�kr`||dkr`|d7}|d7}|dvr|�|�d}q|r�|�|�|S)NrrJrH�
rIz
)r9rX)r�idx�linesZ	next_line�crrr�_splitlines_no_ff(s  

r�cCs,d}|D]}|dvr||7}q|d7}q|S)NrJz	rfr)r�resultr�rrr�_pad_whitespaceAs

r�)�paddedcCsz>|jdus|jdurWdS|jd}|jd}|j}|j}WntyRYdS0t|�}||kr|||��||���S|r�t||��d|����}nd}|||��|d���}	||��d|���}
||d|�}|�	d|	�|�
|
�d�|�S)NrHrJr)rkrlrirjrWr��encode�decoder��insertrXr\)rrr�rirkrjrlr�Zpadding�firstZlastrrr�get_source_segmentLs*	



r�ccs<ddlm}||g�}|r8|��}|�t|��|VqdS)Nr)�deque)�collectionsr��popleft�extendrs)rr�Ztodorrrrxqs
rxc@s$eZdZdd�Zdd�Zdd�ZdS)�NodeVisitorcCs"d|jj}t|||j�}||�S)N�visit_)rZr[rV�
generic_visit)�selfr�method�visitorrrr�visit�szNodeVisitor.visitcCsTt|�D]F\}}t|t�r:|D]}t|t�r|�|�qqt|t�r|�|�qdSr)r|r
r1rTr�)r�rr{r"r}rrrr��s


zNodeVisitor.generic_visitc	Cs�|j}t�t|��}|dur@t��D]\}}t||�r$|}q@q$|dur�d|}zt||�}WntypYn&0ddl}|�	|�d�t
d�||�S|�|�S)Nr�rz" is deprecated; add visit_Constant�)r"�_const_node_type_names�getr!�itemsr
rVrW�warnings�warn�DeprecationWarningr�)	r�rr"Z	type_namer`rar�r�r�rrr�visit_Constant�s&
�zNodeVisitor.visit_ConstantN)r[�
__module__�__qualname__r�r�r�rrrrr�s
r�c@seZdZdd�ZdS)�NodeTransformercCs�t|�D]�\}}t|t�rvg}|D]D}t|t�r\|�|�}|durFq"nt|t�s\|�|�q"|�|�q"||dd�<qt|t�r|�|�}|dur�t||�qt|||�q|Sr)	r|r
r1rTr�r�rX�delattrro)r�rr{�	old_valueZ
new_valuesr"rprrrr��s&






zNodeTransformer.generic_visitN)r[r�r�r�rrrrr��s$r�rycCs|jSr�r"�r�rrr�_getter�sr�cCs
||_dSrr��r�r"rrr�_setter�sr�c@seZdZdd�Zdd�ZdS)�_ABCcGs
d|_dS)Nz3Deprecated AST node class. Use ast.Constant instead)�__doc__)r`r6rrr�__init__sz
_ABC.__init__cCsdt|t�sdS|tvrXz
|j}Wnty4YdS0t|t|�oVt|t�|d��St�||�S)NFr)	r
r �_const_typesr"rW�_const_types_notr�r!�__instancecheck__)r`�instr"rrrr�s

�z_ABC.__instancecheck__N)r[r�r�r�r�rrrrr�sr�cOsp|D]<}||jvrq|j�|�}|t|�krt|j�d|����q|tvrXt|i|��Stj|g|�Ri|��S)Nz" got multiple values for argument )rU�indexr9rgr[r�r �__new__)r`r6�kwargs�key�posrrr�_news
r�c@seZdZdZeZdS)�Num)ryN�r[r�r�rUr�r�rrrrr�#sr�)�	metaclassc@seZdZdZeZdS)r��r�Nr�rrrrr�'sr�c@seZdZdZeZdS)�Bytesr�Nr�rrrrr�+sr�c@seZdZeZdS)�NameConstantN)r[r�r�r�r�rrrrr�/sr�c@seZdZdZdd�ZdS)�EllipsisrcOs6|turtdg|�Ri|��Stj|g|�Ri|��S)N.)r�r r�)r`r6r�rrrr�5szEllipsis.__new__N)r[r�r�rUr�rrrrr�2sr�.c@seZdZdS)�sliceN�r[r�r�rrrrr�Psr�c@seZdZdd�ZdS)�IndexcKs|Srr)r`r"r�rrrr�Usz
Index.__new__N�r[r�r�r�rrrrr�Ssr�c@seZdZddd�ZdS)�ExtSlicercKstt|�t�fi|��Sr)r-r1ZLoad)r`�dimsr�rrrr�ZszExtSlice.__new__N)rr�rrrrr�Xsr�r�cCs|jSr�r/r�rrr�_dims_getterbsr�cCs
||_dSrr�r�rrr�_dims_setterfsr�c@seZdZdS)�SuiteNr�rrrrr�ksr�c@seZdZdS)�AugLoadNr�rrrrr�nsr�c@seZdZdS)�AugStoreNr�rrrrr�qsr�c@seZdZdS)�ParamNr�rrrrr�tsr�Z1ec@s~eZdZe�Ze�Ze�Ze�Ze�Ze�Z	e�Z
e�ZeZe�Z
e�Ze�Ze�Ze�Ze�Ze�Ze�Ze�Zdd�ZdS)�_PrecedencecCs,z|�|d�WSty&|YS0dS�NrH)rZrr�rrr�next�sz_Precedence.nextN)r[r�r�r�TUPLE�YIELD�TEST�OR�AND�NOT�CMP�EXPR�BOR�BXOR�BAND�SHIFT�ARITH�TERM�FACTOR�POWER�AWAIT�ATOMr�rrrrr�|s&r�)�'�")z"""z'''cs�eZdZdd�dd�Zdd�Zdd�Zd	d
�Zd�dd
�Zdd�Zdd�Z	e
dd��Zedd�dd��Z
edd��Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�Z�fd&d'�Zd(d)�Zd*d+�Zd,d-�Zd.d/�Zd0d1�Zd2d3�Zd4d5�Zd6d7�Zd8d9�Zd:d;�Zd<d=�Z d>d?�Z!d@dA�Z"dBdC�Z#dDdE�Z$dFdG�Z%dHdI�Z&dJdK�Z'dLdM�Z(dNdO�Z)dPdQ�Z*dRdS�Z+dTdU�Z,dVdW�Z-dXdY�Z.dZd[�Z/d\d]�Z0d^d_�Z1d`da�Z2dbdc�Z3ddde�Z4dfdg�Z5dhdi�Z6djdk�Z7dldm�Z8dndo�Z9e:ddp�dqdr�Z;e:ds�dtdu�Z<dvdw�Z=dxdy�Z>dzd{�Z?d|d}�Z@d~d�ZAd�d��ZBd�d��ZCd�d��ZDd�d��ZEd�d��ZFd�d��ZGd�d��ZHd�d��ZId�d��ZJd�d��ZKd�d��ZLd�d��ZMd�d��ZNd�d��ZOd�d�d�d�d��ZPeQjReQjSeQjSeQjSd��ZTd�d��ZUd�d�d�d�d�d�d�d�d�d�d�d�d�d��
ZVeQjWeQjWeQjXeQjXeQjXeQjXeQjYeQjYeQjZeQj[eQj\eQjXeQj]d��
Z^e_d��Z`d�d��Zad�d�d�d�d�d�d�d�d�d�d��
Zbd�d��Zcd�d�dÜZdeQjeeQjfdĜZgd�dƄZhd�dȄZid�dʄZjd�d̄Zkd�d΄Zld�dЄZmd�d҄Znd�dԄZod�dքZpd�d؄Zqd�dڄZrd�d܄Zsd�dބZt�ZuS)��	_UnparserF��_avoid_backslashescCs(g|_g|_i|_i|_d|_||_dS)Nr)�_source�_buffer�_precedences�
_type_ignores�_indentr�)r�r�rrrr��sz_Unparser.__init__cCsHt|�}z|t|��Wnty*Yn0|D]}|�||�q0dSr)�iterr��
StopIteration)r�Zinter�f�seqrOrrr�
interleave�sz_Unparser.interleavecs>t|�dkr$||d���d�n���fdd�||�dS)NrHr�,cs
��d�S�NrK��writerr�rr�<lambda>�rSz&_Unparser.items_view.<locals>.<lambda>)r9r�r�)r�Z	traverserr�rr�r�
items_view�sz_Unparser.items_viewcCs|jr|�d�dS)NrI)r�r�r�rrr�
maybe_newline�sz_Unparser.maybe_newlinerJcCs |��|�d|j|�dS)Nz    )r�r�r��r�r�rrr�fill�sz_Unparser.fillcCs|j�|�dSr)r�rXr�rrrr��sz_Unparser.writecCs|j�|�dSr)r�rXr�rrr�
buffer_writer�sz_Unparser.buffer_writercCsd�|j�}|j��|S�NrJ)r\r��clearr�rrr�buffer�s
z_Unparser.bufferN��extraccs>|�d�|r|�|�|jd7_dV|jd8_dS)N�:rH)r�r�)r�rrrr�block�s

z_Unparser.blockccs|�|�dV|�|�dSrr�)r��start�endrrr�delimit�s
z_Unparser.delimitcCs|r|�||�St�SdSr)r
r)r�rr	�	conditionrrr�
delimit_if�sz_Unparser.delimit_ifcCs|�dd|�|�|k�S�N�(�))r�get_precedence)r��
precedencerrrr�require_parens�sz_Unparser.require_parenscCs|j�|tj�Sr)r�r�r�r��r�rrrrr�sz_Unparser.get_precedencecGs|D]}||j|<qdSr)r�)r�rZnodesrrrr�set_precedence�sz_Unparser.set_precedencecCs`t|ttttf�r t|j�dkr$dS|jd}t|t�s<dS|j}t|t	�r\t|jt
�r\|SdS)NrHr)r
r~rr�r�r9rEr�r"r rDrrrr�get_raw_docstrings��

z_Unparser.get_raw_docstringcCs*|j�|j�p|j}|dur&d|��SdS)Nz	 # type: )r�r�ri�type_comment)r�rZcommentrrr�get_type_commentsz_Unparser.get_type_commentcs0t|t�r |D]}|�|�qnt��|�dSr)r
r1�traverse�superr�)r�rr}�rZrrrs
z_Unparser.traversecCsg|_|�|�d�|j�Sr)r�rr\rrrrr�s
z_Unparser.visitcCs>|�|�}r.|�|�|�|jdd��n|�|j�dSr�)r�_write_docstringrrE)r�rZ	docstringrrr�"_write_docstring_and_traverse_body$s
z,_Unparser._write_docstring_and_traverse_bodycCs*dd�|jD�|_|�|�|j��dS)NcSsi|]}|jd|j���qS)�ignore)ri�tag)rNrrrr�
<dictcomp>,s�z*_Unparser.visit_Module.<locals>.<dictcomp>)�type_ignoresr�rrrrrr�visit_Module+s
�
z_Unparser.visit_Modulecs`��dd��*���fdd��j|j�Wd�n1s<0Y��d���|j�dS)Nrrcs
��d�Sr�r�rr�rrr�6rSz._Unparser.visit_FunctionType.<locals>.<lambda>� -> )r
r�r�argtypesr��returnsrrr�r�visit_FunctionType3s�"
z_Unparser.visit_FunctionTypecCs(|��|�tj|j�|�|j�dSr)r�rr�r�r"rrrrr�
visit_Expr<sz_Unparser.visit_ExprcCsh|�tj|��F|�tj|j|j�|�|j�|�d�|�|j�Wd�n1sZ0YdS)Nz := )	rr�r�rr��targetr"rr�rrrr�visit_NamedExprAs

z_Unparser.visit_NamedExprcs(��d����fdd��j|j�dS)Nzimport cs
��d�Sr�r�rr�rrr�JrSz(_Unparser.visit_Import.<locals>.<lambda>)r�r�r�namesrrr�r�visit_ImportHs
z_Unparser.visit_ImportcsT��d���d|j�|jr,��|j���d����fdd��j|j�dS)Nzfrom �.z import cs
��d�Sr�r�rr�rrr�RrSz,_Unparser.visit_ImportFrom.<locals>.<lambda>)r�r�rQ�moduler�rr)rrr�r�visit_ImportFromLs

z_Unparser.visit_ImportFromcCsP|��|jD]}|�|�|�d�q|�|j�|�|�}rL|�|�dS)N� = )r��targetsrr�r"r)r�rr'rrrr�visit_AssignTs

z_Unparser.visit_AssigncCsB|��|�|j�|�d|j|jjjd�|�|j�dS)Nrfz= )	r�rr'r��binopr'rZr[r"rrrr�visit_AugAssign]sz_Unparser.visit_AugAssigncCs�|��|�dd|jo"t|jt���|�|j�Wd�n1sH0Y|�d�|�|j�|j	r�|�d�|�|j	�dS)Nrr�: r.)
r�rrbr
r'r4rr��
annotationr"rrrr�visit_AnnAssigncs *

z_Unparser.visit_AnnAssigncCs*|�d�|jr&|�d�|�|j�dS)N�returnrf)r�r"r�rrrrr�visit_Returnms

z_Unparser.visit_ReturncCs|�d�dS)N�pass�r�rrrr�
visit_Passssz_Unparser.visit_PasscCs|�d�dS)N�breakr9rrrr�visit_Breakvsz_Unparser.visit_BreakcCs|�d�dS)N�continuer9rrrr�visit_Continueysz_Unparser.visit_Continuecs(��d����fdd��j|j�dS)Nzdel cs
��d�Sr�r�rr�rrr�~rSz(_Unparser.visit_Delete.<locals>.<lambda>)r�r�rr/rrr�r�visit_Delete|s
z_Unparser.visit_DeletecCs6|�d�|�|j�|jr2|�d�|�|j�dS)Nzassert rK)r�r�test�msgr�rrrr�visit_Assert�s


z_Unparser.visit_Assertcs(��d����fdd��j|j�dS)Nzglobal cs
��d�Sr�r�rr�rrr��rSz(_Unparser.visit_Global.<locals>.<lambda>�r�r�r�r)rrr�r�visit_Global�s
z_Unparser.visit_Globalcs(��d����fdd��j|j�dS)Nz	nonlocal cs
��d�Sr�r�rr�rrr��rSz*_Unparser.visit_Nonlocal.<locals>.<lambda>rCrrr�r�visit_Nonlocal�s
z_Unparser.visit_NonlocalcCsh|�tj|��F|�d�|jrF|�d�|�tj|j�|�|j�Wd�n1sZ0YdS)N�awaitrf)rr�r�r�r"rr�rrrrr�visit_Await�s

z_Unparser.visit_AwaitcCsh|�tj|��F|�d�|jrF|�d�|�tj|j�|�|j�Wd�n1sZ0YdS)N�yieldrf)rr�r�r�r"rr�rrrrr�visit_Yield�s

z_Unparser.visit_YieldcCsf|�tj|��D|�d�|js(td��|�tj|j�|�|j�Wd�n1sX0YdS)Nzyield from z-Node can't be used without a value attribute.)	rr�r�r�r"rrr�rrrrr�visit_YieldFrom�s
z_Unparser.visit_YieldFromcCsX|�d�|js"|jrtd��dS|�d�|�|j�|jrT|�d�|�|j�dS)N�raisez*Node can't use cause without an exception.rfz from )r��exc�causerr�rrrrr�visit_Raise�s


z_Unparser.visit_RaisecCs�|�d�|���|�|j�Wd�n1s40Y|jD]}|�|�qD|jr�|�d�|���|�|j�Wd�n1s�0Y|jr�|�d�|���|�|j�Wd�n1s�0YdS)N�try�else�finally)r�rrrE�handlers�orelse�	finalbody)r�rZexrrr�	visit_Try�s

*


*

z_Unparser.visit_TrycCsz|�d�|jr&|�d�|�|j�|jrB|�d�|�|j�|���|�|j�Wd�n1sl0YdS)N�exceptrf� as )r�r!r�rrarrErrrr�visit_ExceptHandler�s



z_Unparser.visit_ExceptHandlercCs�|��|jD]}|�d�|�|�q|�d|j�|jdd|jpJ|jd��hd}|jD]"}|rp|�d�nd}|�|�q\|jD]"}|r�|�d�nd}|�|�q�Wd�n1s�0Y|�	��|�
|�Wd�n1s�0YdS)	N�@zclass rr)rFrKT)r��decorator_listr�rrar�basesr7r�rr)r�r�deco�comma�errr�visit_ClassDef�s&



*
z_Unparser.visit_ClassDefcCs|�|d�dS)N�def��_function_helperrrrr�visit_FunctionDef�sz_Unparser.visit_FunctionDefcCs|�|d�dS)Nz	async defrarrrr�visit_AsyncFunctionDef�sz _Unparser.visit_AsyncFunctionDefcCs�|��|jD]}|�d�|�|�q|d|j}|�|�|�dd��|�|j�Wd�n1sn0Y|jr�|�d�|�|j�|j	|�
|�d��|�|�Wd�n1s�0YdS)NrYrfrrr"r)r�rZr�rrar
r6r$r�rrr)r�rZfill_suffixr\Zdef_strrrrrb�s


*
z_Unparser._function_helpercCs|�d|�dS)Nzfor ��_for_helperrrrr�	visit_For�sz_Unparser.visit_ForcCs|�d|�dS)Nz
async for rerrrr�visit_AsyncFor�sz_Unparser.visit_AsyncForcCs�|�|�|�|j�|�d�|�|j�|j|�|�d��|�|j�Wd�n1s`0Y|jr�|�d�|���|�|j�Wd�n1s�0YdS)N� in rrP)	r�rr'r�r�rrrErS)r�r�rrrrrfs

*

z_Unparser._for_helpercCs|�d�|�|j�|���|�|j�Wd�n1s@0Y|jr�t|j�dkr�t|jdt�r�|jd}|�d�|�|j�|���|�|j�Wd�qJ1s�0YqJ|j�r|�d�|���|�|j�Wd�n1�s0YdS)Nzif rHrzelif rP)	r�rr@rrErSr9r
ZIfrrrr�visit_Ifs

*$


,

z_Unparser.visit_IfcCs�|�d�|�|j�|���|�|j�Wd�n1s@0Y|jr�|�d�|���|�|j�Wd�n1s�0YdS)Nzwhile rP)r�rr@rrErSrrrr�visit_Whiles

*

z_Unparser.visit_Whilecsf��d����fdd��j|j��j��|�d����|j�Wd�n1sX0YdS)Nzwith cs
��d�Sr�r�rr�rrr�*rSz&_Unparser.visit_With.<locals>.<lambda>r�r�r�rr�rrrErrr�r�
visit_With(s
z_Unparser.visit_Withcsf��d����fdd��j|j��j��|�d����|j�Wd�n1sX0YdS)Nzasync with cs
��d�Sr�r�rr�rrr�0rSz+_Unparser.visit_AsyncWith.<locals>.<lambda>rrlrrr�r�visit_AsyncWith.s
z_Unparser.visit_AsyncWith��quote_types�escape_special_whitespacecs��fdd�}d�t|����|}d�vr6dd�|D�}�fdd�|D�}|s�t���t�fdd	�|D��d
�}�dd�|gfS�r�|j�fd
d�d�|d
d
�dkrƈdd�d�d��|fS)Ncs4�s|dvr|S|dks |��s0|�d��d�S|S)Nz
	�\Zunicode_escape�ascii)�isprintabler�r�)r�)rqrr�escape_char:s
z2_Unparser._str_literal_helper.<locals>.escape_charrJrIcSsg|]}|tvr|�qSr)�
_MULTI_QUOTES�rN�qrrr�
<listcomp>GrSz1_Unparser._str_literal_helper.<locals>.<listcomp>csg|]}|�vr|�qSrrrw��escaped_stringrrryHrSc3s|]}�d|vr|VqdSrMrrw)�stringrrrRNrSz0_Unparser._str_literal_helper.<locals>.<genexpr>rrHrcs|d�dkS)Nrrr)rxrzrrr�RrSz/_Unparser._str_literal_helper.<locals>.<lambda>)r�rr)r\r.r]r��sort)r�r|rprqruZpossible_quotesZquoter)rqr{r|r�_str_literal_helper4s
z_Unparser._str_literal_helper�rpcCs4|j||d�\}}|d}|�|�|�|���dS)Nrr)r~r�)r�r|rp�
quote_typerrr�_write_str_avoiding_backslashesZsz)_Unparser._write_str_avoiding_backslashesc	Cs�|�d�|jr.|�||j�|�|j�dSg}|jD]:}t|dt|�j	�}|||j�|�
|jt|t�f�q8g}t
}|D]&\}}|j|||d�\}}|�
|�q�d�|�}|d}|�|�|�|���dS)Nr��	_fstring_rorJr)r�r��_fstring_JoinedStrrr�rr;rVr!r[rXr
r �_ALL_QUOTESr~r\)	r�rrr"�methZ
new_bufferrpZis_constantr�rrr�visit_JoinedStr`s*

�

z_Unparser.visit_JoinedStrcCs(|�d�|�||j�|�|j�dS)Nr�)r��_fstring_FormattedValuerr�rrrrr�visit_FormattedValues
z_Unparser.visit_FormattedValuecCs.|jD]"}t|dt|�j�}|||�qdS)Nr�)r;rVr!r[)r�rr�r"r�rrrr��s
z_Unparser._fstring_JoinedStrcCs6t|jt�std��|j�dd��dd�}||�dS)Nz.Constants inside JoinedStr should be a string.�{z{{�}z}})r
r"rDr�replace)r�rr�r"rrr�_fstring_Constant�sz_Unparser._fstring_ConstantcCs�|d�t|�dd�}|�tj��|j�|�|j�}|�d�rH|d�d|vrXtd��||�|j	dkr�t
|j	�}|dvr�td	��|d
|���|jr�|d�t|dt|j�j
�}||j|�|d
�dS)Nr�Tr�rfrrz5Unable to avoid backslash in f-string expression partrZsrazUnknown f-string conversion.�!rr�r�)r!rr�r�r�r"r�rnr�
conversion�chr�format_specrVr[)r�rr��unparser�exprr�r�rrrr��s&


z!_Unparser._fstring_FormattedValuecCs|�|j�dSr)r�r5rrrr�
visit_Name�sz_Unparser.visit_NamecCs0|��|jdkr|�d�|j|jtd�dS)N�ur)r��kindr�r�r"rvrrrrr�s

z_Unparser._write_docstringc
Csjt|ttf�r<|�t|��dt��ddt�dt�d���n*|jrXt|t�rX|�	|�n|�t|��dS)N�inf�nanr�-r)
r
r$r%r�r]r��_INFSTRr�rDr�r�rrr�_write_constant�s���z_Unparser._write_constantcCs�|j}t|t�rL|�dd��|�|j|�Wd�q�1s@0Yn4|dur`|�d�n |jdkrt|�d�|�|j�dS)Nrr.�...r�)r"r
rr
r�r�r�r�)r�rr"rrrr��s
.

z_Unparser.visit_ConstantcsJ��dd��*���fdd��j|j�Wd�n1s<0YdS)N�[�]cs
��d�Sr�r�rr�rrr��rSz&_Unparser.visit_List.<locals>.<lambda>)r
r�rr/rrr�r�
visit_List�sz_Unparser.visit_ListcCsR|�dd��2|�|j�|jD]}|�|�q Wd�n1sD0YdS)Nr�r��r
r�elt�
generators�r�r�genrrr�visit_ListComp�s
z_Unparser.visit_ListCompcCsR|�dd��2|�|j�|jD]}|�|�q Wd�n1sD0YdSr
r�r�rrr�visit_GeneratorExp�s
z_Unparser.visit_GeneratorExpcCsR|�dd��2|�|j�|jD]}|�|�q Wd�n1sD0YdS)Nr�r�r�r�rrr�
visit_SetComp�s
z_Unparser.visit_SetCompcCsh|�dd��H|�|j�|�d�|�|j�|jD]}|�|�q6Wd�n1sZ0YdS)Nr�r�r3)r
rr�r�r"r�r�rrr�visit_DictComp�s

z_Unparser.visit_DictCompcCs�|jr|�d�n
|�d�|�tj|j�|�|j�|�d�|jtj��|j	g|j
�R�|�|j	�|j
D]}|�d�|�|�qrdS)Nz async for z for ri� if )�is_asyncr�rr�r�r'rr�r�r��ifs)r�rZ	if_clauserrr�visit_comprehension�s



z_Unparser.visit_comprehensioncCs�|�tj|��p|�tj��|j|j�|�|j�|�d�|�|j�|�d�|�tj|j	�|�|j	�Wd�n1s�0YdS)Nr�z else )
rr�r�rr�rEr@rr�rSrrrr�visit_IfExp�s

z_Unparser.visit_IfExpcs\|jrN��dd��*���fdd��j|j�Wd�qX1sB0Yn
��d�dS)Nr�r�cs
��d�Sr�r�rr�rrr�rSz%_Unparser.visit_Set.<locals>.<lambda>z{*()})r/r
r�rr�rrr�r�	visit_Set�s:z_Unparser.visit_Setcsj�fdd����fdd�}��dd��0���fdd�|t|j|j��Wd�n1s\0YdS)	Ncs"��|���d���|�dS�Nr3)rr�)�k�vr�rr�write_key_value_pairs

z2_Unparser.visit_Dict.<locals>.write_key_value_paircsB|\}}|dur4��d���tj|���|�n
�||�dS)N�**)r�rr�r�r)r}r�r��r�r�rr�
write_items
z(_Unparser.visit_Dict.<locals>.write_itemr�r�cs
��d�Sr�r�rr�rrr�rSz&_Unparser.visit_Dict.<locals>.<lambda>)r
r�r=r:r;)r�rr�rr�r�
visit_Dicts�z_Unparser.visit_DictcCs@|�dd�� |�|j|j�Wd�n1s20YdSr
)r
r�rr/rrrr�visit_Tuplesz_Unparser.visit_Tuple�~�not�+r�)ZInvertZNotr(r))r�r�r�r�cCs�|j|jjj}|j|}|�||��H|�|�|tjurF|�d�|�	||j
�|�|j
�Wd�n1st0YdS�Nrf)�unopr'rZr[�unop_precedencerr�r�r�rr*r)r�r�operator�operator_precedencerrr�
visit_UnaryOp(s



z_Unparser.visit_UnaryOprrY�/�%�<<�>>�|�^�&�//r�)
r>r?ZMultZMatMultZDivZModZLShiftZRShiftZBitOrZBitXorZBitAndZFloorDivZPow)
r�r�rrYr�r�r�r�r�r�r�r�r�)r�cCs�|j|jjj}|j|}|�||��z||jvr@|��}|}n|}|��}|�||j	�|�
|j	�|�d|�d��|�||j�|�
|j�Wd�n1s�0YdSr�)
r1r'rZr[�binop_precedencer�binop_rassocr�rr@rr�rA)r�rr�r�Zleft_precedenceZright_precedencerrr�visit_BinOpUs

z_Unparser.visit_BinOpz==z!=�<z<=�>z>=�iszis not�inznot in)
ZEqZNotEqZLtZLtEZGtZGtEZIsZIsNotZInZNotIncCs�|�tj|��x|jtj��|jg|j�R�|�|j�t|j	|j�D].\}}|�
d|j|jj
d�|�|�qHWd�n1s�0YdSr�)rr�r�rr�r@�comparatorsrr=�opsr��cmpopsrZr[)r�r�or^rrr�
visit_Comparessz_Unparser.visit_Compare�and�or)ZAndZOr)r�r�cs~�j|jjj}�j|���fdd�}���|��6d|�d������fdd�||j�Wd�n1sp0YdS)Ncs"�������|���|�dSr)r�rrr)r�r�rr�increasing_level_traverse�sz9_Unparser.visit_BoolOp.<locals>.increasing_level_traverserfcs
����Srr�r)r�r�rrr��rSz(_Unparser.visit_BoolOp.<locals>.<lambda>)�boolopsr'rZr[�boolop_precedencerr�r;)r�rr�r�r)r�r�r�r�visit_BoolOp~s
z_Unparser.visit_BoolOpcCsZ|�tj|j�|�|j�t|jt�r@t|jjt�r@|�d�|�d�|�|j	�dS)Nrfr+)
rr�r�r"rr
r r#r�rqrrrr�visit_Attribute�s

z_Unparser.visit_AttributecCs�|�tj|j�|�|j�|�dd��hd}|jD]"}|rH|�d�nd}|�|�q4|jD]"}|rr|�d�nd}|�|�q^Wd�n1s�0YdS)NrrFrKT)	rr�r�r3rr
r6r�r7)r�rr]r^rrr�
visit_Call�s

z_Unparser.visit_CallcCs~dd�}|�tj|j�|�|j�|�dd��:||j�rP|�|j|jj�n|�|j�Wd�n1sp0YdS)NcSs&t|t�o$|jo$tdd�|jD��S)Ncss|]}t|t�VqdSr)r
ZStarred)rNr�rrrrR�rSzE_Unparser.visit_Subscript.<locals>.is_simple_tuple.<locals>.<genexpr>)r
r-r/�any)Zslice_valuerrr�is_simple_tuple�s

��z2_Unparser.visit_Subscript.<locals>.is_simple_tupler�r�)	rr�r�r"rr
r�r�r/)r�rr�rrr�visit_Subscript�s

z_Unparser.visit_SubscriptcCs*|�d�|�tj|j�|�|j�dS)Nr)r�rr�r�r"rrrrr�
visit_Starred�s
z_Unparser.visit_StarredcCs|�d�dS)Nr�r�rrrr�visit_Ellipsis�sz_Unparser.visit_EllipsiscCsN|jr|�|j�|�d�|jr.|�|j�|jrJ|�d�|�|j�dS)Nr)�lowerrr��upper�steprrrr�visit_Slice�s

z_Unparser.visit_SlicecCs,|�|j�|jr(|�d�|�|j�dSr�)r��argr4rrrrr�	visit_arg�s
z_Unparser.visit_argc	Cs�d}|j|j}dgt|�t|j�|j}tt||�d�D]^\}}|\}}|rXd}n
|�d�|�|�|r�|�d�|�|�|t|j�kr>|�d�q>|js�|j	r�|r�d}n
|�d�|�d�|jr�|�|jj
�|jjr�|�d�|�|jj�|j	�rLt|j	|j�D]8\}}|�d�|�|�|�r|�d�|�|��q|j
�r�|�r`d}n
|�d�|�d	|j
j
�|j
j�r�|�d�|�|j
j�dS)
NTrHFrK�=z, /rr3r�)�posonlyargsr6r9�defaults�	enumerater=r�r�vararg�
kwonlyargsr�r4�kw_defaults�kwarg)	r�rr�Zall_argsr�r��elements�a�drrr�visit_arguments�sN












z_Unparser.visit_argumentscCs<|jdur|�d�n|�|j�|�d�|�|j�dS)Nr�r�)r�r�rr"rrrr�
visit_keywords


z_Unparser.visit_keywordcCsn|�tj|��L|�d�|�|j�|�d�|�tj|j�|�|j�Wd�n1s`0YdS)Nzlambda r3)rr�r�r�rr6rrErrrr�visit_Lambdas

z_Unparser.visit_LambdacCs&|�|j�|jr"|�d|j�dS�NrW)r�ra�asnamerrrr�visit_aliassz_Unparser.visit_aliascCs,|�|j�|jr(|�d�|�|j�dSr�)r�context_expr�
optional_varsr�rrrr�visit_withitems
z_Unparser.visit_withitem)rJ)vr[r�r�r�r�r�r�r�r�r�propertyrrrr
rrrrrrrr�rr!r%r&r(r*r-r0r2r5r7r:r<r>r?rBrDrErGrIrJrNrUrXr_rcrdrbrgrhrfrjrkrmrnr�r~r�r�r�r�r�r�r�rr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r1r�r�r�r�r�r�r�r��	frozensetr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r��
__classcell__rrrrr��s




		

�&
	�
���


3r�cCst�}|�|�Sr)r�r�)Zast_objr�rrr�unparse"sr�cCs�ddl}|jdd�}|jd|jdd�ddd	d
�|jddd
ddd�|jddddd�|jddddd�|jddtddd�|��}|j�}|��}Wd�n1s�0Yt||jj	|j
|jd �}tt
||j|jd!��dS)"Nrz
python -m ast)�prog�infile�rbr�?r�z$the file to parse; defaults to stdin)r!�nargs�default�helpz-mz--moder)rZsinglerZ	func_typez(specify what kind of code must be parsed)r�choicesrz--no-type-commentsTZstore_falsez)don't add information about type comments)r�actionrz-az--include-attributes�
store_truez:include attributes such as line numbers and column offsets)rrz-iz--indentrLz'indentation of nodes (number of spaces))r!rr)r	)rerG)�argparse�ArgumentParser�add_argumentZFileTyper#�
parse_argsr�readrrarZno_type_comments�printrhrerG)r	�parserr6rrZtreerrr�main's0�
�
�
��&r�__main__)rr)TF)rH)T)J�sysZ_ast�
contextlibrr�enumrrrrFrhrrrwrzr|rsr�r�r�r�rx�objectr�r�rmr r�r�r�ryr�r!r�r�r�r�r�r�r�r#r$r%rD�bytes�boolr�r�r�rTr�r�r�r-r�r�r��modr�Zexpr_contextr�r�r�r]�
float_info�
max_10_expr�r�Z_SINGLE_QUOTESrvr�r�r�rr[rrrr�<module>s��6C#

%:<	

���


?>