uiri / toml

Python lib for TOML
MIT License
1.1k stars 190 forks source link

Feature Request: Indentation support #214

Open xNinjaKittyx opened 6 years ago

xNinjaKittyx commented 6 years ago

Is there any intention to get indentation support for the dumps?

Taking examples from the TOML-lang GitHub Readme

[servers]

  # Indentation (tabs and/or spaces) is allowed but not required
  [servers.alpha]
  ip = "10.0.0.1"
  dc = "eqdc10"

  [servers.beta]
  ip = "10.0.0.2"
  dc = "eqdc10"

or

[[fruit]]
  name = "apple"

  [fruit.physical]
    color = "red"
    shape = "round"

  [[fruit.variety]]
    name = "red delicious"

  [[fruit.variety]]
    name = "granny smith"

[[fruit]]
  name = "banana"

  [[fruit.variety]]
    name = "plantain"

Edit: I actually don't like how the variables inside the tables are indented. Even something like this:

[[fruit]]
name = "apple"

  [fruit.physical]
  color = "red"
  shape = "round"

  [[fruit.variety]]
  name = "red delicious"

is good enough for me.

uiri commented 6 years ago

Huh, I could have sworn that I'd already seen this as a feature request and/or wrote a decoder for that. But apparently not. Thanks for the suggestion!

LinasNas commented 2 years ago

Hi, I was just interested if the feature of having indentation when using toml.dumps() or toml.dump() has been implemented since. Would greatly appreciate the help!

Investigamer commented 1 year ago

I'm just now learning virtually every toml package with dump capabilities lacks common json/yaml/etc styling kwargs like indent, allow_unicode/ensure_ascii, even sort_keys is missing among some. I find this very bizarre, has this request been revisited at any point?