Metadata-Version: 2.4
Name: steflib
Version: 0.2.2
Summary: Python implementation of STEF (Simple Token-Efficient Format)
Author: Nigel Small
License-Expression: MIT
Project-URL: Homepage, https://stef.nige.tech
Project-URL: Repository, https://github.com/technige/stef
Project-URL: Documentation, https://stef.nige.tech
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
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.9
Description-Content-Type: text/markdown
License-File: LICENSE
Dynamic: license-file

# steflib

Python implementation of [STEF](https://stef.nige.tech): the Simple 
Token-Efficient Format.

For more details on the format and a full specification, visit 
[stef.nige.tech](https://stef.nige.tech).


## Installation

```shell
pip install steflib
```


## Usage

```python-repl
>>> from steflib import stef
>>> from datetime import date
>>> print(stef({"name": "David Bowie", "born": date(1947, 1, 8), "studio_albums": 26}))
name: "David Bowie"
born: 1947-01-08
studio_albums: 26
```

For streaming output, use the `StefWriter` directly:

```python-repl
>>> from steflib import StefWriter
>>> from datetime import date
>>> writer = StefWriter()
>>> writer.print({"name": "David Bowie", "born": date(1947, 1, 8)})
>>> writer.print({"name": "Sting", "born": date(1951, 10, 2)})
```

Plain Python types are mapped to their STEF equivalents automatically. For
additional control, typed wrappers are provided - for example, to emit an
integer in hexadecimal, or to attach a comment to any value:

```python-repl
>>> from steflib import stef, Integer, Float
>>> print(stef(Integer(255, as_hex=True)))
0xFF
>>> print(stef(Float(3.14, comment="approx")))
3.14 (approx)
```
