#!/usr/bin/env python import json import os BASE_PATH = f"{os.environ['ROOT']}/scripts" CLASSES_PATH = f"{BASE_PATH}/src/classes.json" CLASSES = [] with open(CLASSES_PATH) as f: CLASSES = json.load(open(CLASSES_PATH)) to_add: str = input("Class to add:") if not to_add.startswith("bi-"): to_add = f"bi-{to_add}" if to_add not in CLASSES: CLASSES.append(to_add) else: raise Exception("Class already exists!") file = open(CLASSES_PATH, "w") file.write(json.dumps(sorted(CLASSES), sort_keys=True, indent=2).rstrip()) file.close()