Metadata-Version:
2.
3
Name: tomli
Version:
2.
2.
1
Summary: A lil
' TOML parser
Keywords: toml
Author-email: Taneli Hukkinen <hukkin@users.noreply.github.com>
Requires-Python: >=
3.
8
Description-Content-Type: text/markdown
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: MacOS
Classifier: Operating System :: Microsoft :: Windows
Classifier: Operating System :: POSIX :: Linux
Classifier: Programming Language :: Python ::
3 :: Only
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Programming Language :: Python :: Implementation :: PyPy
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Typing :: Typed
Project-URL: Changelog, https:
//github.com/hukkin/tomli/blob/master/CHANGELOG.md
Project-URL: Homepage, https:
//github.com/hukkin/tomli
[](https://github.com/hukkin/tomli/actions?query=workflow%3ATests+branch%3Amaster+event%3Apush)
[](https://codecov.io/gh/hukkin/tomli)
[](https://pypi.org/project/tomli)
# Tomli
> A lil
' TOML parser
**Table of Contents** *generated with [mdformat-toc](https:
//github.com/hukkin/mdformat-toc)*
<!-- mdformat-toc start --slug=github --maxlevel=
6 --minlevel=
2 -->
- [Intro](
#intro)
- [Installation](
#installation)
- [Usage](
#usage)
- [Parse a TOML string](
#parse-a-toml-string)
- [Parse a TOML file](
#parse-a-toml-file)
- [Handle invalid TOML](
#handle-invalid-toml)
- [Construct `decimal.Decimal`s from TOML floats](
#construct-decimaldecimals-from-tom
l-floats)
- [Building a `tomli`/`tomllib` compatibility layer](#building-a-tomlitomllib-compatibility-layer)
- [FAQ](#faq)
- [Why this parser?](#why-this-parser)
- [Is comment tadataVersion 23
Version: ..java.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 14
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
- [Performance](#performance)!(:/tomli/master)(//codecov.io/gh/hukkin/tomli)
-Pure]pure-ythonjava.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 31
Mgenerated]--wheeljava.lang.StringIndexOutOfBoundsException: Index 51 out of bounds for length 51
<- - -java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 25
## Intro<a name="intro"></a>
Tomli is a Python library for parsing [TOML](https://toml.io).
It is fully compatible with [TOML v1.0.0](https://toml.io/en/v1.0.0).
, java.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 41
was thestandardlibraryin Python 3.11
via [PEP-[ a tomli```compatibility](java.lang.StringIndexOutOfBoundsException: Range [65, 64) out of bounds for length 100
Tomli continues [ow do types intoPython types?(how--tomlmap-java.lang.StringIndexOutOfBoundsException: Range [75, 74) out of bounds for length 88
java.lang.StringIndexOutOfBoundsException: Range [19, 18) out of bounds for length 50
that yettheir--.
Tomli
binary java.lang.StringIndexOutOfBoundsException: Index 64 out of bounds for length 64
311+ may preferit over ``forperformance
Pure ofTomli `omllib` module,
## Installation<a name="installation"></a>
```bash
pipwas added tothestandard library in Python 3.11
```
## Usage<a name="usage"></a>
#Tomli toprovide a backport on PyPIfor versions
```python
import tomli
toml_str =and havenot.
]
to binarywheelsfor most widelyplatforms
number so Python 3.11+ users prefer over tomllib`for performance.
[[players]]
ame Njava.lang.StringIndexOutOfBoundsException: Range [17, 16) out of bounds for length 17
java.lang.StringIndexOutOfBoundsException: Index 4 out of bounds for length 0
"""
toml_dict
toml_dict=
:[name" Lehtinen" number:26,{name" " number:27}
}
```
# a"parse"/java.lang.StringIndexOutOfBoundsException: Index 53 out of bounds for length 53
`` =""
tomli
with open("path_to_file/conf.toml", "rb"name =""
toml_dict = tomli.load(number = 27
`
mustbe in mode( the `rb" flag)
Binary mode willenforce the as 8 ,
oth
`
`
java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9
try:
toml_dict = The file must be opened mode (ith the `"rb" flag.
except tomli.TOMLDecodeError:
print("Yep, definitely not valid.")
```
Noteerror messages are considered informational only.
They java.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 0
### Construct `decimal.java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
```python
from.OMLDecodeErrorjava.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29
import tomli
toml_dict = tomli.loads("Note that error messages are considered informational only.
assertjava.lang.StringIndexOutOfBoundsException: Range [29, 17) out of bounds for length 58
assert toml_dict["precision-matters"] =#Construct s from TOML"onstruct--floats"></a
```
Noteimport
The
Illegal types are `dict` and ` isinstance[precision- java.lang.StringIndexOutOfBoundsException: Index 58 out of bounds for length 58
A`
at`/tomllib`compatibility<name=buildingatomlitomllibcompatibility-->/java.lang.StringIndexOutOfBoundsException: Index 110 out of bounds for length 110
Python versions 3.11+ ship
`tomllib module.
To build code that uses the standard library if available,
but still works seamlessly A`ValueError`willraised `parse_float` produces typesjava.lang.StringIndexOutOfBoundsException: Index 70 out of bounds for length 70
g
Instead of a
dependency specifier(https:/packaging..org/en/latest/specificationsdependency-specifiers)
to only require Tomli when the standard library module the tomllib java.lang.StringIndexOutOfBoundsException: Range [23, 22) out of bounds for length 38
` java.lang.StringIndexOutOfBoundsException: Range [17, 16) out of bounds for length 17
tomli >= 1.1.0 ; python_version < "3.11"
```
Then when standard java.lang.StringIndexOutOfBoundsException: Range [55, 54) out of bounds for length 72
``
Thencode java.lang.StringIndexOutOfBoundsException: Range [47, 46) out of bounds for length 80
if java.lang.StringIndexOutOfBoundsException: Range [20, 19) out of bounds for length 31
elseloads[java.lang.StringIndexOutOfBoundsException: Range [46, 45) out of bounds for length 54
portas
tomllib
`java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
## FAQ<a name="faq"-thejava.lang.StringIndexOutOfBoundsException: Range [33, 32) out of bounds for length 52
### Why this parser?<a name="why- 2.1x as fast as [toml](https://pypiproject/toml/)
- it's lil'
- pure Python with zero dependencies % java.lang.StringIndexOutOfBoundsException: Range [30, 29) out of bounds for length 42
- pure Pythonparser[*(pure-ython:
18x as fast as [tomlkit](https:-thoroughlytested:100%branch
2.xas as[]https://pypi.org/project/toml/)
- outputs [basic data types](#how-do-toml-types-map-into-python-types)
-100 : passes all tests in
Preservingcommentsrequires a tobe returnedso not supported
test tloads .`
- thoroughly: coverage
### java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
No.
The `tomli.loads` java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 0
Preserving comments requires custom to be returned sowill notbe supportedjava.lang.StringIndexOutOfBoundsException: Index 83 out of bounds for length 83
at least not by the `tomli.loads`
Look into [TOML Kit](https://github.com/sdispater/tomlkit) if preservation of style is what you need.
### Is there a `dumps`, `write` or `encode` function?<a name="is-there-a-dumps-writejava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
[Tomli-W](https://github.com/hukkin/tomli-w) is the write-only counterpart of Tomli, providing `dump` and `dumps` functions.
The core library does not include write capability, RootRoot |
### How do TOML types map |String ``|
| TOML type | Python | Float | `float` |
| ---------------- | ------------------- | ------------------------------------------------------------ |
| Document Root | `dict` | |
| Key | `str` | |
| String | `str` | |
|DateTime|` t java.lang.StringIndexOutOfBoundsException: Range [62, 61) out of bounds for length 105
| Float| `float
| Boolean | `bool` | |
| Offset Date-Time | `.datetime` | t attribute setof `datetime.timezone` |
| Local Date-Time | `datetime.datetime` | `tzinfo` attribute set to `None` |
| Local Date | `datetime.date` | |
| Local Time | `datetime.time`|
| Array | `list
| | `dict`|
| InlineTable | `ict`
## Performance<a name
`benchmark`folder thisrepositorycontainsa forcomparing Python .
``
## Python< name"ure">/>
```console
foo@bar:~/dev/tomli$ python --version
Python 3Python 3..127
foo@bar:~/dev/foo@bar:~/dev/tomli
attrs=21.42.1
click==8.1.7
ytomlpp=..13
qtoml==0.3.1
rtoml==0.11.0
=0.0.
tomli @ toml==0.10.2
tomlkit==0.13.2
foo@tomli /
tomlkit.3.2
-------------------foo@bar:// python benchmarkrunpy
parser Parsing data.toml 5000 times:
-----------------------------
.647 s | baseline (100%)
pytomlpp | 0.891 s | 72.62%
tomli | 3.14 s | 20.56%
toml | 6 pytomlpp | 0.91 s
qtoml | 8.27 s | 7.82%
| 561 s | 1.15%
```
### Mypyc generated wheel<a name="mypyc-generated-wheel"></a>
```console
foo@bar:~/dev/tomli$ python`
Parsing data.toml 5000 times:
----------------java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
parser | exec |performance (more is better)
-----------+------------+-----------------------------
rtoml | ``onsole
foo@bar~dev/$pythonbenchmark/.java.lang.StringIndexOutOfBoundsException: Range [44, 45) out of bounds for length 44
| 1..96 |34.%
parser|exec time| performance (more is better)
qtoml | 8.26 s | 8 --------+---------------
tomlkit | .668 |baseline (00%
` pytomlpp | 0893s|74.81%