Skip to content

Commit

Permalink
fix: better comment out example/placeholder config (only keys, not he…
Browse files Browse the repository at this point in the history
…aders or empty lines) (#113)
  • Loading branch information
ErikBjare committed Oct 17, 2022
1 parent ffef93a commit d7c91cd
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions aw_core/config.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import os
import logging
from typing import Any, Dict, Union
from configparser import ConfigParser
import os
from typing import Union

from deprecation import deprecated
import tomlkit
from deprecation import deprecated

from aw_core import dirs
from aw_core.__about__ import __version__
Expand Down Expand Up @@ -34,7 +33,13 @@ def _merge(a: dict, b: dict, path=None):


def _comment_out_toml(s: str):
return "\n".join(["#" + line for line in s.split("\n")])
# Only comment out keys, not headers or empty lines
return "\n".join(
[
"#" + line if line.strip() and not line.strip().startswith("[") else line
for line in s.split("\n")
]
)


def load_config_toml(
Expand Down

0 comments on commit d7c91cd

Please sign in to comment.