Ravenports generated: 05 Aug 2023 23:27
[ravenports.git] / bucket_1D / python-tomli
1 # Buildsheet autogenerated by ravenadm tool -- Do not edit.
2
3 NAMEBASE=               python-tomli
4 VERSION=                2.0.1
5 KEYWORDS=               python
6 VARIANTS=               py310 v11
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]
11
12 DOWNLOAD_GROUPS=        main
13 SITES[main]=            PYPIWHL/97/75/10a9ebee3fd790d20926a90a2547f0bf78f371b2f13aa822c759680ca7b9
14 DISTFILE[1]=            tomli-2.0.1-py3-none-any.whl:main
15 DF_INDEX=               1
16 SPKGS[py310]=           single
17 SPKGS[v11]=             single
18
19 OPTIONS_AVAILABLE=      PY310 PY311
20 OPTIONS_STANDARD=       none
21 VOPTS[py310]=           PY310=ON PY311=OFF
22 VOPTS[v11]=             PY310=OFF PY311=ON
23
24 DISTNAME=               tomli-2.0.1.dist-info
25
26 GENERATED=              yes
27
28 [PY310].USES_ON=                        python:py310,wheel
29
30 [PY311].USES_ON=                        python:v11,wheel
31
32 [FILE:2270:descriptions/desc.single]
33 [Build Status]
34 [![codecov.io]](https://codecov.io/gh/hukkin/tomli)
35 [PyPI version]
36
37 # Tomli
38
39 > A lil' TOML parser
40
41 **Table of Contents**  *generated with [mdformat-toc]*
42
43 <!-- mdformat-toc start --slug=github --maxlevel=6 --minlevel=2 -->
44
45 - [Intro]
46 - [Installation]
47 - [Usage]
48   - [Parse a TOML string]
49   - [Parse a TOML file]
50   - [Handle invalid TOML]
51   - [Construct `decimal.Decimal`s from TOML floats]
52 - [FAQ]
53   - [Why this parser?]
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?]
57 - [Performance]
58
59 <!-- mdformat-toc end -->
60
61 ## Intro</a>
62
63 Tomli is a Python library for parsing [TOML].
64 Tomli is fully compatible with [TOML v1.0.0].
65
66 ## Installation<a name="installation">
67
68 `bash
69 pip install tomli
70 `
71
72 ## Usage</a>
73
74 ### Parse a TOML string<a name="parse-a-toml-string">
75
76 ```python
77 import tomli
78
79 toml_str = """
80            gretzky = 99
81
82            [kurri]
83            jari = 17
84            """
85
86 toml_dict = tomli.loads(toml_str)
87 assert toml_dict == {"gretzky": 99, "kurri": {"jari": 17}}
88 ```
89
90 ### Parse a TOML file</a>
91
92 ```python
93 import tomli
94
95 with open("path_to_file/conf.toml", "rb") as f:
96     toml_dict = tomli.load(f)
97 ```
98
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
101 disabled,
102 both of which are required to correctly parse TOML.
103
104 ### Handle invalid TOML<a name="handle-invalid-toml">
105
106 ```python
107 import tomli
108
109 try:
110     toml_dict = tomli.loads("]] this is invalid TOML [[")
111 except tomli.TOMLDecodeError:
112     print("Yep, definitely not valid.")
113 ```
114
115 Note that error messages are considered informational only.
116 They should not be assumed to stay constant across Tomli versions.
117
118 ### Construct `decimal.Decimal`s from TOML floats</a>
119
120 ```python
121 from decimal import Decimal
122 import tomli
123
124 toml_dict = tomli.loads("precision-matters = 0.982492",
125 parse_float=Decimal)
126 assert toml_dict["precision-matters"] == Decimal("0.982492")
127 ```
128
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.
133
134
135 [FILE:107:distinfo]
136 939de3e7a6161af0c887ef91b7d41a53e7c5a1ca976325f429cb46ea9bc30ecc        12757 tomli-2.0.1-py3-none-any.whl
137