def close(self):
        if self.csv_writer is not None:
            if not isinstance(self.outfile,
                              (StringIO.StringIO, cStringIO.OutputType)):
                # Closing a StringIO deletes its contents.
                self.outfile.close()
            self.outfile = None
            self.csv_writer = None

        # Save off a backup copy if requested.
        if self.num_backups > 0:
            timestamp = datetime.datetime.now().strftime('%Y-%m-%d_%H-%M-%S')

            parts = self.filename.split('.')
            if len(parts) > 1:
                name = ''.join(parts[:-1])
                extension = parts[-1]
                backup_name = '%s_%s.%s' % (name, timestamp, extension)
                globname = name
            else:
                backup_name = '%s_%s' % (self.filename, timestamp)
                globname = self.filename

            if os.path.isfile(self.filename):
                shutil.copyfile(self.filename, backup_name)

            # Clean up old backups if we exceed our max
            backups = glob.glob(globname + '_*')
            if len(backups) > self.num_backups:
                sortbackups = sorted(backups)
                for item in sortbackups[:len(backups) - self.num_backups]:
                    os.remove(item)
Private implementation of the `show_block()` method.
dataset/ETHPy150Open OpenMDAO/OpenMDAO-Framework/openmdao.lib/src/openmdao/lib/casehandlers/csvcase.py/CSVCaseRecorder.close--crossover with--dataset/ETHPy150Open traverseda/pycraft/pycraft/world.py/World._show_block