Russian narration for the Enshrouded notes: mod 0.4.0, installer, generation pipeline
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
"""Settings from config.toml (or the file named by ENSVOICE_CONFIG) and the work-directory layout."""
|
||||
import os
|
||||
import pathlib
|
||||
import tomllib
|
||||
|
||||
ROOT = pathlib.Path(__file__).resolve().parent.parent
|
||||
|
||||
|
||||
class Config:
|
||||
def __init__(self, path=None):
|
||||
path = pathlib.Path(path or os.environ.get("ENSVOICE_CONFIG") or ROOT / "config.toml")
|
||||
if not path.exists():
|
||||
raise SystemExit(f"no config: {path} (copy config.example.toml to config.toml and edit it)")
|
||||
self.raw = tomllib.loads(path.read_text(encoding="utf-8"))
|
||||
p = self.raw["paths"]
|
||||
self.game = pathlib.Path(p["game"])
|
||||
self.work = pathlib.Path(p["work"])
|
||||
self.tools = pathlib.Path(p.get("tools", ROOT / "tools"))
|
||||
self.work.mkdir(parents=True, exist_ok=True)
|
||||
# ENSVOICE_NOTES=n016,n238 limits segments (and so everything after it) to these notes
|
||||
self.only = {x.strip() for x in os.environ.get("ENSVOICE_NOTES", "").split(",") if x.strip()}
|
||||
|
||||
def __getitem__(self, key):
|
||||
return self.raw[key]
|
||||
|
||||
def get(self, section, key, default=None):
|
||||
return self.raw.get(section, {}).get(key, default)
|
||||
|
||||
# work-directory layout (everything derived from the game stays here, never in the repo)
|
||||
def w(self, *parts) -> pathlib.Path:
|
||||
p = self.work.joinpath(*parts)
|
||||
p.parent.mkdir(parents=True, exist_ok=True)
|
||||
return p
|
||||
|
||||
|
||||
def load(path=None) -> Config:
|
||||
return Config(path)
|
||||
Reference in New Issue
Block a user