� �fc@s�ddlZddlZddlZddlTddlZejjZeZej jZ da d�Z ejd�Zd�Zd�Zd�Zd�Zed kr�e �ndS( i����N(t*cCspdtjd}y#tjtjdd�\}}Wn;tjk rq}t|d�t|�tjd�nXx)|D]!\}}|dkry|aqyqyWt s�tddks�| r�td �t|�tjd�nd}xv|D]n}tjj |�rt |�r[d}q[q�tjj |�rFt|d �d}q�t |�r�d}q�q�Wtj|�dS( Ns0usage: %s -i /interpreter file-or-directory ... iisi:s is-it/s'-i option or file-or-directory missing s": will not process symbolic links ( tsystargvtgetoptterrorterrtexittnew_interpretertostpathtisdirt recursedowntislinktfix(tusagetoptstargstmsgtotatbadtarg((s-/usr/lib64/python2.7/Tools/scripts/pathfix.pytmain"s4#         s^[a-zA-Z0-9_]+\.py$cCstj|�dkS(Ni(t ispythonprogtmatch(tname((s-/usr/lib64/python2.7/Tools/scripts/pathfix.pytispython?scCs1td|f�d}ytj|�}Wn+tjk rW}td||f�dSX|j�g}x�|D]�}|tjtjfkr�qontjj ||�}tjj |�r�qotjj |�r�|j |�qot |�rot|�rd}qqoqoWx#|D]}t|�rd}qqW|S(Nsrecursedown(%r) is%s: cannot list directory: %r i(tdbgR tlistdirRRtsorttcurdirtpardirR tjoinR R tappendRRR (tdirnameRtnamesRtsubdirsRtfullname((s-/usr/lib64/python2.7/Tools/scripts/pathfix.pyR Bs0      c Cs<yt|d�}Wn(tk r=}td||f�dSX|j�}t|�}||kr~t|d�|j�dStjj |�\}}tjj |d|�}yt|d�}Wn2tk r�}|j�td||f�dSXt|d�|j |�d} x*|j | �} | s4Pn|j | �qW|j�|j�y+tj |�} tj|| td @�Wn*tjk r�}td ||f�nXytj||d �Wn*tjk r�}td||f�nXytj||�Wn+tjk r7}td||f�dSXdS(Ntrs%s: cannot open: %r is : no change t@tws%s: cannot create: %r s : updating iii�s%s: warning: chmod failed (%r) t~s %s: warning: backup failed (%r) s%s: rename failed (%r) ii (topentIOErrorRtreadlinetfixlinetreptcloseR R tsplitR!twritetreadtstattchmodtST_MODERtrename( tfilenametfRtlinetfixedtheadttailttempnametgtBUFSIZEtbuftstatbuf((s-/usr/lib64/python2.7/Tools/scripts/pathfix.pyRXsX        cCs+|jd�s|Sd|kr#|SdtS(Ns#!tpythons#! %s (t startswithR(R:((s-/usr/lib64/python2.7/Tools/scripts/pathfix.pyR.�s  t__main__(RtreR R4RtstderrR2RRtstdoutR/tNoneRRtcompileRRR RR.t__name__(((s-/usr/lib64/python2.7/Tools/scripts/pathfix.pyts           5