(self, lines_to_write)
overwrite the file with line_to_write

        :param lines_to_write: lines to write to the file - they should be \n terminated
        :type lines_to_write: List[str]

        :return: None
overwrite the file with line_to_write
overwrite the file with line_to_write
def overwrite_source_file(self, lines_to_write):
        """overwrite the file with line_to_write

        :param lines_to_write: lines to write to the file - they should be \n terminated
        :type lines_to_write: List[str]

        :return: None
        """
        tmp_filename = '{0}.writing'.format(self.input_file)
        ok = False
        try:
            with open(tmp_filename, 'w') as fh:
                fh.writelines(lines_to_write)
            ok = True
        finally:
            if ok:
                if platform.system() == 'Windows':
                    self._windows_rename(tmp_filename)
                else:
                    os.rename(tmp_filename, self.input_file)
            else:
                os.unlink(tmp_filename)
def overwrite_source_file ( self , lines_to_write ) : tmp_filename = '{0}.writing' . format ( self . input_file ) ok = False try : with open ( tmp_filename , 'w' ) as fh : fh . writelines ( lines_to_write ) ok = True finally : if ok : if platform . system ( ) == 'Windows' : self . _windows_rename ( tmp_filename ) else : os . rename ( tmp_filename , self . input_file ) else : os . unlink ( tmp_filename )