def __manage_backups(self):
        # Only keep backups if the user wants them
        if self.MAX_BACKUP_COUNT <= 0:
            return

        # Make sure there is a backup of the history for today
        (root, ext) = os.path.splitext(self.HISTORY_FILE)
        datestamp = time.strftime('%Y%m%d')
        backup = '%s_%s%s' % (root, datestamp, ext)
        if not os.path.exists(backup):
            self.debug('Backing up the history file for %s' % datestamp)
            shutil.copy(self.HISTORY_FILE, backup)

        # Limit the number of backup files to keep
        listing = sorted(glob.glob('%s_*%s' % (root, ext)), reverse=True)
        if len(listing) > self.MAX_BACKUP_COUNT:
            for discard_file in listing[self.MAX_BACKUP_COUNT:]:
                self.debug('Discarding old backup %s' % discard_file)
                os.remove(discard_file)
dataset/ETHPy150Open FichteFoll/FileHistory/file_history.py/FileHistory.__manage_backups/original