"""Patch (2026-10-14, Okseong P1 G3): builders receive the global GATE (gate id), so the generic centreline builder rebar_polylines.py can serve G3 (params footing_rebar) as well as G4 (params coping_rebar). Backups: backup/2026-10-14_okseong_g3/. Other builders ignore the extra global.""" from pathlib import Path APP = Path(__file__).resolve().parents[2] def patch(path, reps): s = path.read_text(encoding="utf-8") for a, b in reps: assert s.count(a) == 1, (path.name, a[:60]) s = s.replace(a, b) path.write_text(s, encoding="utf-8") patch(APP / "engine" / "pipeline.py", [( ''' steps.append({"name": f"{g}:{script}", "script": RHINO_DIR / script, "globals": glb})''', ''' steps.append({"name": f"{g}:{script}", "script": RHINO_DIR / script, "globals": dict(glb, GATE=g)})''')]) patch(APP / "engine" / "gates.py", [( ''' steps.append({"name": f"{g}:{script}", "script": RHINO_DIR / script, "globals": glb})''', ''' steps.append({"name": f"{g}:{script}", "script": RHINO_DIR / script, "globals": dict(glb, GATE=g)})''')]) patch(APP / "engine" / "rhino" / "rebar_polylines.py", [ ('''Ids: -R-- (pipe) and -RC-- (centreline). """''', '''Ids: -R-- (pipe) and -RC-- (centreline). Section by gate (2026-10-14, Okseong P1): GATE "G3" -> params footing_rebar, otherwise coping_rebar. """'''), ('''SEC = P["coping_rebar"]''', '''SEC = P["footing_rebar" if globals().get("GATE") == "G3" else "coping_rebar"]'''), ]) print("patched")