B
    18\                 @   sj   d Z ddlZddlZdd ZedkrfeejdkrPedejd f  ed eejd ejd	  dS )
z
A script that replaces an old file with a new one, only if the contents
actually changed.  If not, the new file is simply deleted.

This avoids wholesale rebuilds when a code (re)generation phase does not
actually change the in-tree generated code.
    Nc          	   C   s`   t | d}| }W d Q R X t |d}| }W d Q R X ||krRt||  n
t| d S )Nrb)openreadosreplaceunlink)Zold_pathnew_pathfZold_contentsZnew_contents r
   Y/oak/stanford/groups/akundaje/marinovg/programs/Python-3.7.3/Tools/scripts/update_file.pymain   s    r   __main__   z7Usage: %s <path to be updated> <path with new contents>      )	__doc__r   sysr   __name__lenargvprintexitr
   r
   r
   r   <module>   s   
