목업에만 있던 날씨 문구 계약을 제품 payload와 렌더러에 연결한다. 군산 전용 장소를 다른 사업장에 복사하지 않도록 공통 안내를 별도 JSON으로 관리한다. 날씨 변환 단위 테스트 3건, 렌더링 테스트 3건 및 TypeScript·ESLint 통과. 전체 발행 테스트는 깨끗한 renderer 재빌드 후 별도 확인.
22 lines
775 B
Python
22 lines
775 B
Python
"""날씨 안내 계약. 관측값과 분리하고, 확인되지 않은 시설·영업시간은 쓰지 않는다."""
|
|
import json
|
|
from functools import lru_cache
|
|
from pathlib import Path
|
|
|
|
|
|
@lru_cache(maxsize=1)
|
|
def _templates() -> dict:
|
|
return json.loads(Path(__file__).with_name("weather_notes.json").read_text(encoding="utf-8"))
|
|
|
|
|
|
def weather_notes() -> dict:
|
|
templates = _templates()
|
|
sky = {key: list(lines) for key, lines in templates["sky"].items()}
|
|
temperature = {key: list(lines) for key, lines in templates["temperature"].items()}
|
|
return {
|
|
"notes": {key: lines[0] for key, lines in sky.items()},
|
|
"tempNotes": {key: lines[0] for key, lines in temperature.items()},
|
|
"noteSets": sky,
|
|
"tempNoteSets": temperature,
|
|
}
|