2023-02-24 20:13:31 +01:00
|
|
|
from typing import Dict, Any
|
2023-02-16 23:13:41 +01:00
|
|
|
from types import ModuleType
|
2023-02-24 20:13:31 +01:00
|
|
|
import logging
|
2023-02-16 23:13:41 +01:00
|
|
|
import importlib
|
|
|
|
from os import walk
|
|
|
|
|
|
|
|
class Utils:
|
|
|
|
@classmethod
|
|
|
|
def get_all_titles(cls) -> Dict[str, ModuleType]:
|
|
|
|
ret: Dict[str, Any] = {}
|
|
|
|
|
|
|
|
for root, dirs, files in walk("titles"):
|
|
|
|
for dir in dirs:
|
|
|
|
if not dir.startswith("__"):
|
|
|
|
try:
|
|
|
|
mod = importlib.import_module(f"titles.{dir}")
|
|
|
|
ret[dir] = mod
|
|
|
|
|
|
|
|
except ImportError as e:
|
2023-02-24 20:13:31 +01:00
|
|
|
logging.getLogger("core").error(f"get_all_titles: {dir} - {e}")
|
2023-02-17 07:02:21 +01:00
|
|
|
raise
|
2023-02-16 23:13:41 +01:00
|
|
|
return ret
|