Files
aoe2-flashcard-creator/flashcards/config.py
Nate Bowman cd93d61129 Use relative path to config file
I don't feel like changing it every time I move the project.  Note that
this will not work unless settings.yaml exists in your working directory
when you run the Python command.
2026-10-14 19:09:29 -04:00

19 lines
577 B
Python

from pathlib import Path
from types import SimpleNamespace
import yaml
config_file = 'settings.yaml'
with open(config_file, 'r') as f:
c = yaml.safe_load(f)
root_path = Path(c['storage']['root'])
config = SimpleNamespace()
config.data_file = root_path / c['storage']['data'] / c['data_file']
config.name_data_file = root_path / c['storage']['data'] / c['name_data_file']
config.string_data_file = root_path / c['storage']['data'] / c['string_data_file']
config.namelists_dir = root_path / c['storage']['namelists']
config.decks_dir = root_path / c['storage']['decks']