python-tomli
Port variant v13
Summary Lil' TOML parser (3.13)
BROKEN
Package version 2.0.2
Homepage https://github.com/hukkin/tomli
Keywords python
Maintainer Python Automaton
License Not yet specified
Other variants v12
Ravenports Buildsheet | History
Ravensource Port Directory | History
Last modified 11 NOV 2024, 23:28:05 UTC
Port created 19 JUL 2021, 04:13:17 UTC
Subpackage Descriptions
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] ## 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. ## 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: toml_dict = tomli.loads("]] this is invalid TOML [[") except tomli.TOMLDecodeError: print("Yep, definitely not valid.") ``` Note that error messages are considered informational only. They should not be assumed to stay constant across Tomli versions. ### Construct `decimal.Decimal`s from TOML floats
Configuration Switches (platform-specific settings discarded)
PY312 OFF Build using Python 3.12 PY313 ON Build using Python 3.13
Package Dependencies by Type
Build (only) python313:dev:std
python-pip:single:v13
autoselect-python:single:std
Build and Runtime python313:primary:std
Download groups
main mirror://PYPIWHL/cf/db/ce8eda256fa131af12e0a76d481711abe4681b6923c27efb9a255c9e4594
Distribution File Information
2ebe24485c53d303f690b0ec092806a085f07af5a5aa1464f3931eec36caaa38 13237 tomli-2.0.2-py3-none-any.whl
Ports that require python-tomli:v13
python-yapf:v13 Formatter for Python code (3.13)