Require key-value data file syntax

This commit is contained in:
hbrain 2026-05-25 18:52:36 +00:00
parent 86cb85b56d
commit 8d2d422c6c
2 changed files with 18 additions and 22 deletions

View file

@ -523,10 +523,12 @@ def parse_data_file(path: Path | None) -> MovieData:
return MovieData(captions={})
data = MovieData(captions={})
for raw in path.read_text(encoding="utf-8", errors="replace").splitlines():
for line_no, raw in enumerate(path.read_text(encoding="utf-8", errors="replace").splitlines(), start=1):
line = raw.strip()
if not line or line.startswith("#") or ":" not in line:
if not line or line.startswith("#"):
continue
if ":" not in line:
raise SystemExit(f"Invalid data file syntax in {path} line {line_no}: every entry must be key: value")
key, value = line.split(":", 1)
key = key.strip()
value = value.strip()