Skip to main content

Module util

Module util 

Source
Expand description

Small helpers shared by core and first-party plugins, so each rule has one implementation.

Functions§

parse_cell
Parse a cell reference (B12, $B$12) into zero-based (row, col). $ may only appear directly before the column letters and before the row number.
percent_encode
Percent-encode everything except RFC 3986 unreserved characters and, if keep_slash, /.
scaled_decimal
Parse decimal text ("-12.30") into an integer scaled by 10^scale for an Arrow decimal. Negative scales are allowed ("1200" at scale -2 is 12). Digits that the scale would drop must be zero: a value that doesn’t fit the scale is an error, never silently cut.
summarize
One line, at most max characters, for quoting SQL in messages.
write_atomic
Write bytes to path so that a reader, or a crash, sees either the old file or the new one, never a part: write a temporary file (.<name>.<pid>.<random>.tmp) in the same folder, flush it to disk, rename it over path, then flush the folder (Unix; a folder that can’t be flushed, such as some network mounts, is logged at debug and ignored). For DRE’s durable state (run_results.json, the drift snapshot, the manifest, dre.lock, sessions), not report outputs.
write_atomic_mode
write_atomic, creating the file with Unix permissions mode (e.g. 0o600 for secrets).