#NEWLINE# def _replace_lines_in_file( path , regex_pattern , replacement ) : #NEWLINE# #INDENT# with open ( path ) as f : #NEWLINE# #INDENT# lines = f . readlines ( ) #NEWLINE# #UNINDENT# compiled_pattern = re . compile ( regex_pattern ) #NEWLINE# with open ( path , 'w' ) as f : #NEWLINE# #INDENT# for line in lines : #NEWLINE# #INDENT# line = compiled_pattern . sub ( replacement , line ) #NEWLINE# f . write ( line )