summaryrefslogtreecommitdiffstats
path: root/gamechestcli/gamechest/gameconfig.py
diff options
context:
space:
mode:
Diffstat (limited to 'gamechestcli/gamechest/gameconfig.py')
-rw-r--r--gamechestcli/gamechest/gameconfig.py10
1 files changed, 7 insertions, 3 deletions
diff --git a/gamechestcli/gamechest/gameconfig.py b/gamechestcli/gamechest/gameconfig.py
index effacd0..91f13ff 100644
--- a/gamechestcli/gamechest/gameconfig.py
+++ b/gamechestcli/gamechest/gameconfig.py
@@ -2,7 +2,7 @@ import contextlib
from pathlib import Path
import yaml
-from xdg import xdg_data_home
+from xdg import xdg_data_home, xdg_config_home
from . import consts
@@ -36,7 +36,8 @@ class GameConfig:
self.game_config_filepath = game_config_filepath
with contextlib.ExitStack() as stack:
stack.enter_context(contextlib.suppress(FileNotFoundError))
- fdin = stack.enter_context(open(game_config_filepath, 'rb'))
+ fdin = stack.enter_context(open(game_config_filepath, 'r',
+ encoding='utf8'))
self.config = yaml.safe_load(fdin)
self.config = {
**DEFAULT_CONFIG_DICT,
@@ -74,7 +75,7 @@ class GameConfig:
self.config['gamesaves_path']
)
)
- with open(self.game_config_filepath, 'wb') as fdout:
+ with open(self.game_config_filepath, 'w', encoding='utf8') as fdout:
yaml.safe_dump(dict_transformed_for_save, fdout)
def set_profile_id(self, profile_id):
@@ -93,6 +94,9 @@ class GameConfig:
games_install_path.mkdir(parents=True, exist_ok=True)
return games_install_path
+ def print_config(self):
+ print(self.config)
+
# default instance of gameconfig, same instance intended to be shared through
# all modules which needs it.