import json
import sys
import os
sys.path.append("../../../external/Fusion/buildtool/external/")
import jsonschema
sys.path.pop()

def main():
	configFileNames = ["variantconfig.json"]
	if len(sys.argv) > 1:
		configFileNames = sys.argv[1:]

	for configFileName in configFileNames:
		with open(configFileName) as configFile:
			config = json.load(configFile)
		with open("schema.json") as schemaFile:
			schema = json.load(schemaFile)
		try:
			jsonschema.validate(config, schema)
			print(configFileName + " successfully validated")
		except jsonschema.ValidationError, e:
			print("Failed to validate " + configFileName)
			print(e)

if __name__ == '__main__':
	main()
