#NEWLINE# def replace_file( src , dst ) : #NEWLINE# #INDENT# '\n    Overwrite a file (in an atomic fashion when possible).\n\n    :param src: The pathname of the source file (a string).\n    :param dst: The pathname of the destination file (a string).\n    ' #NEWLINE# try : #NEWLINE# #INDENT# os . replace ( src , dst ) #NEWLINE# return #NEWLINE# #UNINDENT# except AttributeError : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# os . rename ( src , dst ) #NEWLINE# return #NEWLINE# #UNINDENT# except OSError as e : #NEWLINE# #INDENT# if ( e . errno != errno . EEXIST ) : #NEWLINE# #INDENT# raise #NEWLINE# #UNINDENT# #UNINDENT# os . remove ( dst ) #NEWLINE# os . rename ( src , dst )