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.0.tar.gz (5.1 kB view details)

Uploaded Source

Built Distribution

tomli_w-0.2.0-py3-none-any.whl (4.9 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for tomli_w-0.2.0.tar.gz
Algorithm Hash digest
SHA256 bc752dd616dbec8f2b1cffca10bcf48e39c1f36e8b9fb59dfc9a1ca8a7f5bcc5
MD5 fe2ad3dd17d5bb8034fc5112ae9ff537
BLAKE2b-256 0e266f65a22e192e516fa1f585216401db6ba4b3f06b2b5527b5759777a7d4e9

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for tomli_w-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 96a95930d9c71bf890400a123bd9ea89ef3990b1483bcc5626edbb22dd58abc9
MD5 f958c44dff1811502b2dc1d62022bd45
BLAKE2b-256 0b5abb9e44606a77aa0522c6006ccfed0eb71b309ae6d353f11ed107531addcf

See more details on using hashes here.

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