def finalize(self, result):
        self.data.setdefault('time.finish', datetime.now())
        self.data.setdefault('result.success', result.wasSuccessful())
        
        for achievement in self.achievements:
            if self.data['achievements.unlocked'] not in achievement.key:
                achievement.finalize(self.data, result)

        if self.data_filename:
            try:
                data_file = open(self.data_filename, 'wb')
            except IOError:
                log.error("Failed to write achievement data to %s (I/O error)",
                          self.data_filename)
            else:
                log.info("Saving achievement data to %s", self.data_filename)
                self.data.save(data_file)
                data_file.close()

        output_stream = self.output_stream or self.config.stream
        if str is not unicode:
            output_stream = codecs.getwriter('utf-8')(output_stream)
        for achievement in self.data['achievements.new']:
            announcement = achievement.announcement()
            output_stream.write(announcement)
            output_stream.write('\n')
dataset/ETHPy150Open exogen/nose-achievements/noseachievements/plugin.py/AchievementsPlugin.finalize/swapped operands of `not in`