|
Zoltan2
|
00001 #!/usr/bin/python 00002 # 00003 # Element is available in python 1.5.2 and higher. 00004 # It can be downloaded to use with older python. 00005 # 00006 # This script does some basic validity checks on parameters.xml. 00007 00008 import elementtree.ElementTree as ET 00009 import sys 00010 00011 ## 00012 ## Begin 00013 ## 00014 00015 tree = ET.parse("./parameters.xml") 00016 00017 root = tree.getroot() 00018 00019 if root.tag != "ParameterList": 00020 print "Error: Root tag is not ParameterList" 00021 sys.exit(1) 00022 00023 validators = [] 00024 for node in root: 00025 if node.tag == "Validators": 00026 validators = node 00027 break 00028 00029 if len(validators) == 0: 00030 print "Error: This is not a valid Zoltan2 parameter list." 00031 sys.exit(1) 00032 00033 00034 # Create a dictionary of Validators 00035 00036 vals={} 00037 00038 for node in validators: 00039 id = node.get("validatorId") 00040 if id in vals: 00041 print "Error: Validator ID ",id," is repeated." 00042 sys.exit(1) 00043 00044 vals[id] = node 00045 00046 ## 00047 # Match up parameters to validators 00048 ## 00049 00050 idList = [] 00051 fail = False 00052 00053 for node in root: 00054 if node.tag != "Parameter": 00055 continue 00056 paramName = node.get("name") 00057 paramId = node.get("id") 00058 validatorId = node.get("validatorId") 00059 00060 if paramId in idList: 00061 print "Error: Parameter id ",paramId," is reused for ",paramName 00062 fail = True 00063 break 00064 00065 idList.append(paramId) 00066 00067 if validatorId not in vals.keys(): 00068 print "Error: Parameter ",paramName," has invalid validator ID ",validatorId 00069 fail = True 00070 break 00071 00072 if fail == True: 00073 print "Looks OK" 00074 00075
1.7.6.1