A tiny TOON-lite encoder/decoder for Python.
Project description
📦 toonlite — Simple TOON Lite Encoder/Decoder for Python
toonlite is a lightweight, dependency-free Python library for encoding and decoding TOON Lite, a simple, human-friendly structured text format similar to JSON/YAML — but much easier to read and write.
It is the Python counterpart to your TOON Lite PHP library.
✨ Features
-
🚀 Simple API:
loads()anddumps() -
📄 Clean, indentation-based structure (like YAML but simpler)
-
🧱 Supports:
- Key–value pairs (
key: value) - Nested objects via indentation
- Lists using
key: []+- item - Scalars: integers, floats, booleans, null, and strings
- Key–value pairs (
-
🔧 Zero dependencies
-
🧪 Fully tested
-
📦 Packaged and ready for PyPI
📦 Installation
Once published on PyPI:
pip install toonlite
If installing from TestPyPI:
pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple toonlite
🔧 Usage Example
from toonlite import loads, dumps
text = """
name: Manoj
age: 26
address:
city: Bengaluru
zip: 560001
skills: []
- Python
- PHP
active: true
"""
# Decode TOON Lite → Python dict
data = loads(text)
print(data)
# {
# 'name': 'Manoj',
# 'age': 26,
# 'address': {'city': 'Bengaluru', 'zip': 560001},
# 'skills': ['Python', 'PHP'],
# 'active': True
# }
# Encode Python dict → TOON Lite
encoded = dumps(data)
print(encoded)
"""
name: Manoj
age: 26
address:
city: Bengaluru
zip: 560001
skills: []
- Python
- PHP
active: true
"""
🧪 Running Tests
Install dependencies:
pip install -e .
pip install pytest
Run the test suite:
pytest
📁 Project Structure
toonlite/
├─ src/toonlite/
│ ├─ __init__.py
│ ├─ encoder.py
│ ├─ decoder.py
│ └─ exceptions.py
├─ tests/
│ └─ test_basic.py
├─ pyproject.toml
├─ README.md
├─ LICENSE
└─ .gitignore
🧩 TOON Lite Format (Supported Subset)
1. Key–Value Pairs
name: Alice
age: 30
2. Nested Objects (Indentation)
address:
city: Bengaluru
zip: 560001
3. Lists
skills: []
- Python
- ML
4. Scalars
true,falsenull123,3.14"strings"(no quotes necessary unless needed)
🛠️ Development
Editable install:
pip install -e .
Rebuild wheel + sdist:
python -m build
📄 License
This project is licensed under the MIT License.
See the LICENSE file for details.
🤝 Contributing
Contributions are welcome! Open an issue or submit a pull request on GitHub.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file toonlite-0.1.0.tar.gz.
File metadata
- Download URL: toonlite-0.1.0.tar.gz
- Upload date:
- Size: 5.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0fbd2a0979df05b9463b937a313d57b7a12b839f30fda5561883744e6e43f6ff
|
|
| MD5 |
819a4045b04d6532ca2501eb7d2803f2
|
|
| BLAKE2b-256 |
62ffe14b4e2f81b16c7cf328d7221b6d49ef8664fb17de610afedcac1fd89428
|
File details
Details for the file toonlite-0.1.0-py3-none-any.whl.
File metadata
- Download URL: toonlite-0.1.0-py3-none-any.whl
- Upload date:
- Size: 5.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4b75cb1b458d6f6557e6ac501039f60593e14b102cd9dd0a1b8de6079125dcc4
|
|
| MD5 |
fde6085782474b0f3bcd36a5551bf606
|
|
| BLAKE2b-256 |
64a1f03f7f963deb157818b4c7c6b69076a3140a70c703fedce528a2e013a791
|