diff options
author | Viljami Ilola <+@hix.fi> | 2024-04-21 00:32:47 +0300 |
---|---|---|
committer | Viljami Ilola <+@hix.fi> | 2024-04-21 00:32:47 +0300 |
commit | cc647b1c0f5f7f8a700103c6312916db126f8ffc (patch) | |
tree | 536503a7f7a8b71d291e207d90d30d1fa40d141c | |
parent | 03ad276bf93e160d19f693bf0a39ef095b0189b3 (diff) |
make use of pathlib
-rw-r--r-- | src/sliceitoff/hiscores/hiscores.py | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/src/sliceitoff/hiscores/hiscores.py b/src/sliceitoff/hiscores/hiscores.py index 627c3f7..bcf41a0 100644 --- a/src/sliceitoff/hiscores/hiscores.py +++ b/src/sliceitoff/hiscores/hiscores.py @@ -13,15 +13,12 @@ class HiScores: self.config_filename = filename else: if os.name == 'nt': - self.config_filename = os.path.join( - Path.home(), - "sliceitoff.cfg") + self.config_filename = (Path.home().resolve() + .joinpath('sliceitoff.cfg')) else: - self.config_filename = os.path.join( - Path.home(), - ".config", - "sliceitoffrc") - if not os.path.isfile(self.config_filename): + self.config_filename = (Path.home().resolve() + .joinpath('.config').joinpath('sliceitoffrc')) + if not self.config_filename.is_file(): self.table=INITIAL_HIGHSCORES[:] return with open(self.config_filename, "r", encoding="utf-8") as config_file: @@ -46,7 +43,7 @@ class HiScores: def __del__(self): """ On object deletion save current high scores to config file """ oldlines=[] - if os.path.isfile(self.config_filename): + if self.config_filename.is_file(): with (open(self.config_filename, "r", encoding="utf-8") as config_file): for line in config_file: |