1 # Buildsheet autogenerated by ravenadm tool -- Do not edit.
7 SDESC[py310]= Lil' TOML parser (3.10)
8 SDESC[v11]= Lil' TOML parser (3.11)
9 HOMEPAGE= https://github.com/hukkin/tomli
10 CONTACT= Python_Automaton[python@ironwolf.systems]
13 SITES[main]= PYPIWHL/97/75/10a9ebee3fd790d20926a90a2547f0bf78f371b2f13aa822c759680ca7b9
14 DISTFILE[1]= tomli-2.0.1-py3-none-any.whl:main
19 OPTIONS_AVAILABLE= PY310 PY311
20 OPTIONS_STANDARD= none
21 VOPTS[py310]= PY310=ON PY311=OFF
22 VOPTS[v11]= PY310=OFF PY311=ON
24 DISTNAME= tomli-2.0.1.dist-info
28 [PY310].USES_ON= python:py310,wheel
30 [PY311].USES_ON= python:v11,wheel
32 [FILE:2270:descriptions/desc.single]
34 [![codecov.io]](https://codecov.io/gh/hukkin/tomli)
41 **Table of Contents** *generated with [mdformat-toc]*
43 <!-- mdformat-toc start --slug=github --maxlevel=6 --minlevel=2 -->
48 - [Parse a TOML string]
50 - [Handle invalid TOML]
51 - [Construct `decimal.Decimal`s from TOML floats]
54 - [Is comment preserving round-trip parsing supported?]
55 - [Is there a `dumps`, `write` or `encode` function?]
56 - [How do TOML types map into Python types?]
59 <!-- mdformat-toc end -->
63 Tomli is a Python library for parsing [TOML].
64 Tomli is fully compatible with [TOML v1.0.0].
66 ## Installation<a name="installation">
74 ### Parse a TOML string<a name="parse-a-toml-string">
86 toml_dict = tomli.loads(toml_str)
87 assert toml_dict == {"gretzky": 99, "kurri": {"jari": 17}}
90 ### Parse a TOML file</a>
95 with open("path_to_file/conf.toml", "rb") as f:
96 toml_dict = tomli.load(f)
99 The file must be opened in binary mode (with the `"rb"` flag).
100 Binary mode will enforce decoding the file as UTF-8 with universal newlines
102 both of which are required to correctly parse TOML.
104 ### Handle invalid TOML<a name="handle-invalid-toml">
110 toml_dict = tomli.loads("]] this is invalid TOML [[")
111 except tomli.TOMLDecodeError:
112 print("Yep, definitely not valid.")
115 Note that error messages are considered informational only.
116 They should not be assumed to stay constant across Tomli versions.
118 ### Construct `decimal.Decimal`s from TOML floats</a>
121 from decimal import Decimal
124 toml_dict = tomli.loads("precision-matters = 0.982492",
126 assert toml_dict["precision-matters"] == Decimal("0.982492")
129 Note that `decimal.Decimal` can be replaced with another callable that
130 converts a TOML float from string to a Python type.
131 The `decimal.Decimal` is, however, a practical choice for use cases where
132 float inaccuracies can not be tolerated.
136 939de3e7a6161af0c887ef91b7d41a53e7c5a1ca976325f429cb46ea9bc30ecc 12757 tomli-2.0.1-py3-none-any.whl