def updateDataFile(self):

        # write out the updated data file
        tempFile, tempName = tempfile.mkstemp(".tmp", "notify",
                                              os.path.dirname(self.__filename))
        writer = csv.writer(os.fdopen(tempFile, "w"),
                            lineterminator=os.linesep)
        for notification in self.notifications:
            writer.writerow(
                [repr(notification.row),
                 notification.date.toString(resolutionInYears=False),
                 notification.whom, notification.text, notification.status])
        del writer # force the writer to close the file

        # keep the existing file around, just in case
        os.rename(self.__filename, self.__filename + ".old")

        # move the new file into place
        try:
            os.rename(tempName, self.__filename)
        except Exception, ex:
            # if we fail, move the .old file back and propagate the error up
            os.rename(self.__filename + ".old", self.__filename)
            raise ex
        
        return
Write updated data file and move it into place
dataset/ETHPy150Open longnow/longview/lvnotify.py/DefaultNotifier.updateDataFile