summaryrefslogtreecommitdiffstats
path: root/gamechestcli/gamechest/gamedb.py
diff options
context:
space:
mode:
Diffstat (limited to 'gamechestcli/gamechest/gamedb.py')
-rw-r--r--gamechestcli/gamechest/gamedb.py19
1 files changed, 10 insertions, 9 deletions
diff --git a/gamechestcli/gamechest/gamedb.py b/gamechestcli/gamechest/gamedb.py
index 1e3967c..d932438 100644
--- a/gamechestcli/gamechest/gamedb.py
+++ b/gamechestcli/gamechest/gamedb.py
@@ -3,14 +3,15 @@ import yaml
from . import paths
-def load_games_database():
- database_path = paths.get_games_database_path()
- with open(database_path, 'rb') as fdin:
- return yaml.safe_load(fdin)
+class GameDB:
+ def __init__(self):
+ database_path = paths.get_games_database_path()
+ with open(database_path, 'rb') as fdin:
+ self.db = yaml.safe_load(fdin)
-def get_game_info(game_id):
- db = load_games_database()
- return next(game_info
- for game_info in db['games']
- if game_info['id'] == game_id)
+
+ def get_game_info(self, game_id):
+ return next(game_info
+ for game_info in self.db['games']
+ if game_info['id'] == game_id)