utils.py 660 B

1234567891011121314151617181920212223
  1. from pathlib import Path
  2. from typing import Iterable
  3. import yaml
  4. PROJECT_ROOT_PATH = Path(__file__).parent.parent.resolve()
  5. def originals() -> Iterable[dict]:
  6. for p in (PROJECT_ROOT_PATH / "originals").iterdir():
  7. if p.is_file() and p.suffix == ".yaml":
  8. originals = yaml.safe_load(open(p, encoding="utf-8"))
  9. for original in originals:
  10. yield original
  11. def games() -> Iterable[dict]:
  12. for p in (PROJECT_ROOT_PATH / "games").iterdir():
  13. if p.is_file() and p.suffix == ".yaml":
  14. games = yaml.safe_load(open(p, encoding="utf-8"))
  15. for game in games:
  16. yield game