summaryrefslogtreecommitdiff
path: root/swiftstory/game_manager.py
diff options
context:
space:
mode:
authorOlivier Gayot <olivier.gayot@sigexec.com>2021-12-26 17:11:37 +0100
committerOlivier Gayot <olivier.gayot@sigexec.com>2021-12-26 18:28:21 +0100
commitd592880c4bc4c581d8847d96ff73bc319ca1fac2 (patch)
treeac4996aa4d81ef55e68b209d4c541c206f1efe61 /swiftstory/game_manager.py
parent794292740c30bfea48dc23eb62fb6aa531bfdca7 (diff)
Make cards be part of the Python package data
We now load the cards using pkg_resources. This is way better in many aspects: * we can install the package using pip without having issues loading cards * we don't need to chdir to / before running swiftstoryd * we don't need to rely on data_files which is deprecated. Signed-off-by: Olivier Gayot <olivier.gayot@sigexec.com>
Diffstat (limited to 'swiftstory/game_manager.py')
-rw-r--r--swiftstory/game_manager.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/swiftstory/game_manager.py b/swiftstory/game_manager.py
index 6c2da1f..a69704c 100644
--- a/swiftstory/game_manager.py
+++ b/swiftstory/game_manager.py
@@ -3,6 +3,8 @@ import logging
import os
from typing import Dict, List
+import pkg_resources
+
from swiftstory.exception import UnsupportedLanguage
from swiftstory.game import Game
from swiftstory.cards import Cards
@@ -39,7 +41,7 @@ class GameManager:
def list_languages(self) -> List[str]:
""" List available languages based on FS. """
- return next(os.walk("usr/share/swiftstory/lang"))[1]
+ return pkg_resources.resource_listdir(__name__, "data/lang")
def find_by_name(self, game_name: str, lang: str, create=True) -> Game:
""" Find and return the game that matches the name and language