https://github.com/beryllium-org/cptoml
A CircuitPython module for managing toml files.
https://github.com/beryllium-org/cptoml
Last synced: 9 months ago
JSON representation
A CircuitPython module for managing toml files.
- Host: GitHub
- URL: https://github.com/beryllium-org/cptoml
- Owner: beryllium-org
- License: mit
- Created: 2022-12-22T16:34:49.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2024-12-01T22:28:53.000Z (about 1 year ago)
- Last Synced: 2025-04-15T22:54:12.368Z (9 months ago)
- Language: Python
- Size: 60.5 KB
- Stars: 10
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# CPToml
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".