2021-03-13 17:05:59 +00:00
|
|
|
# Since go doesn't order its json, this script adds ordered lists
|
|
|
|
# of section/setting names for the settings tab to use.
|
2020-08-01 20:20:02 +00:00
|
|
|
import json, argparse
|
2020-07-31 15:09:30 +00:00
|
|
|
|
2020-08-01 20:20:02 +00:00
|
|
|
parser = argparse.ArgumentParser()
|
|
|
|
parser.add_argument("-i", "--input", help="input config base from jf-accounts")
|
|
|
|
parser.add_argument("-o", "--output", help="output config base for jfa-go")
|
|
|
|
|
|
|
|
args = parser.parse_args()
|
|
|
|
|
|
|
|
with open(args.input, 'r') as f:
|
2020-07-31 15:09:30 +00:00
|
|
|
config = json.load(f)
|
|
|
|
|
2021-01-05 18:16:23 +00:00
|
|
|
newconfig = {"sections": {}, "order": []}
|
2020-07-31 15:09:30 +00:00
|
|
|
|
2021-01-05 18:16:23 +00:00
|
|
|
for sect in config["sections"]:
|
2020-07-31 15:09:30 +00:00
|
|
|
newconfig["order"].append(sect)
|
2021-01-05 18:16:23 +00:00
|
|
|
newconfig["sections"][sect] = {}
|
|
|
|
newconfig["sections"][sect]["order"] = []
|
|
|
|
newconfig["sections"][sect]["meta"] = config["sections"][sect]["meta"]
|
|
|
|
newconfig["sections"][sect]["settings"] = {}
|
|
|
|
for setting in config["sections"][sect]["settings"]:
|
|
|
|
newconfig["sections"][sect]["order"].append(setting)
|
|
|
|
newconfig["sections"][sect]["settings"][setting] = config["sections"][sect]["settings"][setting]
|
2020-07-31 15:09:30 +00:00
|
|
|
|
2020-08-01 20:20:02 +00:00
|
|
|
with open(args.output, 'w') as f:
|
2020-07-31 15:09:30 +00:00
|
|
|
f.write(json.dumps(newconfig, indent=4))
|
|
|
|
|
|
|
|
|