knobe 0.2.0

KNOBE Protocol v1 verifier and sealer: a Rust sibling of lens.py and knobe-core.js
Documentation
"""Writes src/pyprintable.rs: the code points CPython's str.isprintable()
rejects, which repr() escapes. Run with the Python the parity tests use
(CPython 3.13, Unicode 15.1):

  python3 tests/support/gen_pyprintable.py > src/pyprintable.rs
"""
import sys, unicodedata

ranges, start = [], None
for cp in range(0x110000):
    if not chr(cp).isprintable():
        start = cp if start is None else start
    elif start is not None:
        ranges.append((start, cp - 1))
        start = None
if start is not None:
    ranges.append((start, 0x10FFFF))

v = sys.version_info
print(f"""//! Generated by tests/support/gen_pyprintable.py from CPython {v.major}.{v.minor}
//! (Unicode {unicodedata.unidata_version}); do not edit. The code points `str.isprintable()`
//! rejects, which `repr()` escapes: controls, format characters, separators,
//! spaces other than U+0020, surrogates, private use and unassigned.

/// Inclusive, sorted, disjoint ranges.
#[rustfmt::skip]
pub(crate) const NOT_PRINTABLE: &[(u32, u32)] = &[""")
for i in range(0, len(ranges), 6):
    print("    " + " ".join(f"(0x{a:X}, 0x{b:X})," for a, b in ranges[i:i + 6]))
print("];")