import os import sys import json def parseInputFile(inputFile): if not os.path.isfile(inputFile): print(f"Error: Input file '{inputFile}' does not exist.") sys.exit(1) data = None with open(inputFile, 'r') as f: data = json.load(f) # Data should have height key if 'height' not in data or 'width' not in data: print(f"Error: Input file '{inputFile}' does not contain 'height' or 'width' key.") sys.exit(1) if 'tilewidth' not in data or 'tileheight' not in data: print(f"Error: Input file '{inputFile}' does not contain 'tilewidth' or 'tileheight' key.") sys.exit(1) if 'infinite' not in data or not isinstance(data['infinite'], bool): print(f"Error: Input file '{inputFile}' does not contain 'infinite' key.") sys.exit(1) # Need layers if 'layers' not in data or not isinstance(data['layers'], list) or len(data['layers']) == 0: print(f"Error: Input file '{inputFile}' does not contain 'layers' key.") sys.exit(1) return data