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", "wb") 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.3.0.tar.gz (5.5 kB view details)

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: tomli_w-0.3.0.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.3.0.tar.gz
Algorithm Hash digest
SHA256 207c5f05803aec5a9a578c6aca5c1bbbba9783ad88461f3e180eb8c3c3c48a4b
MD5 4905e5d5c09cd6c3611ec1e3b3816fce
BLAKE2b-256 461261ed2aa21bb7207ccce71eb3741623ce8a9adb99e034893a21ef5cc154d9

See more details on using hashes here.

File details

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

File metadata

  • Download URL: tomli_w-0.3.0-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.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b33994e455a627ff4b291328d0ccbb679782dc1b3bd002c123c27b5ee19ca490
MD5 2e1e1cb3495a86e3ac7ea0b9176e342a
BLAKE2b-256 85382d08a0f1fb09225270baef4ecd5ccdcad652b5168aa4e1912d38fc5af5d0

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