Skip to content

lablink_allocator_service.utils.ansi

ANSI escape-sequence stripping for tofu output and client VM logs.

Lives here rather than in main.py because three call sites across two blueprints need it (provisioning: tofu stdout/stderr; vm_telemetry: client log ingestion) and it holds no state.

Return text with ANSI escape sequences removed.

Source code in packages/allocator/src/lablink_allocator_service/utils/ansi.py
def strip_ansi(text: str) -> str:
    """Return *text* with ANSI escape sequences removed."""
    return ANSI_ESCAPE.sub("", text)