1
0
mirror of https://github.com/hrfee/jfa-go.git synced 2024-12-22 17:10:10 +00:00

fix generate_ini for multiline descriptions

This commit is contained in:
Harvey Tindall 2021-05-16 23:00:37 +01:00
parent 1d47b9074f
commit 0f3ad8bb69
Signed by: hrfee
GPG Key ID: BBC65952848FB1A2

View File

@ -4,6 +4,8 @@ import json
import argparse import argparse
from pathlib import Path from pathlib import Path
def fix_description(desc):
return "; " + desc.replace("\n", "\n; ")
def generate_ini(base_file, ini_file): def generate_ini(base_file, ini_file):
""" """
@ -17,10 +19,10 @@ def generate_ini(base_file, ini_file):
for section in config_base["sections"]: for section in config_base["sections"]:
ini.add_section(section) ini.add_section(section)
if "meta" in config_base["sections"][section]: if "meta" in config_base["sections"][section]:
ini.set(section, "; " + config_base["sections"][section]["meta"]["description"]) ini.set(section, fix_description(config_base["sections"][section]["meta"]["description"]))
for entry in config_base["sections"][section]["settings"]: for entry in config_base["sections"][section]["settings"]:
if "description" in config_base["sections"][section]["settings"][entry]: if "description" in config_base["sections"][section]["settings"][entry]:
ini.set(section, "; " + config_base["sections"][section]["settings"][entry]["description"]) ini.set(section, fix_description(config_base["sections"][section]["settings"][entry]["description"]))
value = config_base["sections"][section]["settings"][entry]["value"] value = config_base["sections"][section]["settings"][entry]["value"]
if isinstance(value, bool): if isinstance(value, bool):
value = str(value).lower() value = str(value).lower()