def write(self, delete_if_empty=False):
        filemap = (('tasks', self.name), ('done', '.%s.done' % self.name))
        for kind, filename in filemap:
            path = os.path.join(os.path.expanduser(self.taskdir), filename)
            if os.path.isdir(path):
                raise InvalidTaskfile
            tasks = sorted(getattr(self, kind).values(), key=itemgetter('id'))
            if tasks or not delete_if_empty:
                with open(path, 'w') as tfile:
                    for taskline in _tasklines_from_tasks(tasks):
                        tfile.write(taskline)
            elif not tasks and os.path.isfile(path):
                os.remove(path)
Watch a transient file, which will be created and deleted frequently
dataset/ETHPy150Open sjl/t/t.py/TaskDict.write--crossover with--dataset/ETHPy150Open seb-m/pyinotify/python2/pyinotify.py/WatchManager.watch_transient_file