Files
sci-gui-agent-benchmark/clear_sheetcopilot_jsons.py
David Chang ed61404f2b ver Feb19thv4
corrected a series of sheetcopilot task configs
2024-02-19 22:34:09 +08:00

32 lines
1.1 KiB
Python

#!/usr/bin/python3
import json
import shutil
import os
import os.path
from typing import Dict, List
from typing import Any
path = "evaluation_examples/examples/sheetcopilot"
for f in filter(lambda f: f.endswith(".json"), os.listdir(path)):
with open(os.path.join(path, f)) as f_obj:
config: Dict[str, Any] = json.load(f_obj)
options: List[Dict[str, Any]] = []
deletes = False
for opt in config["evaluator"]["options"]["rules"]:
if opt["type"] == "style" and opt["props"] == [ "font_name", "font_color"
, "font_bold", "font_italic"
, "font_underline", "bgcolor"
]:
deletes = True
continue
else:
options.append(opt)
if deletes:
config["evaluator"]["options"]["rules"] = options
shutil.move(os.path.join(path, f), os.path.join(path, f + ".old"))
with open(os.path.join(path, f), "w") as f_obj:
json.dump(config, f_obj, indent="\t", ensure_ascii=False)