import json def main(): with open("view.json", "r") as f: view = json.load(f) dpm_device_idx = 1 dpm_label_idx = 1 for child in view["root"]["children"]: # Update DPM device names (skip MCM, which is usually named 'MCM') if child.get("type") == "ia.display.view" and child["meta"].get("name") != "MCM": child["meta"]["name"] = f"DPM{dpm_device_idx}_DEVICE" dpm_device_idx += 1 # Update DPM label names and text elif child.get("type") == "ia.display.label": child["meta"]["name"] = f"DPM{dpm_label_idx}_label" child["props"]["text"] = f"DPM{dpm_label_idx}_TEXT" dpm_label_idx += 1 with open("view.json", "w") as f: json.dump(view, f, indent=2) print("DPM device and label names/texts updated and saved to view_renamed.json") if __name__ == "__main__": main()