Toml sorting library
Project description
toml-sort
A command line utility to sort your toml files. Requires Python 3.6 or greater.
Motivation
I wrote this library because I couldn't find any "good" sorting utilities for TOML files. This library strives to sort TOML files by providing the following features:
- Preserve inline comments
- Sort tables / arrays of Tables
- Option to sort table keys, or not
- Standardize top-level whitespace and indentation (generally removes it; this library is opinionated here)
- Preserve top-level comments (in progress; really hard and maybe unachievable)
Installation
pip install toml-sort
Usage
This project can be used as either a Python library or a command line utility. I will document the Python library interface in the future when it stabilizes. The command line interface should remain fairly stable.
Command line interface
Read from stdin, write to stdout:
cat input.toml | toml-sort
Read from file on disk, write to file on disk:
toml-sort -o output.toml input.toml
Read from file on disk, write to stdout
toml-sort input.toml
Read from stdin, write to file on disk
cat input.toml | toml-sort -o output.toml
Only sort the top-level tables / arrays of tables
cat input.toml | toml-sort -i
cat input.toml | toml-sort --ignore-non-tables
Local Development
Local development for this project is quite simple.
Dependencies
Install the following tools manually.
Recommended
Set up development environment
make setup
Run Tests
make test
Written by
Samuel Roeca samuel.roeca@gmail.com
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file toml-sort-0.9.0.tar.gz
.
File metadata
- Download URL: toml-sort-0.9.0.tar.gz
- Upload date:
- Size: 5.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/0.12.17 CPython/3.7.3 Linux/4.15.0-55-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 20b62213667e01d202f40b0c58efdde61e232e673409383e7c1d0cca062fcf46 |
|
MD5 | c62ce8431731cbca5f6aa51eb32d35eb |
|
BLAKE2b-256 | 3f083b2974ddf0d1d4dc3fc40aef2cc10248496e34cdc1efcaae99378e654b7f |
File details
Details for the file toml_sort-0.9.0-py3-none-any.whl
.
File metadata
- Download URL: toml_sort-0.9.0-py3-none-any.whl
- Upload date:
- Size: 6.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/0.12.17 CPython/3.7.3 Linux/4.15.0-55-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 854b445bee78eab7ed586f92bc7822ddcb4b4ece010188421c82fee35e28c53d |
|
MD5 | be72dbb03579cd4d738792c4101c7a9e |
|
BLAKE2b-256 | 046190bd8723fcae2b40eebbd0295b0de4bce82adf06faf8c1278ceaec31a8eb |