Metadata-Version: 2.4
Name: larztoml
Version: 0.1.0
Summary: TOML read and write in pure Python (back to 3.8): tables, arrays of tables, typed values, dates, comments. Zero dependencies.
Author: larz-scripter
License: MIT
Project-URL: Homepage, https://github.com/larz-scripter/larztoml
Project-URL: Repository, https://github.com/larz-scripter/larztoml
Project-URL: Issues, https://github.com/larz-scripter/larztoml/issues
Keywords: toml,toml-parser,config,configuration,tomllib,serialization,parser,writer,zero-dependency
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Dynamic: license-file

# larztoml

**TOML read *and* write. Pure Python (back to 3.8), zero dependencies.**

The standard library gained `tomllib` in 3.11 — but it only **reads**, and only on
new Pythons. larztoml both parses and serializes TOML, on any supported Python,
with no dependency.

```python
from larztoml import loads, dumps

cfg = loads("""
title = "myapp"

[server]
host = "localhost"
port = 8080
tags = ["a", "b"]

[[user]]
name = "Ada"
""")

dumps(cfg)      # back to TOML text
```

## Why

- **It writes.** `dumps()` is the piece `tomllib` doesn't have — generate config
  files, not just read them.
- **Works everywhere.** Python 3.8+, not just 3.11+.
- **Real TOML.** `[tables]`, `[[arrays of tables]]`, nested and dotted keys,
  typed values (strings incl. literal/multiline, ints/floats with `_` and
  hex/oct/bin, `inf`/`nan`, bools, **dates and datetimes**), arrays (including
  multi-line), inline tables, and comments.
- **Zero dependencies.** No `toml`, no `tomli`/`tomli-w`.

## Install

```bash
pip install larztoml
```

## Usage

```python
from larztoml import loads, dumps

data = loads(open("pyproject.toml").read())
text = dumps({"tool": {"app": {"port": 8080, "hosts": ["a", "b"]}}})
```

Dates parse to `datetime`/`date`/`time`; numbers keep their type. Round-trips:
`loads(dumps(obj)) == obj` for the supported subset.

## Tests

```bash
python -m unittest discover -s tests -v   # 21 tests incl. dump round-trips
```

## The Larz stack

One of 30+ pure-Python, zero-dependency libraries at
[github.com/larz-scripter](https://github.com/larz-scripter) — pairs with
[larzconf](https://github.com/larz-scripter/larzconf) and
[larzyaml](https://github.com/larz-scripter/larzyaml).

## License

MIT © larz-scripter
