Skip to main content

A tiny TOON-lite encoder/decoder for Python.

Project description


📦 toonlite — Simple TOON Lite Encoder/Decoder for Python

toonlite logo

PyPI version Python versions Build status License

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() and dumps()

  • 📄 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
  • 🔧 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, false
  • null
  • 123, 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

toonlite-0.1.0.tar.gz (5.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

toonlite-0.1.0-py3-none-any.whl (5.3 kB view details)

Uploaded Python 3

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

Hashes for toonlite-0.1.0.tar.gz
Algorithm Hash digest
SHA256 0fbd2a0979df05b9463b937a313d57b7a12b839f30fda5561883744e6e43f6ff
MD5 819a4045b04d6532ca2501eb7d2803f2
BLAKE2b-256 62ffe14b4e2f81b16c7cf328d7221b6d49ef8664fb17de610afedcac1fd89428

See more details on using hashes here.

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

Hashes for toonlite-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4b75cb1b458d6f6557e6ac501039f60593e14b102cd9dd0a1b8de6079125dcc4
MD5 fde6085782474b0f3bcd36a5551bf606
BLAKE2b-256 64a1f03f7f963deb157818b4c7c6b69076a3140a70c703fedce528a2e013a791

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page