# Buildsheet autogenerated by ravenadm tool -- Do not edit. NAMEBASE= python-tomli VERSION= 1.2.1 KEYWORDS= python VARIANTS= py38 py39 SDESC[py38]= Lil' TOML parser (PY38) SDESC[py39]= Lil' TOML parser (PY39) HOMEPAGE= none CONTACT= Python_Automaton[python@ironwolf.systems] DOWNLOAD_GROUPS= main SITES[main]= PYPIWHL/18/47/f7dab5b63b97efa7a715e389291d46246a5999c7b4705c2d147fc879e3b5 DISTFILE[1]= tomli-1.2.1-py3-none-any.whl:main DF_INDEX= 1 SPKGS[py38]= single SPKGS[py39]= single OPTIONS_AVAILABLE= PY38 PY39 OPTIONS_STANDARD= none VOPTS[py38]= PY38=ON PY39=OFF VOPTS[py39]= PY38=OFF PY39=ON DISTNAME= tomli-1.2.1.dist-info GENERATED= yes [PY38].USES_ON= python:py38,wheel [PY39].USES_ON= python:py39,wheel [FILE:2173: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. Support for text file objects is deprecated for removal in the next major release. ### 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 while the `TOMLDecodeError` type is public API, error messages of raised instances of it are not. Error messages 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") ``` [FILE:107:distinfo] 8dd0e9524d6f386271a36b41dbf6c57d8e32fd96fd22b6584679dc569d20899f 11849 tomli-1.2.1-py3-none-any.whl