

def __manage_backups(self):
    if (self.MAX_BACKUP_COUNT <= 0):
        return
    (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)
    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