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

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for tomli_w-0.2.2.tar.gz
Algorithm Hash digest
SHA256 c9098c7400eb77ec65c81e6aa0114c3a924d60c2901cac2cc23e960ba0f7db05
MD5 db668e8c661c6e35d7e0b34cbad4197c
BLAKE2b-256 bc6bbc469bea777083f2f98ca7f8dff29d299c520a1d7c36bf2882d76704a28e

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for tomli_w-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 21736b394e20587506eece6766f9eb047441bc5009e50aa5a418aec29c56b752
MD5 e1f356d6432c6c2276dc17e0249c8bfe
BLAKE2b-256 6e4a053e2e280ce0a0c3b00241e96555c146f19a2b56b9a5a7a6fa4fe14889ae

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