Tool to generate Python dataclasses that model and load toml files (or other can-representated-as-a-dict files).
Primarily aimed at configuration type files.
Install with:
pip install tomfoolery
Given the following file (venue.toml
):
Running the command
tomfoolery venue.toml
will produce this file (venue.py
):
which can then be used:
>from venue import Venue >venue = Venue.load() >print(venue.address.city) 'Chicago' >venue.calendar.start_month = "March" >venue.dump()
- Only works with
.toml
and.json
files. - All keys must be valid Python variable names.