STAR
Cal STAR — firmware, DAQ server, and engine design
Loading...
Searching...
No Matches
check_toml_no_underscore_ints Namespace Reference

Functions

str strip_strings_and_comment (str line)
list[tuple[int, str]] scan_file (str path)
int main ()

Variables

 UNDERSCORE_BETWEEN_DIGITS = re.compile(r"[0-9]_[0-9]")

Detailed Description

Fail if any config TOML uses `_` digit-separators in numbers (e.g. `port = 5_006`).

Those are valid TOML, but the minimal C++ config parsers in the DAQ services use
std::stoul/stoi/stod, which stop at the underscore — so `5_006` parses as `5`, a
privileged port, and daq_bridge crash-loops on bind (EACCES). @iarna/toml's
stringify emits these separators for every integer >= 1000, so a GUI "Save Config"
would reintroduce them; the writer now strips them (routes/config.ts), and this
check guards the committed files against any other source (hand edits, other tools).

Scans daq-server/config/*.toml. Quote- and comment-aware so a string value like
"weird_1_2_name" is not flagged. Exit 1 (with file:line) on any violation.

Run:  python3 test/check_toml_no_underscore_ints.py   (from daq-server/ or repo root)

Function Documentation

◆ main()

int check_toml_no_underscore_ints.main ( )

Definition at line 59 of file check_toml_no_underscore_ints.py.

References main(), and scan_file().

Referenced by main().

◆ scan_file()

list[tuple[int, str]] check_toml_no_underscore_ints.scan_file ( str path)

Definition at line 49 of file check_toml_no_underscore_ints.py.

References strip_strings_and_comment().

Referenced by main().

◆ strip_strings_and_comment()

str check_toml_no_underscore_ints.strip_strings_and_comment ( str line)
Blank out quoted spans (basic \" and literal ') and any trailing comment,
so only the structural/numeric part of the line remains for scanning.

Definition at line 28 of file check_toml_no_underscore_ints.py.

Referenced by scan_file().

Variable Documentation

◆ UNDERSCORE_BETWEEN_DIGITS

check_toml_no_underscore_ints.UNDERSCORE_BETWEEN_DIGITS = re.compile(r"[0-9]_[0-9]")

Definition at line 25 of file check_toml_no_underscore_ints.py.