o
    ¶2úh"k  ã                   @   s²   d Z ddlmZmZ ddlZddlZddlZddlZddlZddlm	Z	 de
ejjd ƒ Zdd„ ZG d	d
„ d
ƒZejfdd„Zdd„ Zdd„ ZedkrWeejdd… ƒ dS dS )z'Usage: unparse.py <path to source file>é    )Úprint_functionÚunicode_literalsN)ÚStringIOÚ1eé   c                 C   sJ   t |ƒ}z|t|ƒƒ W n
 ty   Y dS w |D ]	}| ƒ  ||ƒ qdS )z<Call f on each item in seq, calling inter() in between.
    N)ÚiterÚnextÚStopIteration)ÚinterÚfÚseqÚx© r   úN/var/www/html/chatgem/venv/lib/python3.10/site-packages/astunparse/unparser.pyÚ
interleave   s   ÿ
þr   c                   @   s2  e Zd ZdZejfdd„ZdÓdd„Zdd„ Zd	d
„ Z	dd„ Z
dd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd „ Zd!d"„ Zd#d$„ Zd%d&„ Zd'd(„ Zd)d*„ Zd+d,„ Zd-d.„ Zd/d0„ Zd1d2„ Zd3d4„ Zd5d6„ Zd7d8„ Z d9d:„ Z!d;d<„ Z"d=d>„ Z#d?d@„ Z$dAdB„ Z%dCdD„ Z&dEdF„ Z'dGdH„ Z(dIdJ„ Z)dKdL„ Z*dMdN„ Z+dOdP„ Z,dQdR„ Z-dSdT„ Z.dUdV„ Z/dWdX„ Z0dÔdZd[„Z1d\d]„ Z2d^d_„ Z3d`da„ Z4dbdc„ Z5ddde„ Z6dfdg„ Z7dhdi„ Z8djdk„ Z9dldm„ Z:dndo„ Z;dpdq„ Z<drds„ Z=dtdu„ Z>dvdw„ Z?dxdy„ Z@dzd{„ ZAd|d}„ ZBd~d„ ZCd€d„ ZDd‚dƒ„ ZEd„d…„ ZFd†d‡„ ZGdˆd‰„ ZHdŠd‹„ ZIdŒd„ ZJdŽd„ ZKdd‘d’d“d”œZLd•d–„ ZMd’d“d—d˜d™dšd›dœddždŸd d¡d¢œZNd£d¤„ ZOd¥d¦d§d¨d©dªd«d¬d­d®d¯œ
ZPd°d±„ ZQeRjSd²eRjTd³iZUd´dµ„ ZVd¶d·„ ZWd¸d¹„ ZXdºd»„ ZYd¼d½„ ZZd¾d¿„ Z[dÀdÁ„ Z\dÂdÃ„ Z]dÄdÅ„ Z^dÆdÇ„ Z_dÈdÉ„ Z`dÊdË„ ZadÌdÍ„ ZbdÎdÏ„ ZcdÐdÑ„ ZddÒS )ÕÚUnparserzŽMethods in this class recursively traverse an AST and
    output source code for the abstract syntax; original formatting
    is disregarded. c                 C   s8   || _ g | _d| _|  |¡ td| j d | j  ¡  dS )zTUnparser(tree, file=sys.stdout) -> None.
         Print the source for tree to file.r   Ú ©ÚfileN)r   Úfuture_importsÚ_indentÚdispatchÚprintÚflush)ÚselfÚtreer   r   r   r   Ú__init__    s   
zUnparser.__init__r   c                 C   s   | j  dd| j  | ¡ dS )zBIndent a piece of text, according to the current indentation levelÚ
z    N)r   Úwriter   ©r   Útextr   r   r   Úfill*   s   zUnparser.fillc                 C   s   | j  t |¡¡ dS )z+Append a piece of text to the current line.N)r   r   ÚsixÚ	text_typer   r   r   r   r   .   s   zUnparser.writec                 C   s   |   d¡ |  jd7  _dS )z(Print ':', and increase the indentation.ú:r   N)r   r   ©r   r   r   r   Úenter2   s   
zUnparser.enterc                 C   s   |  j d8  _ dS )zDecrease the indentation level.r   N)r   r%   r   r   r   Úleave7   s   zUnparser.leavec                 C   s@   t |tƒr|D ]}|  |¡ qdS t| d|jj ƒ}||ƒ dS )z:Dispatcher function, dispatching tree type T to method _T.NÚ_)Ú
isinstanceÚlistr   ÚgetattrÚ	__class__Ú__name__)r   r   ÚtÚmethr   r   r   r   ;   s   
zUnparser.dispatchc                 C   ó   |j D ]}|  |¡ qd S ©N©Úbodyr   ©r   r   Ústmtr   r   r   Ú_ModuleL   ó   
ÿzUnparser._Modulec                 C   r0   r1   r2   r4   r   r   r   Ú_InteractiveP   r7   zUnparser._Interactivec                 C   ó   |   |j¡ d S r1   )r   r3   ©r   r   r   r   r   Ú_ExpressionT   ó   zUnparser._Expressionc                 C   s   |   ¡  |  |j¡ d S r1   )r!   r   Úvaluer:   r   r   r   Ú_ExprX   s   zUnparser._Exprc                 C   s:   |   d¡ |  |j¡ |   d¡ |  |j¡ |   d¡ d S )Nú(z := ú))r   r   Útargetr=   r:   r   r   r   Ú
_NamedExpr\   ó
   

zUnparser._NamedExprc                    ó&   ˆ   d¡ t‡ fdd„ˆ j|jƒ d S )Nzimport c                      ó
   ˆ   d¡S ©Nú, ©r   r   r%   r   r   Ú<lambda>e   ó   
 z"Unparser._Import.<locals>.<lambda>)r!   r   r   Únames©r   r.   r   r%   r   Ú_Importc   ó   
zUnparser._Importc                    sz   |j r|j dkrˆ j dd„ |jD ƒ¡ ˆ  d¡ ˆ  d|j ¡ |j r*ˆ  |j ¡ ˆ  d¡ t‡ fdd„ˆ j|jƒ d S )	NÚ
__future__c                 s   s    | ]}|j V  qd S r1   )Úname©Ú.0Únr   r   r   Ú	<genexpr>j   s   € z'Unparser._ImportFrom.<locals>.<genexpr>zfrom Ú.z import c                      rE   rF   rH   r   r%   r   r   rI   q   rJ   z&Unparser._ImportFrom.<locals>.<lambda>)	Úmoduler   ÚextendrK   r!   r   Úlevelr   r   rL   r   r%   r   Ú_ImportFromg   s   

zUnparser._ImportFromc                 C   s8   |   ¡  |jD ]}|  |¡ |  d¡ q|  |j¡ d S )Nú = )r!   Útargetsr   r   r=   )r   r.   rA   r   r   r   Ú_Assigns   s
   

zUnparser._Assignc                 C   sB   |   ¡  |  |j¡ |  d| j|jjj  d ¡ |  |j¡ d S )Nú z= )	r!   r   rA   r   ÚbinopÚopr,   r-   r=   rL   r   r   r   Ú
_AugAssignz   s   zUnparser._AugAssignc                 C   sŠ   |   ¡  |jst|jtjƒr|  d¡ |  |j¡ |js(t|jtjƒr(|  d¡ |  d¡ |  |j¡ |j	rC|  d¡ |  |j	¡ d S d S )Nr?   r@   ú: rZ   )
r!   Úsimpler)   rA   ÚastÚNamer   r   Ú
annotationr=   rL   r   r   r   Ú
_AnnAssign€   s   



þzUnparser._AnnAssignc                 C   s.   |   d¡ |jr|  d¡ |  |j¡ d S d S )NÚreturnr]   )r!   r=   r   r   rL   r   r   r   Ú_Return   s
   

þzUnparser._Returnc                 C   ó   |   d¡ d S )NÚpass©r!   rL   r   r   r   Ú_Pass“   ó   zUnparser._Passc                 C   ri   )NÚbreakrk   rL   r   r   r   Ú_Break–   rm   zUnparser._Breakc                 C   ri   )NÚcontinuerk   rL   r   r   r   Ú	_Continue™   rm   zUnparser._Continuec                    rD   )Nzdel c                      rE   rF   rH   r   r%   r   r   rI   ž   rJ   z"Unparser._Delete.<locals>.<lambda>)r!   r   r   r[   rL   r   r%   r   Ú_Deleteœ   rN   zUnparser._Deletec                 C   s:   |   d¡ |  |j¡ |jr|  d¡ |  |j¡ d S d S )Nzassert rG   )r!   r   ÚtestÚmsgr   rL   r   r   r   Ú_Assert    s   

þzUnparser._Assertc                 C   sV   |   d¡ |  |j¡ |jr|  d¡ |  |j¡ |jr)|  d¡ |  |j¡ d S d S )Nzexec ú in rG   )r!   r   r3   Úglobalsr   ÚlocalsrL   r   r   r   Ú_Exec§   s   


þzUnparser._Execc                 C   sp   |   d¡ d}|jr|  d¡ |  |j¡ d}|jD ]}|r$|  d¡ nd}|  |¡ q|js6|  d¡ d S d S )Nzprint Fú>>TrG   ú,)r!   Údestr   r   ÚvaluesÚnl)r   r.   Údo_commaÚer   r   r   Ú_Print±   s   


ÿzUnparser._Printc                    rD   )Nzglobal c                      rE   rF   rH   r   r%   r   r   rI   Á   rJ   z"Unparser._Global.<locals>.<lambda>©r!   r   r   rK   rL   r   r%   r   Ú_Global¿   rN   zUnparser._Globalc                    rD   )Nz	nonlocal c                      rE   rF   rH   r   r%   r   r   rI   Å   rJ   z$Unparser._Nonlocal.<locals>.<lambda>r‚   rL   r   r%   r   Ú	_NonlocalÃ   rN   zUnparser._Nonlocalc                 C   ó>   |   d¡ |   d¡ |jr|   d¡ |  |j¡ |   d¡ d S )Nr?   Úawaitr]   r@   ©r   r=   r   rL   r   r   r   Ú_AwaitÇ   ó   


zUnparser._Awaitc                 C   r…   )Nr?   Úyieldr]   r@   r‡   rL   r   r   r   Ú_YieldÏ   r‰   zUnparser._Yieldc                 C   r…   )Nr?   z
yield fromr]   r@   r‡   rL   r   r   r   Ú
_YieldFrom×   r‰   zUnparser._YieldFromc                 C   sº   |   d¡ tjr/|js|jrJ ‚d S |  d¡ |  |j¡ |jr-|  d¡ |  |j¡ d S d S |  d¡ |jr=|  |j¡ |jrK|  d¡ |  |j¡ |j	r[|  d¡ |  |j	¡ d S d S )NÚraiser]   z from rG   )
r!   r"   ÚPY3ÚexcÚcauser   r   ÚtypeÚinstÚtbackrL   r   r   r   Ú_Raiseß   s*   



þ


þzUnparser._Raisec                 C   sœ   |   d¡ |  ¡  |  |j¡ |  ¡  |jD ]}|  |¡ q|jr4|   d¡ |  ¡  |  |j¡ |  ¡  |jrL|   d¡ |  ¡  |  |j¡ |  ¡  d S d S )NÚtryÚelseÚfinally)r!   r&   r   r3   r'   ÚhandlersÚorelseÚ	finalbody©r   r.   Úexr   r   r   Ú_Tryõ   s"   



üzUnparser._Tryc                 C   sp   |   d¡ |  ¡  |  |j¡ |  ¡  |jD ]}|  |¡ q|jr6|   d¡ |  ¡  |  |j¡ |  ¡  d S d S )Nr•   r–   )r!   r&   r   r3   r'   r˜   r™   r›   r   r   r   Ú
_TryExcept  s   


üzUnparser._TryExceptc                 C   s~   t |jƒdkrt|jd tjƒr|  |j¡ n|  d¡ |  ¡  |  |j¡ |  ¡  |  d¡ |  ¡  |  |j	¡ |  ¡  d S )Nr   r   r•   r—   )
Úlenr3   r)   rc   Ú	TryExceptr   r!   r&   r'   rš   rL   r   r   r   Ú_TryFinally  s    

zUnparser._TryFinallyc                 C   sv   |   d¡ |jr|  d¡ |  |j¡ |jr+|  d¡ tjr%|  |j¡ n|  |j¡ |  ¡  |  |j¡ |  	¡  d S )NÚexceptr]   ú as )
r!   r‘   r   r   rP   r"   rŽ   r&   r3   r'   rL   r   r   r   Ú_ExceptHandler$  s   


zUnparser._ExceptHandlerc                 C   sz  |   d¡ |jD ]}|  d¡ |  |¡ q|  d|j ¡ tjr|   d¡ d}|jD ]}|r4|   d¡ nd}|  |¡ q*|jD ]}|rI|   d¡ nd}|  |¡ q?t	j
d d… d	k rŠ|jrr|re|   d¡ nd}|   d
¡ |  |j¡ |jrŠ|r}|   d¡ nd}|   d¡ |  |j¡ |   d¡ n|jr­|   d¡ |jD ]}|  |¡ |   d¡ q›|   d¡ |  ¡  |  |j¡ |  ¡  d S )Nr   ú@zclass r?   FrG   Té   ©é   é   Ú*ú**r@   )r   Údecorator_listr!   r   rP   r"   rŽ   ÚbasesÚkeywordsÚsysÚversion_infoÚstarargsÚkwargsr&   r3   r'   )r   r.   ÚdecoÚcommar€   Úar   r   r   Ú	_ClassDef3  sJ   











zUnparser._ClassDefc                 C   ó   |   |d¡ d S )NÚdef©Ú_Unparser__FunctionDef_helperrL   r   r   r   Ú_FunctionDefZ  r<   zUnparser._FunctionDefc                 C   r·   )Nz	async defr¹   rL   r   r   r   Ú_AsyncFunctionDef]  r<   zUnparser._AsyncFunctionDefc                 C   sž   |   d¡ |jD ]}|  d¡ |  |¡ q|d |j d }|  |¡ |  |j¡ |   d¡ t|ddƒr?|   d¡ |  |j¡ |  ¡  |  |j	¡ |  
¡  d S )	Nr   r¥   r]   r?   r@   ÚreturnsFz -> )r   r¬   r!   r   rP   Úargsr+   r½   r&   r3   r'   )r   r.   Úfill_suffixr³   Údef_strr   r   r   Ú__FunctionDef_helper`  s   





zUnparser.__FunctionDef_helperc                 C   ó   |   d|¡ d S )Nzfor ©Ú_Unparser__For_helperrL   r   r   r   Ú_Forp  r<   zUnparser._Forc                 C   rÂ   )Nz
async for rÃ   rL   r   r   r   Ú	_AsyncFors  r<   zUnparser._AsyncForc                 C   s|   |   |¡ |  |j¡ |  d¡ |  |j¡ |  ¡  |  |j¡ |  ¡  |jr<|   d¡ |  ¡  |  |j¡ |  ¡  d S d S )Nrv   r–   )	r!   r   rA   r   r   r&   r3   r'   r™   )r   r!   r.   r   r   r   Ú__For_helperv  s   


üzUnparser.__For_helperc                 C   sî   |   d¡ |  |j¡ |  ¡  |  |j¡ |  ¡  |jr]t|jƒdkr]t|jd t	j
ƒr]|jd }|   d¡ |  |j¡ |  ¡  |  |j¡ |  ¡  |jr]t|jƒdkr]t|jd t	j
ƒs,|jru|   d¡ |  ¡  |  |j¡ |  ¡  d S d S )Nzif r   r   zelif r–   )r!   r   rs   r&   r3   r'   r™   rŸ   r)   rc   ÚIfrL   r   r   r   Ú_If„  s.   
ÿ

ùÿ	
üzUnparser._Ifc                 C   sf   |   d¡ |  |j¡ |  ¡  |  |j¡ |  ¡  |jr1|   d¡ |  ¡  |  |j¡ |  ¡  d S d S )Nzwhile r–   )r!   r   rs   r&   r3   r'   r™   rL   r   r   r   Ú_Whileš  s   

üzUnparser._WhileFc                    s~   ˆ   |rdnd¡ t|dƒrt‡ fdd„ˆ j|jƒ nˆ  |j¡ |jr/ˆ  d¡ ˆ  |j¡ ˆ  ¡  ˆ  |j	¡ ˆ  
¡  d S )Nzasync with zwith Úitemsc                      rE   rF   rH   r   r%   r   r   rI   ©  rJ   z(Unparser._generic_With.<locals>.<lambda>r£   )r!   Úhasattrr   r   rË   Úcontext_exprÚoptional_varsr   r&   r3   r'   )r   r.   Úasync_r   r%   r   Ú_generic_With¦  s   

zUnparser._generic_Withc                 C   s   |   |¡ d S r1   ©rÐ   rL   r   r   r   Ú_With³  rm   zUnparser._Withc                 C   s   | j |dd d S )NT)rÏ   rÑ   rL   r   r   r   Ú
_AsyncWith¶  s   zUnparser._AsyncWithc                 C   ó   |   t|jƒ¡ d S r1   )r   ÚreprÚsrL   r   r   r   Ú_Bytesº  ó   zUnparser._Bytesc                 C   sŠ   t jr|  t|jƒ¡ d S d| jvr|  t|jƒ¡ d S t|jtƒr.|  dt|jƒ ¡ d S t|jtƒrA|  t|jƒ 	d¡¡ d S J dƒ‚)Nr   ÚbÚuFzshouldn't get here)
r"   rŽ   r   rÕ   rÖ   r   r)   ÚstrÚunicodeÚlstripr:   r   r   r   Ú_Str½  s   
zUnparser._Strc                 C   s‚   |   d¡ tƒ }|  ||j ¡ | ¡ }d|v sd|v r ddg}ng d¢}|D ]}||vr5dj||d} nq&t|ƒ}|   |¡ d S )	Nr   r   úú'''ú""")ú'ú"rá   rà   z{quote_type}{v}{quote_type})Ú
quote_typeÚv)r   r   Ú_fstring_JoinedStrÚgetvalueÚformatrÕ   )r   r.   Ústringrå   Úquote_typesrä   r   r   r   Ú
_JoinedStrÍ  s   

þzUnparser._JoinedStrc                 C   s4   |   d¡ tƒ }|  ||j ¡ |   t| ¡ ƒ¡ d S )Nr   )r   r   ræ   rÕ   rç   )r   r.   ré   r   r   r   Ú_FormattedValueá  s   
zUnparser._FormattedValuec                 C   s.   |j D ]}t| dt|ƒj ƒ}|||ƒ qd S )NÚ	_fstring_)r}   r+   r‘   r-   )r   r.   r   r=   r/   r   r   r   ræ   è  s   
þzUnparser._fstring_JoinedStrc                 C   s"   |j  dd¡ dd¡}||ƒ d S ©NÚ{z{{Ú}z}})rÖ   Úreplace©r   r.   r   r=   r   r   r   Ú_fstring_Strí  s   zUnparser._fstring_Strc                 C   s2   t |jtƒsJ ‚|j dd¡ dd¡}||ƒ d S rî   )r)   r=   rÛ   rñ   rò   r   r   r   Ú_fstring_Constantñ  s   zUnparser._fstring_Constantc                 C   s®   |dƒ t ƒ }t|j|ƒ | ¡  d¡}| d¡r|dƒ ||ƒ |jdkr9t|jƒ}|dv s1J ‚|dj|dƒ |j	rQ|dƒ t
| d	t|j	ƒj ƒ}||j	|ƒ |d
ƒ d S )Nrï   r   r]   éÿÿÿÿÚsraz!{conversion})Ú
conversionr$   rí   rð   )r   r   r=   rç   ÚrstripÚ
startswithr÷   Úchrrè   Úformat_specr+   r‘   r-   )r   r.   r   Úexprr÷   r/   r   r   r   Ú_fstring_FormattedValueö  s    


z Unparser._fstring_FormattedValuec                 C   r9   r1   )r   ÚidrL   r   r   r   Ú_Name  r<   zUnparser._Namec                 C   rÔ   r1   )r   rÕ   r=   rL   r   r   r   Ú_NameConstant  rØ   zUnparser._NameConstantc                 C   s$   |   d¡ |  |j¡ |   d¡ d S )Nú`©r   r   r=   rL   r   r   r   Ú_Repr  s   
zUnparser._Reprc                 C   s:   t |ttfƒr|  t|ƒ dt¡¡ d S |  t|ƒ¡ d S )NÚinf)r)   ÚfloatÚcomplexr   rÕ   rñ   ÚINFSTR)r   r=   r   r   r   Ú_write_constant  s   zUnparser._write_constantc                    sž   |j }t|tƒr2ˆ  d¡ t|ƒdkr ˆ  |d ¡ ˆ  d¡ nt‡ fdd„ˆ j|ƒ ˆ  d¡ d S |tu r=ˆ  d¡ d S |jd	krGˆ  d	¡ ˆ  |j ¡ d S )
Nr?   r   r   r{   c                      rE   rF   rH   r   r%   r   r   rI   "  rJ   z$Unparser._Constant.<locals>.<lambda>r@   ú...rÚ   )	r=   r)   Útupler   rŸ   r  r   ÚEllipsisÚkind)r   r.   r=   r   r%   r   Ú	_Constant  s   



zUnparser._Constantc                 C   s†   t |jƒ}tjr|  | dt¡¡ d S | d¡r|  d¡ d|v r,| d¡r,| dd¡}|  | dt¡¡ | d¡rA|  d¡ d S d S )Nr  ú-r?   z*jÚjr@   )	rÕ   rS   r"   rŽ   r   rñ   r  rù   Úendswith)r   r.   Úrepr_nr   r   r   Ú_Num+  s   



ÿzUnparser._Numc                    s0   ˆ   d¡ t‡ fdd„ˆ j|jƒ ˆ   d¡ d S )Nú[c                      rE   rF   rH   r   r%   r   r   rI   <  rJ   z Unparser._List.<locals>.<lambda>ú])r   r   r   ÚeltsrL   r   r%   r   Ú_List:  s   
zUnparser._Listc                 C   ó:   |   d¡ |  |j¡ |jD ]}|  |¡ q|   d¡ d S ©Nr  r  ©r   r   ÚeltÚ
generators©r   r.   Úgenr   r   r   Ú	_ListComp?  rC   zUnparser._ListCompc                 C   r  )Nr?   r@   r  r  r   r   r   Ú_GeneratorExpF  rC   zUnparser._GeneratorExpc                 C   r  )Nrï   rð   r  r  r   r   r   Ú_SetCompM  rC   zUnparser._SetCompc                 C   sP   |   d¡ |  |j¡ |   d¡ |  |j¡ |jD ]}|  |¡ q|   d¡ d S )Nrï   ra   rð   )r   r   Úkeyr=   r  r  r   r   r   Ú	_DictCompT  ó   


zUnparser._DictCompc                 C   sh   t |ddƒr|  d¡ n|  d¡ |  |j¡ |  d¡ |  |j¡ |jD ]}|  d¡ |  |¡ q%d S )NÚis_asyncFz async for z for rv   ú if )r+   r   r   rA   r   Úifs)r   r.   Ú	if_clauser   r   r   Ú_comprehension]  s   



þzUnparser._comprehensionc                 C   sP   |   d¡ |  |j¡ |   d¡ |  |j¡ |   d¡ |  |j¡ |   d¡ d S )Nr?   r%  z else r@   )r   r   r3   rs   r™   rL   r   r   r   Ú_IfExpi  r#  zUnparser._IfExpc                    s:   |j sJ ‚ˆ  d¡ t‡ fdd„ˆ j|j ƒ ˆ  d¡ d S )Nrï   c                      rE   rF   rH   r   r%   r   r   rI   u  rJ   zUnparser._Set.<locals>.<lambda>rð   )r  r   r   r   rL   r   r%   r   Ú_Setr  s   

zUnparser._Setc                    sP   ˆ   d¡ ‡ fdd„‰‡ ‡fdd„}t‡ fdd„|t|j|jƒƒ ˆ   d¡ d S )	Nrï   c                    s"   ˆ   | ¡ ˆ  d¡ ˆ   |¡ d S ©Nra   )r   r   )Úkrå   r%   r   r   Úwrite_key_value_pairz  s   

z,Unparser._Dict.<locals>.write_key_value_pairc                    s6   | \}}|d u rˆ   d¡ ˆ  |¡ d S ˆ||ƒ d S )Nr«   )r   r   )Úitemr,  rå   ©r   r-  r   r   Ú
write_item  s
   
z"Unparser._Dict.<locals>.write_itemc                      rE   rF   rH   r   r%   r   r   rI   ˆ  rJ   z Unparser._Dict.<locals>.<lambda>rð   )r   r   ÚzipÚkeysr}   )r   r.   r0  r   r/  r   Ú_Dictx  s
   
	zUnparser._Dictc                    s^   ˆ   d¡ t|jƒdkr|jd }ˆ  |¡ ˆ   d¡ nt‡ fdd„ˆ j|jƒ ˆ   d¡ d S )Nr?   r   r   r{   c                      rE   rF   rH   r   r%   r   r   rI   ’  rJ   z!Unparser._Tuple.<locals>.<lambda>r@   )r   rŸ   r  r   r   )r   r.   r  r   r%   r   Ú_Tuple‹  s   


zUnparser._Tupleú~Únotú+r  )ÚInvertÚNotÚUAddÚUSubc                 C   sˆ   |   d¡ |   | j|jjj ¡ |   d¡ tjr7t|jtj	ƒr7t|j
tjƒr7|   d¡ |  |j
¡ |   d¡ n|  |j
¡ |   d¡ d S ©Nr?   r]   r@   )r   Úunopr_   r,   r-   r"   ÚPY2r)   rc   r;  ÚoperandÚNumr   rL   r   r   r   Ú_UnaryOp–  s   

"
zUnparser._UnaryOprª   r¥   ú/ú%z<<rz   ú|ú^ú&z//r«   )ÚAddÚSubÚMultÚMatMultÚDivÚModÚLShiftÚRShiftÚBitOrÚBitXorÚBitAndÚFloorDivÚPowc                 C   sN   |   d¡ |  |j¡ |   d| j|jjj  d ¡ |  |j¡ |   d¡ d S r<  )r   r   Úleftr^   r_   r,   r-   ÚrightrL   r   r   r   Ú_BinOpª  s
   
zUnparser._BinOpz==z!=ú<z<=ú>z>=Úiszis notÚinznot in)
ÚEqÚNotEqÚLtÚLtEÚGtÚGtEÚIsÚIsNotÚInÚNotInc                 C   sb   |   d¡ |  |j¡ t|j|jƒD ]\}}|   d| j|jj  d ¡ |  |¡ q|   d¡ d S r<  )	r   r   rT  r1  ÚopsÚcomparatorsÚcmpopsr,   r-   )r   r.   Úor€   r   r   r   Ú_Compare³  s   
zUnparser._CompareÚandÚorc                    sD   ˆ  d¡ dˆj|jj  ‰ t‡ ‡fdd„ˆj|jƒ ˆ  d¡ d S )Nr?   z %s c                      s
   ˆ  ˆ ¡S r1   rH   r   ©rÖ   r   r   r   rI   ¿  rJ   z"Unparser._BoolOp.<locals>.<lambda>r@   )r   Úboolopsr_   r,   r   r   r}   rL   r   rl  r   Ú_BoolOp¼  s   
zUnparser._BoolOpc              	   C   sZ   |   |j¡ t|jttdttdd ƒƒƒr t|jjtƒr |  d¡ |  d¡ |  |j¡ d S )NÚConstantr@  r]   rU   )	r   r=   r)   r+   rc   rS   Úintr   ÚattrrL   r   r   r   Ú
_AttributeÂ  s
   *

zUnparser._Attributec                 C   sî   |   |j¡ |  d¡ d}|jD ]}|r|  d¡ nd}|   |¡ q|jD ]}|r/|  d¡ nd}|   |¡ q%tjd d… dk rp|jrX|rK|  d¡ nd}|  d¡ |   |j¡ |jrp|rc|  d¡ nd}|  d¡ |   |j¡ |  d	¡ d S )
Nr?   FrG   Tr¦   r§   rª   r«   r@   )	r   Úfuncr   r¾   r®   r¯   r°   r±   r²   )r   r.   r´   r€   r   r   r   Ú_CallÌ  s.   




zUnparser._Callc                 C   s0   |   |j¡ |  d¡ |   |j¡ |  d¡ d S r  )r   r=   r   ÚslicerL   r   r   r   Ú
_Subscriptå  s   
zUnparser._Subscriptc                 C   s   |   d¡ |  |j¡ d S )Nrª   r  rL   r   r   r   Ú_Starredë  s   
zUnparser._Starredc                 C   ri   )Nr	  rH   rL   r   r   r   Ú	_Ellipsisð  rm   zUnparser._Ellipsisc                 C   r9   r1   )r   r=   rL   r   r   r   Ú_Indexó  r<   zUnparser._Indexc                 C   sR   |j r	|  |j ¡ |  d¡ |jr|  |j¡ |jr'|  d¡ |  |j¡ d S d S )Nr$   )Úlowerr   r   ÚupperÚsteprL   r   r   r   Ú_Sliceö  s   

þzUnparser._Slicec                    s   t ‡ fdd„ˆ j|jƒ d S )Nc                      rE   rF   rH   r   r%   r   r   rI     rJ   z$Unparser._ExtSlice.<locals>.<lambda>)r   r   ÚdimsrL   r   r%   r   Ú	_ExtSlice   s   zUnparser._ExtSlicec                 C   s0   |   |j¡ |jr|   d¡ |  |j¡ d S d S r+  )r   Úargre   r   rL   r   r   r   Ú_arg  ó
   
þzUnparser._argc           	      C   sL  d}t |dg ƒ|j }d gt|ƒt|jƒ  |j }tt||ƒdƒD ]2\}}|\}}|r/d}n|  d¡ |  |¡ |rE|  d¡ |  |¡ |tt |ddƒƒkrT|  d¡ q"|js^t |d	dƒr¥|rcd}n|  d¡ |  d
¡ |jr¥t	|jdƒrŽ|  |jj
¡ |jjr|  d¡ |  |jj¡ n|  |j¡ t |dd ƒr¥|  d¡ |  |j¡ t |d	dƒrÓt|j|jƒD ] \}}|r»d}n|  d¡ |  |¡f |rÒ|  d¡ |  |¡ q²|jr"|rÜd}n|  d¡ t	|jdƒr|  d|jj
 ¡ |jjr|  d¡ |  |jj¡ d S d S |  d|j ¡ t |dd ƒr$|  d¡ |  |j¡ d S d S d S )NTÚposonlyargsr   FrG   ú=r   z, /Ú
kwonlyargsrª   r€  ra   Úvarargannotationr«   Úkwargannotation)r+   r¾   rŸ   ÚdefaultsÚ	enumerater1  r   r   ÚvarargrÌ   r€  re   r†  r…  Úkw_defaultsÚkwargr‡  )	r   r.   ÚfirstÚall_argsrˆ  ÚindexÚelementsrµ   Údr   r   r   Ú
_arguments  sj   





€



€




€



þ
ô
zUnparser._argumentsc                 C   s<   |j d u r|  d¡ n|  |j ¡ |  d¡ |  |j¡ d S )Nr«   r„  )r€  r   r   r=   rL   r   r   r   Ú_keywordE  s
   

zUnparser._keywordc                 C   sD   |   d¡ |   d¡ |  |j¡ |   d¡ |  |j¡ |   d¡ d S )Nr?   zlambda ra   r@   )r   r   r¾   r3   rL   r   r   r   Ú_LambdaN  s   


zUnparser._Lambdac                 C   s*   |   |j¡ |jr|   d|j ¡ d S d S ©Nr£   )r   rP   ÚasnamerL   r   r   r   Ú_aliasV  s   ÿzUnparser._aliasc                 C   s0   |   |j¡ |jr|  d¡ |   |j¡ d S d S r•  )r   rÍ   rÎ   r   rL   r   r   r   Ú	_withitem[  r‚  zUnparser._withitemN)r   )F)er-   Ú
__module__Ú__qualname__Ú__doc__r¯   Ústdoutr   r!   r   r&   r'   r   r6   r8   r;   r>   rB   rM   rY   r\   r`   rf   rh   rl   ro   rq   rr   ru   ry   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  r   r"  r(  r)  r*  r3  r4  r=  rA  r^   rV  rg  ri  rc   ÚAndÚOrrm  rn  rr  rt  rv  rw  rx  ry  r}  r  r  r’  r“  r”  r—  r˜  r   r   r   r   r      sÆ    


'
		

þÿ

:	r   c                 C   sÌ   t jr<t| dƒ}t |j¡d }W d   ƒ n1 sw   Y  t| d|d}| ¡ }W d   ƒ n1 s6w   Y  nt| dƒ}| ¡ }W d   ƒ n1 sPw   Y  t|| dtj	dd}t
||ƒ d S )NÚrbr   Úr)ÚencodingÚexecT)Údont_inherit)r"   rŽ   ÚopenÚtokenizeÚdetect_encodingÚreadlineÚreadÚcompilerc   ÚPyCF_ONLY_ASTr   )ÚfilenameÚoutputÚpyfiler¡  Úsourcer   r   r   r   Ú	roundtripa  s   ÿ
ÿ€
ÿr¯  c                 C   sÒ   zdd„ t  | ¡D ƒ}W n ty   td|  tjd Y d S w |D ]D}t j | |¡}t j |¡r\t	ƒ }td| ƒ zt
||ƒ W q" ty[ } ztdt|ƒ ƒ W Y d }~q"d }~ww t j |¡rft|ƒ q"d S )Nc                 S   s   g | ]	}|  d ¡r|‘qS )z.py)r  rQ   r   r   r   Ú
<listcomp>q  s    ztestdir.<locals>.<listcomp>zDirectory not readable: %sr   z
Testing %sz$  Failed to compile, exception is %s)ÚosÚlistdirÚOSErrorr   r¯   ÚstderrÚpathÚjoinÚisfiler   r¯  Ú	ExceptionrÕ   ÚisdirÚtestdir)rµ   rK   rS   Úfullnamer¬  r€   r   r   r   rº  o  s(   ÿ€ÿ€örº  c                 C   s@   | d dkr| dd … D ]}t |ƒ qd S | D ]}t|ƒ qd S )Nr   z	--testdirr   )rº  r¯  )r¾   rµ   r   r   r   Úmain  s   
ÿ
ÿr¼  Ú__main__)r›  rO   r   r   r"   r¯   rc   r±  r¥  r   rÕ   Ú
float_infoÚ
max_10_expr  r   r   rœ  r¯  rº  r¼  r-   Úargvr   r   r   r   Ú<module>   s.          Lÿ