This is a small utility that converts ini-files to json

main
Micke Nordin 2 years ago
parent b4d060bbcf
commit 8872ccf2e2
Signed by: micke
GPG Key ID: 0DA0A7A5708FE257

@ -0,0 +1,18 @@
#!/usr/bin/env python3
import configparser
import sys
import json
config = configparser.ConfigParser()
str_conf = ""
for line in sys.stdin.read().splitlines(keepends=True):
if not (line.startswith("-") or line.startswith("#")):
str_conf += line
config.read_string(str_conf)
dictionary = {}
for section in config.sections():
dictionary[section] = {}
for option in config.options(section):
dictionary[section][option] = config.get(section, option)
print(json.dumps(dictionary))
Loading…
Cancel
Save