Skip to content

uchti/python-pretty-toml

Repository files navigation

Pretty TOML for Python

Build Status Python Versions Release Wheel

A formatter for TOML files.

Installation

pip install --upgrade prettytoml

Usage

>>> import prettytoml
>>> prettified_content = prettytoml.prettify_from_file('sample.toml')
>>> with open('sample-prettified.toml', 'w') as fp:
      fp.write(prettified_content)

Formatting Rules

  • Entries within a single table should be ordered lexicographically by key
  • Every key and value pair in any table should be separated by the triplet (single space character, an assignment character =, single space character)
  • Anonymous table should never be indented
  • Nth-level table sections should be indented by (N-1)*2 spaces
  • Line-terminating comments should always be prefixed by a single tab character whitespace only
  • Lines whose lengths exceed 120 characters whose values are strings, arrays should have the array or string value broken onto multiple lines
  • Tables should always be separated by an empty newline

About

Pretty TOML for Python

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages