diff options
| author | Viljami Ilola <+@hix.fi> | 2024-04-27 01:36:07 +0300 | 
|---|---|---|
| committer | Viljami Ilola <+@hix.fi> | 2024-04-27 01:36:07 +0300 | 
| commit | db5967a52d9409842581276154a6fa9763a57a24 (patch) | |
| tree | 49200ce79e2cd80c80f64169b7488f503257d66c | |
| parent | 7a33e5020f9b1e7cf89bc532e2ddcf681f5bcf9c (diff) | |
discard badly formed hiscores
| -rw-r--r-- | src/sliceitoff/hiscores/hiscores.py | 7 | 
1 files changed, 5 insertions, 2 deletions
| diff --git a/src/sliceitoff/hiscores/hiscores.py b/src/sliceitoff/hiscores/hiscores.py index d963605..b981077 100644 --- a/src/sliceitoff/hiscores/hiscores.py +++ b/src/sliceitoff/hiscores/hiscores.py @@ -9,8 +9,11 @@ class HiScores:          """ On creation load high scores from config file """          self.table=[]          for value in settings.get_values("hiscore"): -            score, name = value.split('!') -            self.add(int(score.strip()),name.strip()) +            try: +                score, name = value.split('!') +                self.add(int(score.strip()),name.strip()) +            except ValueError: +                pass          if len(self.table)<MAX_HIGHSCORES:              self.table+=[(0,"") for _ in range(MAX_HIGHSCORES-len(self.table))] |