# Buildsheet autogenerated by ravenadm tool -- Do not edit. NAMEBASE= python-tomli VERSION= 2.2.1 KEYWORDS= python VARIANTS= v12 v13 SDESC[v12]= Lil' TOML parser (3.12) SDESC[v13]= Lil' TOML parser (3.13) HOMEPAGE= https://github.com/hukkin/tomli CONTACT= Python_Automaton[python@ironwolf.systems] DOWNLOAD_GROUPS= main SITES[main]= PYPIWHL/6e/c2/61d3e0f47e2b74ef40a68b9e6ad5984f6241a942f7cd3bbfbdbd03861ea9 DISTFILE[1]= tomli-2.2.1-py3-none-any.whl:main DIST_SUBDIR= python-src DF_INDEX= 1 SPKGS[v12]= single SPKGS[v13]= single OPTIONS_AVAILABLE= PY312 PY313 OPTIONS_STANDARD= none VOPTS[v12]= PY312=ON PY313=OFF VOPTS[v13]= PY312=OFF PY313=ON DISTNAME= tomli-2.2.1.dist-info GENERATED= yes [PY312].USES_ON= python:v12,wheel [PY313].USES_ON= python:v13,wheel [FILE:2206: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] - [Building a `tomli`/`tomllib` compatibility layer] - [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] - [Pure Python] - [Mypyc generated wheel] ## Intro Tomli is a Python library for parsing [TOML]. It is fully compatible with [TOML v1.0.0]. A version of Tomli, the `tomllib` module, was added to the standard library in Python 3.11 via [PEP 680]. Tomli continues to provide a backport on PyPI for Python versions where the standard library module is not available and that have not yet reached their end-of-life. Tomli uses [mypyc] to generate binary wheels for most of the widely used platforms, so Python 3.11+ users may prefer it over `tomllib` for improved performance. Pure Python wheels are available on any platform and should perform the same as `tomllib`. ## Installation `bash pip install tomli ` ## Usage ### Parse a TOML string ```python import tomli toml_str = """ [[players]] name = "Lehtinen" number = 26 [[players]] name = "Numminen" number = 27 """ toml_dict = tomli.loads(toml_str) assert toml_dict == { "players": [{"name": "Lehtinen", "number": 26}, {"name": "Numminen", "number": 27}] } ``` ### 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: [FILE:118:distinfo] cb55c73c5f4408779d0cf3eef9f762b9c9f147a77de7b258bef0a5628adc85cc 14257 python-src/tomli-2.2.1-py3-none-any.whl