-
-
Notifications
You must be signed in to change notification settings - Fork 105
Open
Description
Hello,
I am using the tomlkit Python library to modify an existing TOML file.
The original file looks like this:
## My POST route comment
[[routes]]
method = 'POST'
path = '/my/post/path'
topic = 'my-topic.0'
## My GET route comment
[[routes]]
method = 'GET'
path = '/my/get/path/{key}'
topic = 'my-topic.1'
I add two tables to that original array of tables "[[routes]]", with method = 'POST' and path = '/my/post/path'. When I do that, the resulting file becomes:
## My POST route comment
[[routes]]
method = 'POST'
path = '/my/post/path'
topic = 'my-topic.0'
## My GET route comment
[routes.rate_limit]
enabled = true
[routes.rate_limit.requests]
per_second = 25
[[routes]]
method = 'GET'
path = '/my/get/path/{key}'
topic = 'my-topic.1'
The comment ends up in the wrong spot. What can I do to make sure it stays on top of my second "[[routes]]" such as:
## My POST route comment
[[routes]]
method = 'POST'
path = '/my/post/path'
topic = 'my-topic.0'
[routes.rate_limit]
enabled = true
[routes.rate_limit.requests]
per_second = 25
## My GET route comment
[[routes]]
method = 'GET'
path = '/my/get/path/{key}'
topic = 'my-topic.1'
This is an extract of the code I use to add my 2 tables:
# result is <class 'tomlkit.items.Table'>
route_ratelimit = tomlkit.table()
route_ratelimit.add("enabled", True)
route_ratelimit_requests = tomlkit.table()
route_ratelimit_requests.add("per_second", 25)
result.append("rate_limit", route_ratelimit)
route_ratelimit.append("requests", route_ratelimit_requests)
Thank you for your assistance.
Metadata
Metadata
Assignees
Labels
No labels