Created
May 1, 2023 15:52
-
-
Save shellygr/27837495489ae108dabb0467ddc2dbf2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
import sys | |
from pathlib import Path | |
""" | |
Super basic script for fixing up conf files following the new API changes. | |
This is a one-time thing so not spending too much in engineering. | |
It traverses conf files recursively in the cwd. | |
""" | |
for conf_file in Path(".").rglob("*.conf"): | |
print(f"Working on {conf_file}") | |
with open(conf_file) as conf_handle: | |
json_obj = json.load(conf_handle) | |
# now we start modifications on the json_obj! | |
# we loudly exit on any error. | |
# verify was a list and now is just a string. | |
if "verify" in json_obj: | |
verify_obj = json_obj["verify"] | |
if len(verify_obj) > 0 and isinstance(verify_obj, list): | |
if len(verify_obj) > 1: | |
print(f"Multiple spec files in conf {verify_obj}, cannot convert") | |
sys.exit(1) | |
json_obj["verify"] = verify_obj[0] | |
# To be continued...! | |
with open(conf_file, 'w') as conf_handle: | |
json.dump(json_obj, conf_handle, indent=4) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment