footprint_writes.py file-level

at sha256:a · View file ↗ · Intel ↗

History
1 files
1 commits
0 hotspots
0 🧊 dead
0 💥 blast risk
sha256:6 fix(ISR): default require_independent_second_reviewer to require Opera… · aaronrene · Sep 2, 2026
1 """Footprint file writes with regime-specific modes (§K7.3.1 executable script)."""
2
3 from __future__ import annotations
4
5 import os
6 from pathlib import Path
7
8 from cli.atomic import WriteFailure, atomic_write_bytes
9 from cli.footprint import EXECUTABLE_FOOTPRINT_DESTINATIONS
10
11 FOOTPRINT_EXECUTABLE_MODE = 0o755
12
13
14 def write_footprint_bytes(path: Path, data: bytes, *, destination: str) -> None:
15 """Atomically write one footprint file; set mode ``0755`` for executable destinations."""
16 atomic_write_bytes(path, data)
17 if destination in EXECUTABLE_FOOTPRINT_DESTINATIONS:
18 try:
19 path.chmod(FOOTPRINT_EXECUTABLE_MODE)
20 except OSError as exc:
21 raise WriteFailure(path, exc) from exc