Skip to content

wholeboard.sexpr

A small S-expression reader and writer for KiCad files.

Atoms are kept as Sym (bare words) or str (quoted strings) so a file can be written back with the same quoting. Numbers stay as Sym text so they round-trip exactly; use num() to read one.

Sym

Bases: str

A bare (unquoted) atom such as a keyword or a number.

parse(text)

Parse the first S-expression in text.

dumps(node, indent=0)

Write a node in KiCad's style: one list per line when it holds lists.

fmt(x)

Format a number the way KiCad does: no trailing zeros, at most 6 decimals.

S(*items)

Build a list node, turning bare Python numbers into Sym atoms.