INNER CODE UNIT · Python
err
x-cmd/x-cmd · mod/codex/lib/py/use-ds.py:54
def err(msg):
print("error:", msg, file=sys.stderr)
sys.exit(1)
def deep_set(doc, path, value):
"""Set a dotted-path key in a tomlkit document, creating tables as needed."""
keys = path.split(".")
cur = doc
for k in keys[:-1]:
if k not in cur or not isinstance(cur[k], dict):
cur[k] = tomlkit.table()
cur = cur[k]
cur[keys[-1]] = value
# ── resolve config path ───────────────────────────────────────────
config_dir = os.environ.get("CODEX_HOME") or os.path.expanduser("~/.codex")