#NEWLINE# def fixup_egglink_file( filename , old_dir , new_dir ) : #NEWLINE# #INDENT# logger . debug ( ( 'fixing %s' % filename ) ) #NEWLINE# with open ( filename , 'rb' ) as f : #NEWLINE# #INDENT# link = f . read ( ) . decode ( 'utf-8' ) . strip ( ) #NEWLINE# #UNINDENT# if _dirmatch ( link , old_dir ) : #NEWLINE# #INDENT# link = link . replace ( f , new_dir , 1 ) #NEWLINE# with open ( filename , 'wb' ) as f : #NEWLINE# #INDENT# link = ( link + '\n' ) . encode ( 'utf-8' ) #NEWLINE# f . write ( link )