From e6b9b68a6539d74bec94c0a361187ed89ec5c124 Mon Sep 17 00:00:00 2001 From: Olivier Gayot Date: Thu, 23 Dec 2021 21:45:30 +0100 Subject: Move FS operation outside the initializer of GameManager Signed-off-by: Olivier Gayot --- swiftstory/game_manager.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/swiftstory/game_manager.py b/swiftstory/game_manager.py index 7551ac4..da2e5c7 100644 --- a/swiftstory/game_manager.py +++ b/swiftstory/game_manager.py @@ -21,13 +21,17 @@ class GameManager: def __init__(self) -> None: self.lang_containers: Dict[str, LangContainer] = {} - for language in next(os.walk('usr/share/swiftstory/lang'))[1]: + for language in self.list_languages(): self.lang_containers[language] = LangContainer( black_cards=Cards.get_black_cards(language), white_cards=Cards.get_white_cards(language), games={} ) + def list_languages(self) -> List[str]: + """ List available languages based on FS. """ + return next(os.walk("usr/share/swiftstory/lang"))[1] + def join_game(self, game_name: str, lang: str) -> Game: container = self.lang_containers.get(lang) if container is None: -- cgit v1.2.3