p="post_draft.py"
src=open(p).read()
old='def _editorial_copy(signal: dict, platform: str) -> tuple[str, str, str]:\n """Return (title, hook, body) as original Mallorca AirServices copy.\n\n The copy follows the standing editorial rule: use the external signal only as\n a prompt for our own professional angle, never as source/competitor ad copy.\n """\n cat = _category(signal)'
new='_FOCUS_TO_CATEGORY = {\n "feuchte_schimmel": "feuchte",\n "luftqualitaet_co2": "luftqualitaet",\n "lueftung": "lueftung",\n "gebaeude_diagnose": "bauphysik",\n "energie_komfort": "bauphysik",\n "sonstiges": None,\n}\n\n\ndef _effective_category(signal: dict, topic_focus: str | None = None) -> str:\n """Kategorie mit verbindlicher Fokus-Überschreibung (MAS-IG-CO2-FOCUS)."""\n if topic_focus and topic_focus != "auto":\n override = _FOCUS_TO_CATEGORY.get(topic_focus)\n if override:\n return override\n return _category(signal)\n\n\ndef _editorial_copy(signal: dict, platform: str, topic_focus: str | None = None) -> tuple[str, str, str]:\n """Return (title, hook, body) as original Mallorca AirServices copy.\n\n The copy follows the standing editorial rule: use the external signal only as\n a prompt for our own professional angle, never as source/competitor ad copy.\n ``topic_focus`` überschreibt die Signal-Kategorie hart, wenn er manuell gesetzt ist.\n """\n cat = _effective_category(signal, topic_focus)'
assert old in src, "editorial marker not found"
src2=src.replace(old,new,1)
# thread topic_focus in build_post_draft
old2=' candidate = transformed or dict(signal)\n p = (platform or "facebook").lower()\n title, hook_text, body_text = _editorial_copy(candidate, p)'
new2=' candidate = transformed or dict(signal)\n p = (platform or "facebook").lower()\n title, hook_text, body_text = _editorial_copy(candidate, p, topic_focus)'
assert old2 in src2, "build marker not found"
src2=src2.replace(old2,new2,1)
# extend signature of build_post_draft with topic_focus keyword
old3='def build_post_draft(signal, platform, transform_signal, render_text):'
new3='def build_post_draft(signal, platform, transform_signal, render_text, topic_focus=None):'
assert old3 in src2, "sig marker not found"
src2=src2.replace(old3,new3,1)
open(p,"w").write(src2)
print("post_draft.py patched OK", len(src2))