#NEWLINE# def fixup_link( filename , old_dir , new_dir , target = None ) : #NEWLINE# #INDENT# logger . debug ( ( 'fixing %s' % filename ) ) #NEWLINE# if ( target is None ) : #NEWLINE# #INDENT# target = os . readlink ( filename ) #NEWLINE# #UNINDENT# origdir = os . path . dirname ( os . path . abspath ( filename ) ) . replace ( new_dir , old_dir ) #NEWLINE# if ( not os . path . isabs ( target ) ) : #NEWLINE# #INDENT# target = os . path . abspath ( os . path . join ( origdir , old_dir ) ) #NEWLINE# rellink = True #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# rellink = False #NEWLINE# #UNINDENT# if _dirmatch ( target , old_dir ) : #NEWLINE# #INDENT# if rellink : #NEWLINE# #INDENT# target = target [ len ( origdir ) : ] . lstrip ( os . sep ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# target = target . replace ( old_dir , new_dir , 1 ) #NEWLINE# #UNINDENT# #UNINDENT# _replace_symlink ( filename , target )