def handle_temp(self, job):
    ' Remove temp files if they are no longer needed. Update temp_mtimes. '
    if self.notemp:
        return
    is_temp = (lambda f: is_flagged(f, 'temp'))
    needed = (lambda job_, f: any(((f in files) for (j, files) in self.depending[job_].items() if ((not self.finished(j)) and self.needrun(j) and (j != job)))))

    def unneeded_files():
        for (job_, files) in self.dependencies[job].items():
            tempfiles = set((f for f in job_.expanded_output if is_temp(f)))
            (yield from filterfalse(partial(needed, job_), (tempfiles & files)))
        if ((not job.dynamic_output) and ((job not in self.targetjobs) or (job.rule.name == self.workflow.first_rule))):
            tempfiles = (f for f in job.expanded_output if (is_temp(f) and (f not in self.targetfiles)))
            (yield from filterfalse(partial(needed, job), tempfiles))
    for f in unneeded_files():
        logger.info('Removing temporary output file {}.'.format(f))
        f.remove(remove_non_empty_dir=True)
Remove temp files if they are no longer needed. Update temp_mtimes.
def handle_temp(self, job):
    '  '
    if self.notemp:
        return
    is_temp = (lambda f: is_flagged(f, 'temp'))
    needed = (lambda job_, f: any(((f in files) for (j, files) in self.depending[job_].items() if ((not self.finished(j)) and self.needrun(j) and (j != job)))))

    def unneeded_files():
        for (job_, files) in self.dependencies[job].items():
            tempfiles = set((f for f in job_.expanded_output if is_temp(f)))
            (yield from filterfalse(partial(needed, job_), (tempfiles & files)))
        if ((not job.dynamic_output) and ((job not in self.targetjobs) or (job.rule.name == self.workflow.first_rule))):
            tempfiles = (f for f in job.expanded_output if (is_temp(f) and (f not in self.targetfiles)))
            (yield from filterfalse(partial(needed, job), tempfiles))
    for f in unneeded_files():
        logger.info('Removing temporary output file {}.'.format(f))
        f.remove(remove_non_empty_dir=True)