AlkantarClanX12

Your IP : 3.135.204.43


Current Path : /opt/alt/python310/lib64/python3.10/__pycache__/
Upload File :
Current File : //opt/alt/python310/lib64/python3.10/__pycache__/ast.cpython-310.opt-2.pyc

o

6��f���@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+�s�d,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��s!dGdH�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�rxeH�dSdS)c�N)�*)�contextmanager�nullcontext)�IntEnum�auto�	<unknown>�execF)�
type_comments�feature_versioncCsH	t}|r	|tO}t|t�r|\}}|}n|durd}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/python310/lib64/python3.10/ast.py�parse!s

�rcsh	t|t�rt|�d�dd�}t|t�r|j}dd���fdd���fdd	������fd
d���|�S)Nz 	�eval�rcSs4d}t|dd�}r|d|��7}t|d|����)Nzmalformed node or string�linenoz	 on line �: )�getattr�
ValueError)�node�msg�lnorrr�_raise_malformed_nodeCsz+literal_eval.<locals>._raise_malformed_nodecs,t|t�rt|j�tttfvr�|�|jS�N)r
�Constant�type�value�int�float�complex�r)r"rr�_convert_numHsz"literal_eval.<locals>._convert_numcsDt|t�rt|jttf�r�|j�}t|jt�r|
S|S�|�Sr#)r
ZUnaryOp�op�UAdd�USub�operand)rr/)r+rr�_convert_signed_numLs
z)literal_eval.<locals>._convert_signed_numcsLt|t�r|jSt|t�rtt�|j��St|t�r"tt�|j��St|t	�r/t
t�|j��St|t�rOt|jt
�rO|jjdkrO|j|jkrNgkrOt
�St|t�rqt|j�t|j�krb�|�ttt�|j�t�|j���St|t�r�t|jttf�r��|j�}�|j�}t|ttf�r�t|t�r�t|jt�r�||S||S�|�S)N�set) r
r$r&�Tupler�map�eltsZList�list�Setr1ZCall�func�Name�id�args�keywordsZDict�len�keys�values�dict�zipZBinOpr,�Add�Sub�left�rightr'r(r))rrCrD��_convertr+r0r"rrrFTs4



"�

�

zliteral_eval.<locals>._convert)r
�strr�lstripZ
Expression�body)Znode_or_stringrrEr�literal_eval6s

rJT)�indentcsV	d����fdd�	�t|t�std|jj���dur%t�t�s%d���|�dS)Nrc	s��dur�d7�d��}d��}nd}d}t|t�r�t|�}g}d}�}|jD]@}zt||�}	Wnty?d}Yq+w|	durOt||d�durOd}q+�|	��\}	}
|oY|
}|rf|�d||	f�q+|�|	�q+�r�|jr�|jD]4}zt||�}	Wn	ty�Yqtw|	dur�t||d�dur�qt�|	��\}	}
|o�|
}|�d||	f�qt|r�t|�d	kr�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>�s�z(dump.<locals>._format.<locals>.<genexpr>)r
�ASTr%�_fieldsr�AttributeError�append�_attributesr<�	__class__�__name__�joinr5�repr)rrU�prefix�sep�clsr:Z	allsimpler;�namer&�simple�rT�annotate_fields�include_attributesrK)rUrrT}s\

�

�
&zdump.<locals>._formatzexpected AST, got %r� )r)r
rW�	TypeErrorr\r]rG)rrfrgrKrrer�dumpqs
0rjcCsX	dD]&}||jvr)||jvr)t||d�}|dus#t||�r)|�d�r)t|||�q|S)N)r�
col_offset�
end_lineno�end_col_offsetZend_)r[r�hasattr�
startswith�setattr)�new_nodeZold_node�attrr&rrr�
copy_location�s���rscs"	�fdd���|dddd�|S)Ncs�d|jvrt|d�s||_n|j}d|jvr%t|dd�dur"||_n|j}d|jvr6t|d�s3||_n|j}d|jvrJt|dd�durG||_n|j}t|�D]
}�|||||�qNdS)Nrrlrkrm)r[rnrrrlrkrm�iter_child_nodes)rrrkrlrm�child��_fixrrrw�s&





�z#fix_missing_locations.<locals>._fixrLrrr*rrvr�fix_missing_locations�srxrLcCsv	t|�D]3}t|t�rt|dd�||_qd|jvr$t|dd�||_d|jvr8t|dd�}dur8|||_q|S)Nrrrl)�walkr
Z
TypeIgnorerrr[rl)r�nrurlrrr�increment_lineno�s



�r{c	cs:�	|jD]}z
|t||�fVWqtyYqwdSr#)rXrrY)r�fieldrrr�iter_fields�s�
��r}ccsP�	t|�D]\}}t|t�r|Vqt|t�r%|D]
}t|t�r$|VqqdSr#)r}r
rWr5)rrcr|�itemrrrrts�


��rtcCs�	t|ttttf�std|jj��|jrt|jdt	�sdS|jdj
}t|t�r.|j}nt|t
�r=t|j
t�r=|j
}ndS|rJddl}|�|�}|S)Nz%r can't have docstringsr)r
�AsyncFunctionDef�FunctionDef�ClassDef�Modulerir\r]rI�Exprr&�Str�sr$rG�inspectZcleandoc)rZclean�textr�rrr�
get_docstrings

r�cCs�	d}g}d}|t|�krB||}||7}|d7}|dkr1|t|�kr1||dkr1|d7}|d7}|dvr<|�|�d}|t|�ks
|rI|�|�|S)NrrNrL�
rMz
)r<rZ)r�idx�linesZ	next_line�crrr�_splitlines_no_ff3s$ 
�
r�cCs.	d}|D]}|dvr||7}q|d7}q|S)NrNz	rhr)r�resultr�rrr�_pad_whitespaceLs

r�)�paddedcCs	z|jdus|jdurWdS|jd}|jd}|j}|j}Wn
ty*YdSwt|�}||kr?||��||���S|rPt||��d|����}nd}|||��|d���}	||��d|���}
||d|�}|�	d|	�|�
|
�d�|�S)NrLrNr)rlrmrrkrYr��encode�decoder��insertrZr^)rrr�rrlrkrmr�Zpadding�firstZlastrrr�get_source_segmentWs.


�

r�ccsF�	ddlm}||g�}|r!|��}|�t|��|V|sdSdS)Nr)�deque)�collectionsr��popleft�extendrt)rr�Ztodorrrry|s�
�ryc@s&eZdZ	dd�Zdd�Zdd�ZdS)�NodeVisitorcCs$	d|jj}t|||j�}||�S)N�visit_)r\r]r�
generic_visit)�selfr�method�visitorrrr�visit�szNodeVisitor.visitcCsV	t|�D]#\}}t|t�r|D]}t|t�r|�|�qqt|t�r(|�|�qdSr#)r}r
r5rWr�)r�rr|r&r~rrrr��s


��

��zNodeVisitor.generic_visitc	Cs�|j}t�t|��}|dur t��D]
\}}t||�r|}nq|durKd|}zt||�}Wn	ty8Ynwddl}|�	|�d�t
d�||�S|�|�S)Nr�rz" is deprecated; add visit_Constant�)r&�_const_node_type_names�getr%�itemsr
rrY�warnings�warn�DeprecationWarningr�)	r�rr&Z	type_namerbrcr�r�r�rrr�visit_Constant�s*
���
zNodeVisitor.visit_ConstantN)r]�
__module__�__qualname__r�r�r�rrrrr��s

r�c@�eZdZ	dd�ZdS)�NodeTransformercCs�t|�D]P\}}t|t�r:g}|D]!}t|t�r-|�|�}|dur"qt|t�s-|�|�q|�|�q||dd�<qt|t�rT|�|�}|durNt||�qt|||�q|Sr#)	r}r
r5rWr�r�rZ�delattrrp)r�rr|�	old_valueZ
new_valuesr&rqrrrr��s(






�zNodeTransformer.generic_visitN)r]r�r�r�rrrrr��s#r�rzcC�	|jSr#�r&�r�rrr�_getter�r�cC�
||_dSr#r��r�r&rrr�_setter�
r�c@seZdZdd�Zdd�ZdS)�_ABCcGs
d|_dS)Nz3Deprecated AST node class. Use ast.Constant instead)�__doc__)rbr:rrr�__init__r�z
_ABC.__init__cCsdt|t�sdS|tvr,z|j}Wn
tyYdSwt|t|�o+t|t�|d��St�||�S)NFr)	r
r$�_const_typesr&rY�_const_types_notr�r%�__instancecheck__)rb�instr&rrrr�s

��z_ABC.__instancecheck__N)r]r�r�r�r�rrrrr�sr�cOsp|D]}||jvr
q|j�|�}|t|�kr t|j�d|����q|tvr,t|i|��Stj|g|�Ri|��S)Nz" got multiple values for argument )rX�indexr<rir]r�r$�__new__)rbr:�kwargs�key�posrrr�_new"s
�r�c@�eZdZdZeZdS)�Num)rzN�r]r�r�rXr�r�rrrrr�.�r�)�	metaclassc@r�)r��r�Nr�rrrrr�2r�r�c@r�)�Bytesr�Nr�rrrrr�6r�r�c@seZdZeZdS)�NameConstantN)r]r�r�r�r�rrrrr�:sr�c@seZdZdZdd�ZdS)�EllipsisrcOs6|turtdg|�Ri|��Stj|g|�Ri|��S)N.)r�r$r�)rbr:r�rrrr�@szEllipsis.__new__N)r]r�r�rXr�rrrrr�=sr�.c@�eZdZdS)�sliceN�r]r�r�rrrrr�[�r�c@r�)�IndexcKs|Sr#r)rbr&r�rrrr�`sz
Index.__new__N�r]r�r�r�rrrrr�^sr�c@seZdZ	ddd�ZdS)�ExtSlicercKstt|�t�fi|��Sr#)r2r5ZLoad)rb�dimsr�rrrr�eszExtSlice.__new__N)rr�rrrrr�csr�r�cCr�r#�r4r�rrr�_dims_gettermr�r�cCr�r#r�r�rrr�_dims_setterqr�r�c@r�)�SuiteNr�rrrrr�vr�r�c@r�)�AugLoadNr�rrrrr�yr�r�c@r�)�AugStoreNr�rrrrr�|r�r�c@r�)�ParamNr�rrrrr�r�r�Z1ec@s�eZdZ	e�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|YSw�NrL)r\rr�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'''cseZdZ	dd�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ބZtd�d�Zud�d�Zvd�d�Zwd�d�Zxd�d�Zyd�d�Zzd�d�Z{d�d�Z|d�d�Z}d�d�Z~�ZS)��	_UnparserF��_avoid_backslashescCs(g|_g|_i|_i|_d|_||_dS)Nr)�_source�_buffer�_precedences�
_type_ignores�_indentr�)r�r�rrrr��s
z_Unparser.__init__cCsL	t|�}z|t|��Wn
tyYdSw|D]	}|�||�qdSr#)�iterr��
StopIteration)r�Zinter�f�seqrSrrr�
interleave�s�
�z_Unparser.interleavecsB	t|�dkr||d���d�dS���fdd�||�dS)NrLr�,c�
��d�S�NrO��writerr�rr�<lambda>��
z&_Unparser.items_view.<locals>.<lambda>)r<rr)r�Z	traverserr�rr�r�
items_view�s
z_Unparser.items_viewcCs	|jr|�d�dSdS)NrM)r�rr�rrr�
maybe_newline�s�z_Unparser.maybe_newlinerNcCs"	|��|�d|j|�dS)Nz    )r	rr��r�r�rrr�fill�sz_Unparser.fillcCs	|j�|�dSr#)r�rZr
rrrr�sz_Unparser.writecCs|j�|�dSr#)r�rZr
rrr�
buffer_writer��z_Unparser.buffer_writercCsd�|j�}|j��|S�NrN)r^r��clearr�rrr�buffer�s
z_Unparser.bufferN��extraccsB�	|�d�|r|�|�|jd7_dV|jd8_dS)N�:rL)rr�)r�rrrr�block�s�

z_Unparser.blockccs"�	|�|�dV|�|�dSr#r)r��start�endrrr�delimit�s
�
z_Unparser.delimitcCs|r|�||�St�Sr#)rr)r�rr�	conditionrrr�
delimit_if�sz_Unparser.delimit_ifcCs	|�dd|�|�|k�S�N�(�))r�get_precedence)r��
precedencerrrr�require_parenssz_Unparser.require_parenscCs|j�|tj�Sr#)r�r�r�r��r�rrrrrr
z_Unparser.get_precedencecGs|D]}||j|<qdSr#)r�)r�rZnodesrrrr�set_precedences�z_Unparser.set_precedencecCsf	t|ttttf�rt|j�dkrdS|jd}t|t�sdS|j}t|t	�r/t|jt
�r1|SdSdS)NrLr)r
rr�r�r�r<rIr�r&r$rGr rrr�get_raw_docstrings�

�z_Unparser.get_raw_docstringcCs*|j�|j�p	|j}|durd|��SdS)Nz	 # type: )r�r�r�type_comment)r�rZcommentrrr�get_type_comments
�z_Unparser.get_type_commentcs2t|t�r|D]}|�|�qdSt��|�dSr#)r
r5�traverse�superr�)r�rr~�r\rrr%!s

�z_Unparser.traversecCs	g|_|�|�d�|j�Sr)r�r%r^r rrrr�+s
z_Unparser.visitcCs@|�|�}r|�|�|�|jdd��dS|�|j�dSr�)r"�_write_docstringr%rI)r�rZ	docstringrrr�"_write_docstring_and_traverse_body2s
z,_Unparser._write_docstring_and_traverse_bodycCs*dd�|jD�|_|�|�|j��dS)NcSsi|]
}|jd|j���qS)�ignore)r�tag)rRr*rrr�
<dictcomp>:s��z*_Unparser.visit_Module.<locals>.<dictcomp>)�type_ignoresr�r)rr rrr�visit_Module9s
�
z_Unparser.visit_Modulecs`��dd�����fdd��j|j�Wd�n1swY��d���|j�dS)Nrrcrrrrr�rrrDrz._Unparser.visit_FunctionType.<locals>.<lambda>� -> )rrr%�argtypesr�returnsr rr�r�visit_FunctionTypeAs��
z_Unparser.visit_FunctionTypecCs(|��|�tj|j�|�|j�dSr#)rr!r�r�r&r%r rrr�
visit_ExprJsz_Unparser.visit_ExprcCsj|�tj|��$|�tj|j|j�|�|j�|�d�|�|j�Wd�dS1s.wYdS)Nz := )	rr�r�r!r��targetr&r%rr rrr�visit_NamedExprOs
"�z_Unparser.visit_NamedExprc�(��d����fdd��j|j�dS)Nzimport crrrrr�rrrXrz(_Unparser.visit_Import.<locals>.<lambda>)rrr%�namesr rr�r�visit_ImportV�
z_Unparser.visit_ImportcsX��d���d|jpd�|jr��|j���d����fdd��j|j�dS)Nzfrom �.rz import crrrrr�rrr`rz,_Unparser.visit_ImportFrom.<locals>.<lambda>)rrrU�modulerr%r7r rr�r�visit_ImportFromZs

z_Unparser.visit_ImportFromcCsT|��|jD]}|�|�|�d�q|�|j�|�|�}r(|�|�dSdS)N� = )r�targetsr%rr&r$)r�rr4r#rrr�visit_Assignbs

�z_Unparser.visit_AssigncCsB|��|�|j�|�d|j|jjjd�|�|j�dS)Nrhz= )	rr%r4r�binopr,r\r]r&r rrr�visit_AugAssignksz_Unparser.visit_AugAssigncCs�|��|�dd|jot|jt���|�|j�Wd�n1s$wY|�d�|�|j�|j	rD|�d�|�|j	�dSdS)Nrrrr=)
rrrdr
r4r8r%r�
annotationr&r rrr�visit_AnnAssignqs �

�z_Unparser.visit_AnnAssigncCs.|�d�|jr|�d�|�|j�dSdS)N�returnrh)rr&rr%r rrr�visit_Return{s


�z_Unparser.visit_ReturncC�|�d�dS)N�pass�rr rrr�
visit_Pass��z_Unparser.visit_PasscCrF)N�breakrHr rrr�visit_Break�rJz_Unparser.visit_BreakcCrF)N�continuerHr rrr�visit_Continue�rJz_Unparser.visit_Continuecr6)Nzdel crrrrr�rrr�rz(_Unparser.visit_Delete.<locals>.<lambda>)rrr%r>r rr�r�visit_Delete�r9z_Unparser.visit_DeletecCs:|�d�|�|j�|jr|�d�|�|j�dSdS)Nzassert rO)rr%�testr rr rrr�visit_Assert�s

�z_Unparser.visit_Assertcr6)Nzglobal crrrrr�rrr�rz(_Unparser.visit_Global.<locals>.<lambda>�rrrr7r rr�r�visit_Global�r9z_Unparser.visit_Globalcr6)Nz	nonlocal crrrrr�rrr�rz*_Unparser.visit_Nonlocal.<locals>.<lambda>rRr rr�r�visit_Nonlocal�r9z_Unparser.visit_NonlocalcC�z|�tj|��,|�d�|jr+|�d�|�tj|j�|�|j�Wd�dSWd�dS1s6wYdS)N�awaitrh)rr�r�rr&r!r�r%r rrr�visit_Await��

�"�z_Unparser.visit_AwaitcCrU)N�yieldrh)rr�r�rr&r!r�r%r rrr�visit_Yield�rXz_Unparser.visit_YieldcCsh|�tj|��#|�d�|jstd��|�tj|j�|�|j�Wd�dS1s-wYdS)Nzyield from z-Node can't be used without a value attribute.)	rr�r�rr&rr!r�r%r rrr�visit_YieldFrom�s
"�z_Unparser.visit_YieldFromcCs\|�d�|js|jrtd��dS|�d�|�|j�|jr,|�d�|�|j�dSdS)N�raisez*Node can't use cause without an exception.rhz from )r�exc�causerrr%r rrr�visit_Raise�s


�z_Unparser.visit_RaisecCs�|�d�|���|�|j�Wd�n1swY|jD]}|�|�q"|jrL|�d�|���|�|j�Wd�n1sGwY|jrq|�d�|���|�|j�Wd�dS1sjwYdSdS)N�try�else�finally)rrr%rI�handlers�orelse�	finalbody)r�rZexrrr�	visit_Try�s"

�


�

"��z_Unparser.visit_TrycCs||�d�|jr|�d�|�|j�|jr!|�d�|�|j�|���|�|j�Wd�dS1s7wYdS)N�exceptrh� as )rr%rr%rcrrIr rrr�visit_ExceptHandler�s



"�z_Unparser.visit_ExceptHandlercCs|��|jD]}|�d�|�|�q|�d|j�|jdd|jp%|jd��4d}|jD]}|r8|�d�nd}|�|�q.|jD]}|rM|�d�nd}|�|�qCWd�n1s_wY|�	��|�
|�Wd�dS1sywYdS)	N�@zclass rr)rFrOT)r	�decorator_listrr%rcr�basesr;rrr))r�r�deco�comma�errr�visit_ClassDef�s,



��
"�z_Unparser.visit_ClassDefcC�|�|d�dS)N�def��_function_helperr rrr�visit_FunctionDef�r
z_Unparser.visit_FunctionDefcCrq)Nz	async defrsr rrr�visit_AsyncFunctionDef�r
z _Unparser.visit_AsyncFunctionDefcCs�|��|jD]}|�d�|�|�q|d|j}|�|�|�dd��|�|j�Wd�n1s7wY|jrJ|�d�|�|j�|j	|�
|�d��|�|�Wd�dS1sdwYdS)Nrjrhrrr/r)r	rkrr%rcrr:r1rrr$r))r�rZfill_suffixrmZdef_strrrrrt�s


�
"�z_Unparser._function_helpercC�|�d|�dS)Nzfor ��_for_helperr rrr�	visit_Forr
z_Unparser.visit_ForcCrw)Nz
async for rxr rrr�visit_AsyncForr
z_Unparser.visit_AsyncForcCs�|�|�|�|j�|�d�|�|j�|j|�|�d��|�|j�Wd�n1s0wY|jrZ|�d�|���|�|j�Wd�dS1sSwYdSdS)N� in rra)	rr%r4rr�rr$rIrd)r�rrrrrrys

�

"��z_Unparser._for_helpercCs4|�d�|�|j�|���|�|j�Wd�n1s wY|jrst|j�dkrst|jdt�rs|jd}|�d�|�|j�|���|�|j�Wd�n1s\wY|jrst|j�dkrst|jdt�s7|jr�|�d�|���|�|j�Wd�dS1s�wYdSdS)Nzif rLrzelif ra)	rr%rPrrIrdr<r
ZIfr rrr�visit_Ifs&

�$


�$�

"��z_Unparser.visit_IfcCs�|�d�|�|j�|���|�|j�Wd�n1s wY|jrJ|�d�|���|�|j�Wd�dS1sCwYdSdS)Nzwhile ra)rr%rPrrIrdr rrr�visit_While,s

�

"��z_Unparser.visit_Whilec�h��d����fdd��j|j��j��|�d����|j�Wd�dS1s-wYdS)Nzwith crrrrr�rrr8rz&_Unparser.visit_With.<locals>.<lambda>r�rrr%r�rr$rIr rr�r�
visit_With6�

"�z_Unparser.visit_Withcr)Nzasync with crrrrr�rrr>rz+_Unparser.visit_AsyncWith.<locals>.<lambda>rr�r rr�r�visit_AsyncWith<r�z_Unparser.visit_AsyncWith��quote_types�escape_special_whitespacecs�	�fdd�}d�t|����|}d�vrdd�|D�}�fdd�|D�}|sBt���t�fdd	�|D��d
�}�dd�|gfS�rd|j�fd
d�d�|d
d
�dkrd�dd�d�d��|fS)Ncs4�s|dvr|S|dks|��s|�d��d�S|S)Nz
	�\Zunicode_escape�ascii)�isprintabler�r�)r�)r�rr�escape_charHs
z2_Unparser._str_literal_helper.<locals>.escape_charrNrMcSsg|]}|tvr|�qSr)�
_MULTI_QUOTES�rR�qrrr�
<listcomp>U�z1_Unparser._str_literal_helper.<locals>.<listcomp>csg|]}|�vr|�qSrrr���escaped_stringrrr�Vr�c3s �|]}�d|vr|VqdSrQrr�)�stringrrrV\s�z0_Unparser._str_literal_helper.<locals>.<genexpr>rrLrcs|d�dkS)Nrrr)r�r�rrr`sz/_Unparser._str_literal_helper.<locals>.<lambda>)r�r�)r^r3r_r��sort)r�r�r�r�r�Zpossible_quotesZquoter)r�r�r�r�_str_literal_helperBs 
z_Unparser._str_literal_helper�r�cCs6	|j||d�\}}|d}|�|�|�|���dS)Nr�r)r�r)r�r�r��
quote_typerrr�_write_str_avoiding_backslasheshsz)_Unparser._write_str_avoiding_backslashesc	Cs�|�d�|jr|�||j�|�|j�dSg}|jD]}t|dt|�j	�}|||j�|�
|jt|t�f�qg}t
}|D]\}}|j|||d�\}}|�
|�q@d�|�}|d}|�|�|�|���dS)Nr��	_fstring_r�rNr)rr��_fstring_JoinedStrrr�rr>rr%r]rZr
r$�_ALL_QUOTESr�r^)	r�rrr&�methZ
new_bufferr�Zis_constantr�rrr�visit_JoinedStrns*


�
z_Unparser.visit_JoinedStrcCs(|�d�|�||j�|�|j�dS)Nr�)r�_fstring_FormattedValuerr�rr rrr�visit_FormattedValue�s
z_Unparser.visit_FormattedValuecCs.|jD]}t|dt|�j�}|||�qdS)Nr�)r>rr%r])r�rrr&r�rrrr��s
�z_Unparser._fstring_JoinedStrcCs6t|jt�s
td��|j�dd��dd�}||�dS)Nz.Constants inside JoinedStr should be a string.�{z{{�}z}})r
r&rGr�replace)r�rrr&rrr�_fstring_Constant�sz_Unparser._fstring_ConstantcCs�|d�t|�dd�}|�tj��|j�|�|j�}|�d�r$|d�d|vr,td��||�|j	dkrIt
|j	�}|dvrBtd	��|d
|���|jra|d�t|dt|j�j
�}||j|�|d
�dS)Nr�Tr�rhr�z5Unable to avoid backslash in f-string expression partrZsrazUnknown f-string conversion.�!rr�r�)r%r!r�r�r�r&r�ror�
conversion�chr�format_specrr])r�rr�unparser�exprr�r�rrrr��s&


z!_Unparser._fstring_FormattedValuecC�|�|j�dSr#)rr9r rrr�
visit_Name�r
z_Unparser.visit_NamecCs0|��|jdkr|�d�|j|jtd�dS)N�ur�)r�kindrr�r&r�r rrrr(�s

z_Unparser._write_docstringc
Csnt|ttf�r|�t|��dt��ddt�dt�d���dS|jr.t|t�r.|�	|�dS|�t|��dS)N�inf�nanr�-r)
r
r(r)rr_r��_INFSTRr�rGr�r�rrr�_write_constant�s�z_Unparser._write_constantcCs�|j}t|t�r(|�dd��|�|j|�Wd�dS1s!wYdS|dur3|�d�dS|jdkr=|�d�|�|j�dS)Nrr.�...r�)r&r
rrrr�rr�)r�rr&rrrr��s
"�

z_Unparser.visit_Constantc�L��dd�����fdd��j|j�Wd�dS1swYdS)N�[�]crrrrr�rrr�rz&_Unparser.visit_List.<locals>.<lambda>)rrr%r4r rr�r�
visit_List�s"�z_Unparser.visit_ListcC�T|�dd��|�|j�|jD]}|�|�qWd�dS1s#wYdS)Nr�r��rr%�elt�
generators�r�r�genrrr�visit_ListComp��
�"�z_Unparser.visit_ListCompcCr�rr�r�rrr�visit_GeneratorExp�r�z_Unparser.visit_GeneratorExpcCr�)Nr�r�r�r�rrr�
visit_SetComp�r�z_Unparser.visit_SetCompcCsj|�dd��%|�|j�|�d�|�|j�|jD]}|�|�qWd�dS1s.wYdS)Nr�r�r)rr%r�rr&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�|�|�q9dS)Nz async for z for r|� if )�is_asyncrr!r�r�r4r%r�r�r��ifs)r�rZ	if_clauserrr�visit_comprehension�s



�z_Unparser.visit_comprehensioncCs�|�tj|��9|�tj��|j|j�|�|j�|�d�|�|j�|�d�|�tj|j	�|�|j	�Wd�dS1sCwYdS)Nr�z else )
rr�r�r!r�rIrPr%rrdr rrr�visit_IfExps

"�z_Unparser.visit_IfExpcs`|jr)��dd�����fdd��j|j�Wd�dS1s"wYdS��d�dS)Nr�r�crrrrr�rrrrz%_Unparser.visit_Set.<locals>.<lambda>z{*()})r4rrr%rr rr�r�	visit_Sets
"�z_Unparser.visit_Setcsl�fdd����fdd�}��dd�����fdd�|t|j|j��Wd�dS1s/wYdS)	Ncs"��|���d���|�dS�Nr�r%r)�k�vr�rr�write_key_value_pairs

z2_Unparser.visit_Dict.<locals>.write_key_value_paircsD|\}}|dur��d���tj|���|�dS�||�dS)N�**)rr!r�r�r%)r~r�r��r�r�rr�
write_items
z(_Unparser.visit_Dict.<locals>.write_itemr�r�crrrrr�rrr'rz&_Unparser.visit_Dict.<locals>.<lambda>)rrr@r=r>)r�rr�rr�r�
visit_Dicts�"�z_Unparser.visit_DictcCsB|�dd��|�|j|j�Wd�dS1swYdSr)rrr%r4r rrr�visit_Tuple*s"�z_Unparser.visit_Tuple�~�not�+r�)ZInvertZNotr-r.)r�r�r�r�cCs�|j|jjj}|j|}|�||��%|�|�|tjur#|�d�|�	||j
�|�|j
�Wd�dS1s;wYdS�Nrh)�unopr,r\r]�unop_precedencerrr�r�r!r/r%)r�r�operator�operator_precedencerrr�
visit_UnaryOp6s



"�z_Unparser.visit_UnaryOprrj�/�%�<<�>>�|�^�&�//r�)
rArBZMultZMatMultZDivZModZLShiftZRShiftZBitOrZBitXorZBitAndZFloorDivZPow)
r�r�rrjr�r�r�r�r�r�r�r�r�)r�cCs�|j|jjj}|j|}|�||��>||jvr |��}|}n|}|��}|�||j	�|�
|j	�|�d|�d��|�||j�|�
|j�Wd�dS1sTwYdSr�)
r@r,r\r]�binop_precedencer�binop_rassocr�r!rCr%rrD)r�rr�r�Zleft_precedenceZright_precedencerrr�visit_BinOpcs

"�z_Unparser.visit_BinOpz==z!=�<z<=�>z>=�iszis not�inznot in)
ZEqZNotEqZLtZLtEZGtZGtEZIsZIsNotZInZNotIncCs�|�tj|��=|jtj��|jg|j�R�|�|j�t|j	|j�D]\}}|�
d|j|jj
d�|�|�q$Wd�dS1sGwYdSr�)rr�r�r!r�rC�comparatorsr%r@�opsr�cmpopsr\r])r�r�ororrr�
visit_Compare�s�"�z_Unparser.visit_Compare�and�or)ZAndZOr)r�r�cs��j|jjj}�j|���fdd�}���|��d|�d������fdd�||j�Wd�dS1s9wYdS)Ncs"�������|���|�dSr#)r�r!r%r*)r�r�rr�increasing_level_traverse�sz9_Unparser.visit_BoolOp.<locals>.increasing_level_traverserhcs
����Sr#rr)r�r�rrr�rz(_Unparser.visit_BoolOp.<locals>.<lambda>)�boolopsr,r\r]�boolop_precedencerrr>)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)Nrhr:)
r!r�r�r&r%r
r$r'rrrr rrr�visit_Attribute�s

z_Unparser.visit_AttributecCs�|�tj|j�|�|j�|�dd��5d}|jD]}|r$|�d�nd}|�|�q|jD]}|r9|�d�nd}|�|�q/Wd�dS1sLwYdS)NrrFrOT)	r!r�r�r7r%rr:rr;)r�rrnrorrr�
visit_Call�s 

�"�z_Unparser.visit_CallcCs�dd�}|�tj|j�|�|j�|�dd��&||j�r(|�|j|jj�n|�|j�Wd�dSWd�dS1sAwYdS)NcSs&t|t�o|jotdd�|jD��S)Ncss�|]}t|t�VqdSr#)r
ZStarred)rRr�rrrrV�s�zE_Unparser.visit_Subscript.<locals>.is_simple_tuple.<locals>.<genexpr>)r
r2r4�any)Zslice_valuerrr�is_simple_tuple�s

��z2_Unparser.visit_Subscript.<locals>.is_simple_tupler�r�)	r!r�r�r&r%rr�rr4)r�rr�rrr�visit_Subscript�s

�"�z_Unparser.visit_SubscriptcCs*|�d�|�tj|j�|�|j�dS)Nr)rr!r�r�r&r%r rrr�
visit_Starred�s
z_Unparser.visit_StarredcCrF)Nr�rr rrr�visit_Ellipsis�rJz_Unparser.visit_EllipsiscCsR|jr	|�|j�|�d�|jr|�|j�|jr'|�d�|�|j�dSdS)Nr)�lowerr%r�upper�stepr rrr�visit_Slice�s

�z_Unparser.visit_SlicecCsZ|�d�|�|j�|���|jD]}|�|�qWd�dS1s&wYdS)Nzmatch )rr%�subjectr�cases)r�r�caserrr�visit_Match�s


�"�z_Unparser.visit_MatchcCs0|�|j�|jr|�d�|�|j�dSdSr�)r�argrBr%r rrr�	visit_arg��

�z_Unparser.visit_argc	Cs�d}|j|j}dgt|�t|j�|j}tt||�d�D]/\}}|\}}|r,d}n|�d�|�|�|rB|�d�|�|�|t|j�krN|�d�q|jsU|j	r~|rZd}n|�d�|�d�|jr~|�|jj
�|jjr~|�d�|�|jj�|j	r�t|j	|j�D]\}}|�d�|�|�|r�|�d�|�|�q�|j
r�|r�d}n|�d�|�d	|j
j
�|j
jr�|�d�|�|j
j�dSdSdS)
NTrLFrO�=z, /rrr�)�posonlyargsr:r<�defaults�	enumerater@rr%�vararg�
kwonlyargsrrB�kw_defaults�kwarg)	r�rr�Zall_argsr	r��elements�a�drrr�visit_arguments�sV




�






�

�z_Unparser.visit_argumentscCs<|jdur|�d�n|�|j�|�d�|�|j�dS)Nr�r)rrr%r&r rrr�
visit_keywords


z_Unparser.visit_keywordcCsp|�tj|��'|�d�|�|j�|�d�|�tj|j�|�|j�Wd�dS1s1wYdS)Nzlambda r)rr�r�rr%r:r!rIr rrr�visit_Lambda$s

"�z_Unparser.visit_LambdacCs*|�|j�|jr|�d|j�dSdS�Nrh)rrc�asnamer rrr�visit_alias,s�z_Unparser.visit_aliascCs0|�|j�|jr|�d�|�|j�dSdSr)r%�context_expr�
optional_varsrr rrr�visit_withitem1rz_Unparser.visit_withitemcCsl|�d�|�|j�|jr|�d�|�|j�|���|�|j�Wd�dS1s/wYdS)Nzcase r�)rr%�pattern�guardrrrIr rrr�visit_match_case7s


"�z_Unparser.visit_match_casecCr�r#)r%r&r rrr�visit_MatchValue@r
z_Unparser.visit_MatchValuecCr�r#)r�r&r rrr�visit_MatchSingletonCr
z_Unparser.visit_MatchSingletoncr�)Nr�r�crrrrr�rrrIrz/_Unparser.visit_MatchSequence.<locals>.<lambda>)rrr%�patternsr rr�r�visit_MatchSequenceFs
�"�z_Unparser.visit_MatchSequencecCs&|j}|dur	d}|�d|���dS)N�_r)rcr)r�rrcrrr�visit_MatchStarLsz_Unparser.visit_MatchStarc
s��fdd�}��dd��;|j}���fdd�|t||jdd��|j}|dur?|r/��d	���d
|���Wd�dSWd�dS1sJwYdS)Ncs*|\}}��|���d���|�dSr�r�)�pairr��pr�rr�write_key_pattern_pairSs

z<_Unparser.visit_MatchMapping.<locals>.write_key_pattern_pairr�r�crrrrr�rrr\rz._Unparser.visit_MatchMapping.<locals>.<lambda>T��strictrOr�)rr=rr@r �restr)r�rr&r=r)rr�r�visit_MatchMappingRs 
�
�"�z_Unparser.visit_MatchMappingc
s���tj|j���|j���dd��C|j}���fdd��j|�|j}|rO�fdd�}|r6��	d����fdd�|t
||jd	d
��Wd�dSWd�dS1sZwYdS)Nrrcrrrrr�rrrlrz,_Unparser.visit_MatchClass.<locals>.<lambda>cs&|\}}��|�d����|�dS)Nr)rr%)r$rrrr�rr�write_attr_patternpsz6_Unparser.visit_MatchClass.<locals>.write_attr_patternrOcrrrrr�rrrxrTr')r!r�r�rbr%rr r�	kwd_attrsrr@�kwd_patterns)r�rr Zattrsr+rr�r�visit_MatchClassfs(�

��"�z_Unparser.visit_MatchClasscCs�|j}|j}|dur|�d�dS|dur|�|j�dS|�tj|�� |�tj|j�|�|j�|�d|j���Wd�dS1sGwYdS)Nr"rh)	rcrrrr�r�r!r�r%)r�rrcrrrr�
visit_MatchAs}s"�z_Unparser.visit_MatchAscsh��tj|��#�jtj��g|j�R����fdd��j|j�Wd�dS1s-wYdS)Ncr)Nz | rrr�rrr�rz)_Unparser.visit_MatchOr.<locals>.<lambda>)rr�r�r!r�r rr%r rr�r�
visit_MatchOr�s"�z_Unparser.visit_MatchOr)rN)�r]r�r�r�rrr	rrr�propertyrrrrrrrr!r"r$r%r�r)r.r2r3r5r8r<r?rArCrErIrLrNrOrQrSrTrWrZr[r_rfrirprurvrtrzr{ryr}r~r�r�r�r�r�r�r�r�r�r�r�r(r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r@r�r�r�r�r�r�r�r��	frozensetr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrrrrrrrr!r#r*r.r/r0�
__classcell__rrr'rr��s4




		

�&
	�
���

3	
r�cCst�}|�|�Sr#)r�r�)Zast_objr�rrr�unparse�s
r4cCs�ddl}|jdd�}|jd|jdd�ddd	d
�|jddd
ddd�|jddddd�|jddddd�|jddtddd�|��}|j�}|��}Wd�n1sTwYt||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:�choicesr;z--no-type-commentsTZstore_falsez)don't add information about type comments)r:�actionr;z-az--include-attributes�
store_truez:include attributes such as line numbers and column offsets)r=r;z-iz--indentrPz'indentation of nodes (number of spaces))r%r:r;)r	)rgrK)�argparse�ArgumentParser�add_argumentZFileTyper'�
parse_argsr6�readrrcrZno_type_comments�printrjrgrK)r?�parserr:r6rZtreerrr�main�s2�
�
�
��
�rF�__main__)rr)TF)rL)T)J�sysZ_ast�
contextlibrr�enumrrrrJrjrsrxr{r}rtr�r�r�r�ry�objectr�r�rnr$r�r�r1rzr�r%r�r�r�r�r�r�r�r'r(r)rG�bytes�boolr�r�r�rWr�r�r�r2r�r�r��modr�Zexpr_contextr�r�r�r_�
float_info�
max_10_expr�r�Z_SINGLE_QUOTESr�r�r�r4rFr]rrrr�<module>s��;C
#
%:
<
	
���m

�