# Buildsheet autogenerated by ravenadm tool -- Do not edit.
NAMEBASE= python-tomli
VERSION= 2.0.1
KEYWORDS= python
VARIANTS= v11 v12
SDESC[v11]= Lil' TOML parser (3.11)
SDESC[v12]= Lil' TOML parser (3.12)
HOMEPAGE= https://github.com/hukkin/tomli
CONTACT= Python_Automaton[python@ironwolf.systems]
DOWNLOAD_GROUPS= main
SITES[main]= PYPIWHL/97/75/10a9ebee3fd790d20926a90a2547f0bf78f371b2f13aa822c759680ca7b9
DISTFILE[1]= tomli-2.0.1-py3-none-any.whl:main
DF_INDEX= 1
SPKGS[v11]= single
SPKGS[v12]= single
OPTIONS_AVAILABLE= PY311 PY312
OPTIONS_STANDARD= none
VOPTS[v11]= PY311=ON PY312=OFF
VOPTS[v12]= PY311=OFF PY312=ON
DISTNAME= tomli-2.0.1.dist-info
GENERATED= yes
[PY311].USES_ON= python:v11,wheel
[PY312].USES_ON= python:v12,wheel
[FILE:2270:descriptions/desc.single]
[Build Status]
[![codecov.io]](https://codecov.io/gh/hukkin/tomli)
[PyPI version]
# Tomli
> A lil' TOML parser
**Table of Contents** *generated with [mdformat-toc]*
- [Intro]
- [Installation]
- [Usage]
- [Parse a TOML string]
- [Parse a TOML file]
- [Handle invalid TOML]
- [Construct `decimal.Decimal`s from TOML floats]
- [FAQ]
- [Why this parser?]
- [Is comment preserving round-trip parsing supported?]
- [Is there a `dumps`, `write` or `encode` function?]
- [How do TOML types map into Python types?]
- [Performance]
## Intro
Tomli is a Python library for parsing [TOML].
Tomli is fully compatible with [TOML v1.0.0].
## Installation
`bash
pip install tomli
`
## Usage
### Parse a TOML string
```python
import tomli
toml_str = """
gretzky = 99
[kurri]
jari = 17
"""
toml_dict = tomli.loads(toml_str)
assert toml_dict == {"gretzky": 99, "kurri": {"jari": 17}}
```
### Parse a TOML file
```python
import tomli
with open("path_to_file/conf.toml", "rb") as f:
toml_dict = tomli.load(f)
```
The file must be opened in binary mode (with the `"rb"` flag).
Binary mode will enforce decoding the file as UTF-8 with universal newlines
disabled,
both of which are required to correctly parse TOML.
### Handle invalid TOML
```python
import tomli
try:
toml_dict = tomli.loads("]] this is invalid TOML [[")
except tomli.TOMLDecodeError:
print("Yep, definitely not valid.")
```
Note that error messages are considered informational only.
They should not be assumed to stay constant across Tomli versions.
### Construct `decimal.Decimal`s from TOML floats
```python
from decimal import Decimal
import tomli
toml_dict = tomli.loads("precision-matters = 0.982492",
parse_float=Decimal)
assert toml_dict["precision-matters"] == Decimal("0.982492")
```
Note that `decimal.Decimal` can be replaced with another callable that
converts a TOML float from string to a Python type.
The `decimal.Decimal` is, however, a practical choice for use cases where
float inaccuracies can not be tolerated.
[FILE:107:distinfo]
939de3e7a6161af0c887ef91b7d41a53e7c5a1ca976325f429cb46ea9bc30ecc 12757 tomli-2.0.1-py3-none-any.whl