A CircuitPython module for managing toml files.
To create an .mpy package, just run make mpy
.
Basic usage guide:
# Read
from cptoml import fetch
fetch("CIRCUITPY_PYSTACK_SIZE") # To fetch something from the root table
fetch("item1", "subtable1") # To fetch item1 from subtable1
# Write
from cptoml import put
from storage import remount
remount("/", False)
put("CIRCUITPY_PYSTACK_SIZE", 7000) # To set an item in root table
put("item1", 123, "subtable1", comment="This is useless") # To set item1 in subtable1 with comment
remount("/", True)
# Delete
from cptoml import delete
from storage import remount
remount("/", False)
delete("CIRCUITPY_PYSTACK_SIZE") # To make me sad
delete("item1", "subtable1") # To delete item1 from subtable1
remount("/", True)
Empty tables are deleted automatically.
The toml file is formatted automatically on any write.
To edit a toml file other than
/settings.toml
, pass the option: toml="/path_to_your.toml"
.