summaryrefslogtreecommitdiffstats
path: root/gamechestcli/gamechest/gamedb.py
blob: d932438383d189b212d4894f7a1e4fce8064efb0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import yaml

from . import paths


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(self, game_id):
        return next(game_info
                    for game_info in self.db['games']
                    if game_info['id'] == game_id)