How python-poetry/tomlkit works
Project type and purpose
• This is an open-source, style-preserving TOML library for Python (a parser and writer).
• Its goal is to let client code read, manipulate, and write TOML documents while preserving formatting, comments, and ordering.
File structure
• Top-level directories/files:
• tomlkit/ ← core Python package
• tests/ ← pytest test suite (includes TOML spec tests submodule)
• docs/ ← Sphinx documentation
• pyproject.toml, tox.ini, CI workflows
• Within tomlkit/:
• api.py ← public entry points
• parser.py ← parsing logic (token → AST)
• source.py ← file/string scanning
• toml_document.py, toml_file.py ← in-memory representation & I/O
• container.py, items.py ← node containers and element types
• _utils.py, _types.py, _compat.py ← support functions and compatibility
• exceptions.py ← error definitions
• Tests exercise:
• API calls, building documents, round-trip write/read, spec compliance via toml-test.
README
• Confirms it’s a TOML parser/writer preserving styles.
• Usage via importing the public API and calling parse() or dumps() methods.