From 804a9da4df53995eb1468c4ec1feeb7715d94e6e Mon Sep 17 00:00:00 2001 From: Nicolas Wittler Date: Fri, 10 Jun 2022 15:58:24 +0000 Subject: [PATCH] Deleted helper file. --- test/convert_cfgs_1.5.py | 53 ---------------------------------------- 1 file changed, 53 deletions(-) delete mode 100755 test/convert_cfgs_1.5.py diff --git a/test/convert_cfgs_1.5.py b/test/convert_cfgs_1.5.py deleted file mode 100755 index dd2604ba..00000000 --- a/test/convert_cfgs_1.5.py +++ /dev/null @@ -1,53 +0,0 @@ -#!/usr/bin/env python3 -import argparse -import hjson -import shutil - -parser = argparse.ArgumentParser() -parser.add_argument( - "files", metavar="F", type=str, nargs="+", help="List of files to convert" -) - -args = parser.parse_args() - - -def convert(dct): - if "Drives" not in dct: - dct["Drives"] = {} - drv_keys = [] - for key, coup in dct["Couplings"].items(): - if coup["c3type"] == "Drive": - dct["Drives"][key] = coup - drv_keys.append(key) - for key in drv_keys: - dct["Couplings"].pop(key, None) - return dct - - -def write(cfg, dct): - with open(cfg, "w") as cfg_file: - hjson.dump(dct, cfg_file) - - -for cfg in args.files: - with open(cfg, "r") as cfg_file: - cfg_dct = hjson.load(cfg_file) - if "model" in cfg_dct: - if type(cfg_dct["model"]) is str: - # Just convert separate model file - model_str = cfg_dct["model"] - shutil.copy(model_str, model_str + ".old") - with open(model_str, "r") as cfg_file: - dct = hjson.load(cfg_file) - write(model_str, convert(dct)) - else: - # Convert embedded model dict - shutil.copy(cfg, cfg + ".old") - dct = convert(cfg_dct["model"]) - cfg_dct["model"] = dct - write(cfg, cfg_dct) - - elif "Couplings" in cfg_dct: - # Convert model file - shutil.copy(cfg, cfg + ".old") - write(cfg, convert(cfg_dct))