a
    ze	                     @   s   d Z ddlmZ dZddlmZ ddlZddlZddlZddlm	Z	 dd	lm
Z
 dd
l
mZ e  dd Zdd Zedkre  dS )z,Main program for testing the infrastructure.    )print_functionz#Guido van Rossum <guido@python.org>   )supportN   )pytree)pgen2)driverc            
      C   s  t d} t j| tjd}d}|j|dd}t||s>td tj	dd  sPd S g }tj
D ]|}tj
| }|d u sZt|ds|qZ|j}|d	r|d d
 }|dsqZtd|tjd |j|dd}t||rZ|| qZtjD ]}zt|}W n ty   Y qY n0 td|dtjd |D ]}|ds4q td|tjd tj||}z|j|dd}W n4 tjjy }	 ztd|	 W Y d }	~	n d }	~	0 0 t||r || q q|std ntd |D ]}td| qd S )NzGrammar.txt)convertz
example.pyT)debugz	No diffs.r   __file__z.pycz.pyZParsing)fileZScanningz...zParseError:zNo problems.  Congratulations!zProblems in following files:z***)r   Zload_grammarZDriverr   r	   Z
parse_filediffprintsysargvmoduleshasattrr   endswithstderrappendpathoslistdirOSErrorjoinr   parseZ
ParseError)
ZgrZdrfntreeZproblemsnamemoddirnameserr r$   6/usr/lib/python3.9/lib2to3/tests/pytree_idempotency.pymain   sX    








 
r&   c              	   C   s\   t dd}z|t| W |  n
|  0 ztd|  W td S td 0 d S )N@wzdiff -u %s @)openwritestrcloser   systemremove)r   r   fr$   r$   r%   r   R   s    

r   __main__)__doc__Z
__future__r   
__author__ r   r   r   loggingr   r   r   basicConfigr&   r   __name__r$   r$   r$   r%   <module>   s   8