Skip to main content

A lil' TOML writer

Project description

Build Status codecov.io PyPI version

Tomli-W

A lil' TOML writer

Table of Contents generated with mdformat-toc

Intro

Tomli-W is a Python library for writing TOML. It is a write-only counterpart to Tomli, which is a read-only TOML parser. Tomli-W is fully compatible with TOML v1.0.0.

Installation

pip install tomli-w

Usage

Write to string

import tomli_w

doc = {"table": {"nested": {}, "val3": 3}, "val2": 2, "val1": 1}
expected_toml = """\
val2 = 2
val1 = 1

[table]
val3 = 3

[table.nested]
"""
assert tomli_w.dumps(doc) == expected_toml

Write to file

import tomli_w

doc = {"one": 1, "two": 2, "pi": 3}
with open("path_to_file/conf.toml", "w", encoding="utf-8") as f:
    tomli_w.dump(doc, f)

FAQ

Does Tomli-W sort the document?

No, but it respects sort order of the input data, so one could sort the content of the dict (recursively) before calling tomli_w.dumps.

Does Tomli-W support writing documents with comments, custom whitespace, or other stylistic choices?

No.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tomli_w-0.2.1.tar.gz (5.4 kB view details)

Uploaded Source

Built Distribution

tomli_w-0.2.1-py3-none-any.whl (4.8 kB view details)

Uploaded Python 3

File details

Details for the file tomli_w-0.2.1.tar.gz.

File metadata

  • Download URL: tomli_w-0.2.1.tar.gz
  • Upload date:
  • Size: 5.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.25.1

File hashes

Hashes for tomli_w-0.2.1.tar.gz
Algorithm Hash digest
SHA256 590d3adbd5c29e3f8bba5512edda4d90fe09c665b0464a1c3978e73686ca80bb
MD5 9b28e2dffc0b5b0d8bc3840f849b1ff0
BLAKE2b-256 1d1391a315f8468a52173068cd617905452c6ae5c6bc07968c42ac364f42fa02

See more details on using hashes here.

Provenance

File details

Details for the file tomli_w-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: tomli_w-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 4.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.25.1

File hashes

Hashes for tomli_w-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 1f3cf296661f0ebc2964fd3379fdfc1633914df926915277d9eba9b0df31aa54
MD5 fc7d7a2f99a8c0de06f1df0c854b9f7d
BLAKE2b-256 e8252a60f0ddb13db7fd6bffda02c9fdfe6a4ebc746ec0f2ee1efb5961d4d9b0

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page