�
�fc @ s� d d l Z d d l Z d d l Z d d l Td d l Z e j j Z e Z e j j Z
d a d � Z
e j d � Z d � Z d � Z d � Z d � Z e d k r� e
� n d S(
i����N( t *c C sp d t j d } y# t j t j d d � \ } } Wn; t j k
rq } t | d � t | � t j d � n Xx) | D]! \ } } | d k ry | a qy qy Wt s� t d d k s� | r� t d � t | � t j d � n d } xv | D]n } t j j | � rt
| � r[d } q[q� t j j | � rFt | d
� d } q� t | � r� d } q� q� Wt j | � d S( Ns0 usage: %s -i /interpreter file-or-directory ...
i i s i:s
i s -it /s' -i option or file-or-directory missing
s" : will not process symbolic links
(
t syst argvt getoptt errort errt exitt new_interpretert ost patht isdirt recursedownt islinkt fix( t usaget optst argst msgt ot at badt arg( ( s- /usr/lib64/python2.7/Tools/scripts/pathfix.pyt main" s4 #
s ^[a-zA-Z0-9_]+\.py$c C s t j | � d k S( Ni ( t ispythonprogt match( t name( ( s- /usr/lib64/python2.7/Tools/scripts/pathfix.pyt ispython? s c C s1 t d | f � d } y t j | � } Wn+ t j k
rW } t d | | f � d SX| j � g } x� | D]� } | t j t j f k r� qo n t j j | | � } t j j
| � r� qo t j j | � r� | j | � qo t
| � ro t | � rd } qqo qo Wx# | D] } t | � rd } qqW| S( Ns recursedown(%r)
i s %s: cannot list directory: %r
i ( t dbgR t listdirR R t sortt curdirt pardirR
t joinR
R t appendR R R ( t dirnameR t namesR t subdirsR t fullname( ( s- /usr/lib64/python2.7/Tools/scripts/pathfix.pyR B s0
c C s< y t | d � } Wn( t k
r= } t d | | f � d SX| j � } t | � } | | k r~ t | d � | j � d St j j | � \ } } t j j
| d | � } y t | d � } Wn2 t k
r� } | j � t d | | f � d SXt | d � | j | � d } x* | j | � }
|
s4Pn | j |
� qW| j � | j � y+ t j
| � } t j | | t d @� Wn* t j k
r�} t d | | f � n Xy t j | | d
� Wn* t j k
r�} t d | | f � n Xy t j | | � Wn+ t j k
r7} t d | | f � d SXd S( Nt rs %s: cannot open: %r
i s : no change
t @t ws %s: cannot create: %r
s : updating
i i i� s %s: warning: chmod failed (%r)
t ~s %s: warning: backup failed (%r)
s %s: rename failed (%r)
i i ( t opent IOErrorR t readlinet fixlinet rept closeR R
t splitR! t writet readt statt chmodt ST_MODER t rename( t filenamet fR t linet fixedt headt tailt tempnamet gt BUFSIZEt buft statbuf( ( s- /usr/lib64/python2.7/Tools/scripts/pathfix.pyR X sX
c C s+ | j d � s | Sd | k r# | Sd t S( Ns #!t pythons #! %s
( t
startswithR ( R: ( ( s- /usr/lib64/python2.7/Tools/scripts/pathfix.pyR. � s
t __main__( R t reR R4 R t stderrR2 R R t stdoutR/ t NoneR R t compileR R R R R. t __name__( ( ( s- /usr/lib64/python2.7/Tools/scripts/pathfix.pyt