Questions tagged [tomlkit]

Style-preserving TOML library for Python

https://github.com/sdispater/tomlkit

4 questions
2
votes
0 answers

Python - how to entirely stop a function if criteria is not met?

I have these two functions. The first one gets a file path ensures the file exists. The second function is intended to check that a table exists in a toml file and then ensure three values exist and are not None or '' I am wondering how I can make…
uncrayon
  • 395
  • 2
  • 11
0
votes
0 answers

Python - pathlib, tomlkit check if values exist

I have a toml file that looks like; [default] conf_path = "d" prefix = "p" suffix = "s" And I have this code; def get_config_path(): final_path = Path(os.getenv('CONFIG_PATH', const.CONFIG_PATH)).expanduser().resolve() if not…
uncrayon
  • 395
  • 2
  • 11
0
votes
2 answers

tomlkit: nicely formatted array with inline tables

I am trying to use tomlkit 0.8.0 to create a TOML from the following data: data = { 'stuff': [ {'a':1, 'b': 2}, {'c': 3}, {'a': 4}, ] } in this format exactly: stuff = [ {a = 1, b = 2}, {c = 3}, {a = 4},…
Udi
  • 29,222
  • 9
  • 96
  • 129
-1
votes
1 answer

How can I check is each keys in this dict exist and that they all have a non empty value?

I have a toml file that looks like [default] conf_path = "d" prefix = "p" suffix = "s" I am turning this into a dict that looks like, {default: {'conf_path': 'd', 'prefix': 'p', 'suffix': 's'}} They key is default and the value is a dictionary. I…
uncrayon
  • 395
  • 2
  • 11