24 lines
602 B
Python
24 lines
602 B
Python
from __future__ import annotations
|
|
|
|
import json
|
|
from functools import lru_cache
|
|
from pathlib import Path
|
|
from typing import Any
|
|
|
|
|
|
PROGRAM_PATH = Path(__file__).resolve().parent.parent / "data" / "program.json"
|
|
|
|
|
|
@lru_cache(maxsize=1)
|
|
def load_program() -> dict[str, Any]:
|
|
with PROGRAM_PATH.open(encoding="utf-8") as f:
|
|
return json.load(f)
|
|
|
|
|
|
def get_week(week_number: int) -> dict[str, Any]:
|
|
program = load_program()
|
|
for week in program["weeks"]:
|
|
if week["week"] == week_number:
|
|
return week
|
|
raise ValueError(f"Неделя {week_number} не найдена")
|