""" hiscores.hiscores - high socres: loading, saving, converting to string""" import os MAX_HIGHSCORES = 20 class HiScores: """ Keeps track of high scores """ def __init__(self): """ On creation load high scores from config file """ self.table=[] self.config_filename = os.path.join( os.getenv('HOME'), ".config", "sliceitoffrc") if not os.path.isfile(self.config_filename): self.table=[(0,"") for _ in range(MAX_HIGHSCORES)] return with open(self.config_filename, "r", encoding="utf-8") as config_file: for line in config_file: option, value = line.split('=') if option == 'hiscore': score, name = value.split('!') self.add(int(score.strip()),name.strip()) if len(self.table)