3 Created on Thu Aug 13 23:45:12 2015
8 Boreal Scientific Computing LLC, Fairbanks, Alaska, USA
9 Don.Morton@borealscicomp.com
10 http://www.borealscicomp.com/
16 christian.maurer@zamg.ac.at
17 delia.arnold-arias@zamg.ac.at
22 import xml.etree.ElementTree
as XMLTree
32 Container for an entire test suite, initialised from an XML config file.
33 A TestSuite object contains Distribution classes, which in turn will each
34 contain MetCase, RunCase and BasicTest objects. A TestSuite object should
35 have all of the information necessary for testing routines to do their
42 Creates a list of Distribution objects from a list of xml_files.
43 If only a single file is entered as an argument (which may often
44 be the case), it is inserted into a list of one element. An XML file
45 is read, and a Distribution object is manufactured from this
49 if type(xml_files)
is str:
51 elif type(xml_files)
is list:
54 raise Exception(
'xml_files should be a list')
56 raise Exception(
'A list of valid xml_files is needed')
66 distro_tree = XMLTree.parse(the_xml_file)
70 print 'Error parsing XML file: ' + str(the_xml_file)
74 self._distribution_list.append( distro_object )
85 Creates and returns a distribution object (e.g. FLEXPART-ECMWF
86 (nested/not nested input), FLEXPART-GFS or FLEXPART-WRF) based
87 on the parsed XML distribution tree
97 the_distribution =
None
100 distro_path = parmod_path = exec_name =
None
102 distro_root = distro_tree.getroot()
103 for child
in distro_root:
104 if child.tag ==
'metcase':
106 met_case_list.append(the_met_case)
107 elif child.tag ==
'short_descr':
108 descr = child.text.strip()
109 elif child.tag ==
'distropath':
110 distro_path = child.text.strip()
111 elif child.tag ==
'parmodpath':
112 parmod_path = child.text.strip()
113 elif child.tag ==
'execname':
114 exec_name = child.text.strip()
117 if descr
and distro_path
and exec_name:
120 distro_path=distro_path,
121 parmod_path=parmod_path,
123 met_case_list=met_case_list
127 "Unable to create Distribution object - missing args"
130 return the_distribution
135 """ Creates and returns a MetCase object based on the parsed XML
136 tree. This will read in the parameters for a MetCase object, as
137 well as RunCase objects, if available. Otherwise, inserts an empty
141 metnestfile_dir =
None
142 if met_case_tree
is not None:
144 met_case_root = met_case_tree.getchildren()
145 for child
in met_case_root:
146 if child.tag ==
'runcase':
148 run_case_list.append(the_run_case)
149 elif child.tag ==
"short_descr":
150 descr = child.text.strip()
151 elif child.tag ==
"metfiledir":
152 metfile_dir = child.text.strip()
153 elif child.tag ==
"metnestfiledir":
154 metnestfile_dir = child.text.strip()
156 if descr
and metfile_dir:
158 metfile_dir=metfile_dir,
159 metnestfile_dir=metnestfile_dir,
160 run_case_list=run_case_list)
163 "Unable to create MetCase object - missing args"
169 """Creates and returns a RunCase object based on the parsed XML tree.
170 This will read in the parameters for runcase objects, as
171 well as BasicTest objects, if available. Otherwise, inserts and
172 empty BasicTest list"""
175 if run_case_tree
is not None:
176 descr = testtype = max_threshold =
None
179 run_case_root = run_case_tree.getchildren()
180 for child
in run_case_root:
181 if child.tag ==
'basictest':
183 basic_test_list.append(the_basic_test)
184 elif child.tag ==
'short_descr':
185 descr = child.text.strip()
186 elif child.tag ==
'casedir':
187 case_dir = child.text.strip()
188 elif child.tag ==
'controldatadir':
189 control_data_dir = child.text.strip()
192 if descr
and case_dir
and control_data_dir:
195 control_data_dir=control_data_dir,
196 test_list=basic_test_list)
199 "Unable to create RunCase object - missing args"
207 """ Creates and returns a BasicTest object based on the parsed
208 XML tree parameters"""
210 the_basic_test =
None
211 if basic_test_tree
is not None:
212 basic_test_root = basic_test_tree.getchildren()
214 for child
in basic_test_root:
215 if child.tag ==
'short_descr':
216 descr = child.text.strip()
217 elif child.tag ==
'type':
218 testtype = child.text.strip()
219 elif child.tag ==
'max_threshold':
220 max_threshold = child.text.strip()
222 if descr
and testtype
and max_threshold:
225 threshold=max_threshold)
228 "Unable to create BasicTest object - missing args"
231 return the_basic_test
def get_distribution_list