""" hiscores.hiscores - high socres: loading, saving, converting to string""" import os from .static import INITIAL_HIGHSCORES, MAX_HIGHSCORES 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=INITIAL_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)