comparison toolfactory/galaxyxml/tool/import_xml.py @ 36:ce2b1f8ea68d draft

passes flake8 tests finally :)
author fubar
date Mon, 10 Aug 2020 23:24:41 -0400
parents 5d38cb3d9be8
children a30536c100bf
comparison
equal deleted inserted replaced
35:5d38cb3d9be8 36:ce2b1f8ea68d
20 :type xml_root: :class:`xml.etree._Element` 20 :type xml_root: :class:`xml.etree._Element`
21 """ 21 """
22 version_cmd = None 22 version_cmd = None
23 description = None 23 description = None
24 for child in xml_root: 24 for child in xml_root:
25 if child.tag == 'description': 25 if child.tag == "description":
26 description = child.text 26 description = child.text
27 elif child.tag == 'command': 27 elif child.tag == "command":
28 executable = child.text.split()[0] 28 executable = child.text.split()[0]
29 command = child.text 29 command = child.text
30 elif child.tag == 'version_command': 30 elif child.tag == "version_command":
31 version_cmd = child.text 31 version_cmd = child.text
32 32
33 tool = gxt.Tool(xml_root.attrib['name'], 33 tool = gxt.Tool(
34 xml_root.attrib['id'], 34 xml_root.attrib["name"],
35 xml_root.attrib.get('version', None), 35 xml_root.attrib["id"],
36 description, 36 xml_root.attrib.get("version", None),
37 executable, 37 description,
38 hidden=xml_root.attrib.get('hidden', False), 38 executable,
39 tool_type=xml_root.attrib.get('tool_type', None), 39 hidden=xml_root.attrib.get("hidden", False),
40 URL_method=xml_root.attrib.get('URL_method', None), 40 tool_type=xml_root.attrib.get("tool_type", None),
41 workflow_compatible=xml_root.attrib.get('workflow_compatible', True), 41 URL_method=xml_root.attrib.get("URL_method", None),
42 version_command=version_cmd) 42 workflow_compatible=xml_root.attrib.get("workflow_compatible", True),
43 version_command=version_cmd,
44 )
43 tool.command = command 45 tool.command = command
44 return tool 46 return tool
45 47
46 def _load_description(self, tool, desc_root): 48 def _load_description(self, tool, desc_root):
47 """ 49 """
107 :param requirements_root: root of <requirements> tag. 109 :param requirements_root: root of <requirements> tag.
108 :type requirements_root: :class:`xml.etree._Element` 110 :type requirements_root: :class:`xml.etree._Element`
109 """ 111 """
110 tool.requirements = gxtp.Requirements() 112 tool.requirements = gxtp.Requirements()
111 for req in requirements_root: 113 for req in requirements_root:
112 req_type = req.attrib['type'] 114 req_type = req.attrib["type"]
113 value = req.text 115 value = req.text
114 if req.tag == 'requirement': 116 if req.tag == "requirement":
115 version = req.attrib.get('version', None) 117 version = req.attrib.get("version", None)
116 tool.requirements.append(gxtp.Requirement(req_type, value, version=version)) 118 tool.requirements.append(
117 elif req.tag == 'container': 119 gxtp.Requirement(req_type, value, version=version)
120 )
121 elif req.tag == "container":
118 tool.requirements.append(gxtp.Container(req_type, value)) 122 tool.requirements.append(gxtp.Container(req_type, value))
119 else: 123 else:
120 logger.warning(req.tag + ' is not a valid tag for requirements child') 124 logger.warning(req.tag + " is not a valid tag for requirements child")
121 125
122 def _load_edam_topics(self, tool, topics_root): 126 def _load_edam_topics(self, tool, topics_root):
123 """ 127 """
124 Add <edam_topics> to the tool. 128 Add <edam_topics> to the tool.
125 129
154 :param configfiles_root: root of <configfiles> tag. 158 :param configfiles_root: root of <configfiles> tag.
155 :type configfiles_root: :class:`xml.etree._Element` 159 :type configfiles_root: :class:`xml.etree._Element`
156 """ 160 """
157 tool.configfiles = gxtp.Configfiles() 161 tool.configfiles = gxtp.Configfiles()
158 for conf in configfiles_root: 162 for conf in configfiles_root:
159 name = conf.attrib['name'] 163 name = conf.attrib["name"]
160 value = conf.text 164 value = conf.text
161 tool.configfiles.append(gxtp.Configfile(name, value)) 165 tool.configfiles.append(gxtp.Configfile(name, value))
162 166
163 def _load_citations(self, tool, citations_root): 167 def _load_citations(self, tool, citations_root):
164 """ 168 """
169 :param citations_root: root of <citations> tag. 173 :param citations_root: root of <citations> tag.
170 :type citations_root: :class:`xml.etree._Element` 174 :type citations_root: :class:`xml.etree._Element`
171 """ 175 """
172 tool.citations = gxtp.Citations() 176 tool.citations = gxtp.Citations()
173 for cit in citations_root: 177 for cit in citations_root:
174 cit_type = cit.attrib['type'] 178 cit_type = cit.attrib["type"]
175 value = cit.text 179 value = cit.text
176 tool.citations.append(gxtp.Citation(cit_type, value)) 180 tool.citations.append(gxtp.Citation(cit_type, value))
177 181
178 def _load_inputs(self, tool, inputs_root): 182 def _load_inputs(self, tool, inputs_root):
179 """ 183 """
226 xml_root = ET.parse(xml_path).getroot() 230 xml_root = ET.parse(xml_path).getroot()
227 tool = self._init_tool(xml_root) 231 tool = self._init_tool(xml_root)
228 # Now we import each tag's field 232 # Now we import each tag's field
229 for child in xml_root: 233 for child in xml_root:
230 try: 234 try:
231 getattr(self, '_load_{}'.format(child.tag))(tool, child) 235 getattr(self, "_load_{}".format(child.tag))(tool, child)
232 except AttributeError: 236 except AttributeError:
233 logger.warning(child.tag + " tag is not processed.") 237 logger.warning(child.tag + " tag is not processed.")
234 return tool 238 return tool
235 239
236 240
245 249
246 :param root: root to append the param to. 250 :param root: root to append the param to.
247 :param text_param: root of <param> tag. 251 :param text_param: root of <param> tag.
248 :type text_param: :class:`xml.etree._Element` 252 :type text_param: :class:`xml.etree._Element`
249 """ 253 """
250 root.append(gxtp.TextParam(text_param.attrib['name'], 254 root.append(
251 optional=text_param.get('optional', None), 255 gxtp.TextParam(
252 label=text_param.get('label', None), 256 text_param.attrib["name"],
253 help=text_param.get('help', None), 257 optional=text_param.get("optional", None),
254 value=text_param.get('value', None))) 258 label=text_param.get("label", None),
259 help=text_param.get("help", None),
260 value=text_param.get("value", None),
261 )
262 )
255 263
256 def _load_data_param(self, root, data_param): 264 def _load_data_param(self, root, data_param):
257 """ 265 """
258 Add <param type="data" /> to the root. 266 Add <param type="data" /> to the root.
259 267
260 :param root: root to append the param to. 268 :param root: root to append the param to.
261 :param data_param: root of <param> tag. 269 :param data_param: root of <param> tag.
262 :type data_param: :class:`xml.etree._Element` 270 :type data_param: :class:`xml.etree._Element`
263 """ 271 """
264 root.append(gxtp.DataParam(data_param.attrib['name'], 272 root.append(
265 optional=data_param.attrib.get('optional', None), 273 gxtp.DataParam(
266 label=data_param.attrib.get('label', None), 274 data_param.attrib["name"],
267 help=data_param.attrib.get('help', None), 275 optional=data_param.attrib.get("optional", None),
268 format=data_param.attrib.get('format', None), 276 label=data_param.attrib.get("label", None),
269 multiple=data_param.attrib.get('multiple', None))) 277 help=data_param.attrib.get("help", None),
278 format=data_param.attrib.get("format", None),
279 multiple=data_param.attrib.get("multiple", None),
280 )
281 )
270 282
271 def _load_boolean_param(self, root, bool_param): 283 def _load_boolean_param(self, root, bool_param):
272 """ 284 """
273 Add <param type="boolean" /> to the root. 285 Add <param type="boolean" /> to the root.
274 286
275 :param root: root to append the param to. 287 :param root: root to append the param to.
276 :param bool_param: root of <param> tag. 288 :param bool_param: root of <param> tag.
277 :type bool_param: :class:`xml.etree._Element` 289 :type bool_param: :class:`xml.etree._Element`
278 """ 290 """
279 root.append(gxtp.BooleanParam(bool_param.attrib['name'], 291 root.append(
280 optional=bool_param.attrib.get('optional', None), 292 gxtp.BooleanParam(
281 label=bool_param.attrib.get('label', None), 293 bool_param.attrib["name"],
282 help=bool_param.attrib.get('help', None), 294 optional=bool_param.attrib.get("optional", None),
283 checked=bool_param.attrib.get('checked', False), 295 label=bool_param.attrib.get("label", None),
284 truevalue=bool_param.attrib.get('truevalue', None), 296 help=bool_param.attrib.get("help", None),
285 falsevalue=bool_param.attrib.get('falsevalue', None))) 297 checked=bool_param.attrib.get("checked", False),
298 truevalue=bool_param.attrib.get("truevalue", None),
299 falsevalue=bool_param.attrib.get("falsevalue", None),
300 )
301 )
286 302
287 def _load_integer_param(self, root, int_param): 303 def _load_integer_param(self, root, int_param):
288 """ 304 """
289 Add <param type="integer" /> to the root. 305 Add <param type="integer" /> to the root.
290 306
291 :param root: root to append the param to. 307 :param root: root to append the param to.
292 :param int_param: root of <param> tag. 308 :param int_param: root of <param> tag.
293 :type int_param: :class:`xml.etree._Element` 309 :type int_param: :class:`xml.etree._Element`
294 """ 310 """
295 root.append(gxtp.IntegerParam(int_param.attrib['name'], 311 root.append(
296 int_param.attrib.get('value', None), 312 gxtp.IntegerParam(
297 optional=int_param.attrib.get('optional', None), 313 int_param.attrib["name"],
298 label=int_param.attrib.get('label', None), 314 int_param.attrib.get("value", None),
299 help=int_param.attrib.get('help', None), 315 optional=int_param.attrib.get("optional", None),
300 min=int_param.attrib.get('min', None), 316 label=int_param.attrib.get("label", None),
301 max=int_param.attrib.get('max', None))) 317 help=int_param.attrib.get("help", None),
318 min=int_param.attrib.get("min", None),
319 max=int_param.attrib.get("max", None),
320 )
321 )
302 322
303 def _load_float_param(self, root, float_param): 323 def _load_float_param(self, root, float_param):
304 """ 324 """
305 Add <param type="float" /> to the root. 325 Add <param type="float" /> to the root.
306 326
307 :param root: root to append the param to. 327 :param root: root to append the param to.
308 :param float_param: root of <param> tag. 328 :param float_param: root of <param> tag.
309 :type float_param: :class:`xml.etree._Element` 329 :type float_param: :class:`xml.etree._Element`
310 """ 330 """
311 root.append(gxtp.FloatParam(float_param.attrib['name'], 331 root.append(
312 float_param.attrib.get('value', None), 332 gxtp.FloatParam(
313 optional=float_param.attrib.get('optional', None), 333 float_param.attrib["name"],
314 label=float_param.attrib.get('label', None), 334 float_param.attrib.get("value", None),
315 help=float_param.attrib.get('help', None), 335 optional=float_param.attrib.get("optional", None),
316 min=float_param.attrib.get('min', None), 336 label=float_param.attrib.get("label", None),
317 max=float_param.attrib.get('max', None))) 337 help=float_param.attrib.get("help", None),
338 min=float_param.attrib.get("min", None),
339 max=float_param.attrib.get("max", None),
340 )
341 )
318 342
319 def _load_option_select(self, root, option): 343 def _load_option_select(self, root, option):
320 """ 344 """
321 Add <option> to the root (usually <param type="select" />). 345 Add <option> to the root (usually <param type="select" />).
322 346
323 :param root: root to append the param to. 347 :param root: root to append the param to.
324 :param option: root of <option> tag. 348 :param option: root of <option> tag.
325 :type float_param: :class:`xml.etree._Element` 349 :type float_param: :class:`xml.etree._Element`
326 """ 350 """
327 root.append(gxtp.SelectOption(option.attrib.get('value', None), 351 root.append(
328 option.text, 352 gxtp.SelectOption(
329 selected=option.attrib.get('selected', False))) 353 option.attrib.get("value", None),
354 option.text,
355 selected=option.attrib.get("selected", False),
356 )
357 )
330 358
331 def _load_column_options(self, root, column): 359 def _load_column_options(self, root, column):
332 """ 360 """
333 Add <column> to the root (usually <options>). 361 Add <column> to the root (usually <options>).
334 362
335 :param root: root to append the param to. 363 :param root: root to append the param to.
336 :param option: root of <column> tag. 364 :param option: root of <column> tag.
337 :type float_param: :class:`xml.etree._Element` 365 :type float_param: :class:`xml.etree._Element`
338 """ 366 """
339 root.append(gxtp.Column(column.attrib['name'], column.attrib['index'])) 367 root.append(gxtp.Column(column.attrib["name"], column.attrib["index"]))
340 368
341 def _load_filter_options(self, root, filter): 369 def _load_filter_options(self, root, filter):
342 """ 370 """
343 Add <filter> to the root (usually <options>). 371 Add <filter> to the root (usually <options>).
344 372
345 :param root: root to append the param to. 373 :param root: root to append the param to.
346 :param option: root of <filter> tag. 374 :param option: root of <filter> tag.
347 :type float_param: :class:`xml.etree._Element` 375 :type float_param: :class:`xml.etree._Element`
348 """ 376 """
349 root.append(gxtp.Filter(filter.attrib['type'], 377 root.append(
350 column=filter.attrib.get('column', None), 378 gxtp.Filter(
351 name=filter.attrib.get('name', None), 379 filter.attrib["type"],
352 ref=filter.attrib.get('ref', None), 380 column=filter.attrib.get("column", None),
353 key=filter.attrib.get('key', None), 381 name=filter.attrib.get("name", None),
354 multiple=filter.attrib.get('multiple', None), 382 ref=filter.attrib.get("ref", None),
355 separator=filter.attrib.get('separator', None), 383 key=filter.attrib.get("key", None),
356 keep=filter.attrib.get('keep', None), 384 multiple=filter.attrib.get("multiple", None),
357 value=filter.attrib.get('value', None), 385 separator=filter.attrib.get("separator", None),
358 ref_attribute=filter.attrib.get('ref_attribute', None), 386 keep=filter.attrib.get("keep", None),
359 index=filter.attrib.get('index', None))) 387 value=filter.attrib.get("value", None),
388 ref_attribute=filter.attrib.get("ref_attribute", None),
389 index=filter.attrib.get("index", None),
390 )
391 )
360 392
361 def _load_options_select(self, root, options): 393 def _load_options_select(self, root, options):
362 """ 394 """
363 Add <options> to the root (usually <param type="select" />). 395 Add <options> to the root (usually <param type="select" />).
364 396
365 :param root: root to append the param to. 397 :param root: root to append the param to.
366 :param option: root of <options> tag. 398 :param option: root of <options> tag.
367 :type float_param: :class:`xml.etree._Element` 399 :type float_param: :class:`xml.etree._Element`
368 """ 400 """
369 opts = gxtp.Options(from_dataset=options.attrib.get('from_dataset', None), 401 opts = gxtp.Options(
370 from_file=options.attrib.get('from_file', None), 402 from_dataset=options.attrib.get("from_dataset", None),
371 from_data_table=options.attrib.get('from_data_table', None), 403 from_file=options.attrib.get("from_file", None),
372 from_parameter=options.attrib.get('from_parameter', None)) 404 from_data_table=options.attrib.get("from_data_table", None),
405 from_parameter=options.attrib.get("from_parameter", None),
406 )
373 # Deal with child nodes (usually filter and column) 407 # Deal with child nodes (usually filter and column)
374 for opt_child in options: 408 for opt_child in options:
375 try: 409 try:
376 getattr(self, '_load_{}_options'.format(opt_child.tag))(opts, opt_child) 410 getattr(self, "_load_{}_options".format(opt_child.tag))(opts, opt_child)
377 except AttributeError: 411 except AttributeError:
378 logger.warning(opt_child.tag + " tag is not processed for <options>.") 412 logger.warning(opt_child.tag + " tag is not processed for <options>.")
379 root.append(opts) 413 root.append(opts)
380 414
381 def _load_select_param(self, root, sel_param): 415 def _load_select_param(self, root, sel_param):
384 418
385 :param root: root to append the param to. 419 :param root: root to append the param to.
386 :param sel_param: root of <param> tag. 420 :param sel_param: root of <param> tag.
387 :type sel_param: :class:`xml.etree._Element` 421 :type sel_param: :class:`xml.etree._Element`
388 """ 422 """
389 select_param = gxtp.SelectParam(sel_param.attrib['name'], 423 select_param = gxtp.SelectParam(
390 optional=sel_param.attrib.get('optional', None), 424 sel_param.attrib["name"],
391 label=sel_param.attrib.get('label', None), 425 optional=sel_param.attrib.get("optional", None),
392 help=sel_param.attrib.get('help', None), 426 label=sel_param.attrib.get("label", None),
393 data_ref=sel_param.attrib.get('data_ref', None), 427 help=sel_param.attrib.get("help", None),
394 display=sel_param.attrib.get('display', None), 428 data_ref=sel_param.attrib.get("data_ref", None),
395 multiple=sel_param.attrib.get('multiple', None)) 429 display=sel_param.attrib.get("display", None),
430 multiple=sel_param.attrib.get("multiple", None),
431 )
396 # Deal with child nodes (usually option and options) 432 # Deal with child nodes (usually option and options)
397 for sel_child in sel_param: 433 for sel_child in sel_param:
398 try: 434 try:
399 getattr(self, '_load_{}_select'.format(sel_child.tag))(select_param, sel_child) 435 getattr(self, "_load_{}_select".format(sel_child.tag))(
436 select_param, sel_child
437 )
400 except AttributeError: 438 except AttributeError:
401 logger.warning(sel_child.tag + " tag is not processed for <param type='select'>.") 439 logger.warning(
440 sel_child.tag + " tag is not processed for <param type='select'>."
441 )
402 root.append(select_param) 442 root.append(select_param)
403 443
404 def _load_param(self, root, param_root): 444 def _load_param(self, root, param_root):
405 """ 445 """
406 Method to select which type of <param> is being added to the root. 446 Method to select which type of <param> is being added to the root.
407 447
408 :param root: root to attach param to. 448 :param root: root to attach param to.
409 :param param_root: root of <param> tag. 449 :param param_root: root of <param> tag.
410 :type param_root: :class:`xml.etree._Element` 450 :type param_root: :class:`xml.etree._Element`
411 """ 451 """
412 param_type = param_root.attrib['type'] 452 param_type = param_root.attrib["type"]
413 try: 453 try:
414 getattr(self, '_load_{}_param'.format(param_type))(root, param_root) 454 getattr(self, "_load_{}_param".format(param_type))(root, param_root)
415 except AttributeError: 455 except AttributeError:
416 logger.warning(param_type + " tag is not processed for <param>.") 456 logger.warning(param_type + " tag is not processed for <param>.")
417 457
418 def _load_when(self, root, when_root): 458 def _load_when(self, root, when_root):
419 """ 459 """
421 461
422 :param root: root to append when to. 462 :param root: root to append when to.
423 :param when_root: root of <when> tag. 463 :param when_root: root of <when> tag.
424 :type when_root: :class:`xml.etree._Element` 464 :type when_root: :class:`xml.etree._Element`
425 """ 465 """
426 when = gxtp.When(when_root.attrib['value']) 466 when = gxtp.When(when_root.attrib["value"])
427 # Deal with child nodes 467 # Deal with child nodes
428 self.load_inputs(when, when_root) 468 self.load_inputs(when, when_root)
429 root.append(when) 469 root.append(when)
430 470
431 def _load_conditional(self, root, conditional_root): 471 def _load_conditional(self, root, conditional_root):
434 474
435 :param root: root to append conditional to. 475 :param root: root to append conditional to.
436 :param conditional_root: root of <conditional> tag. 476 :param conditional_root: root of <conditional> tag.
437 :type conditional_root: :class:`xml.etree._Element` 477 :type conditional_root: :class:`xml.etree._Element`
438 """ 478 """
439 value_ref_in_group = conditional_root.attrib.get('value_ref_in_group', None) 479 value_ref_in_group = conditional_root.attrib.get("value_ref_in_group", None)
440 # Other optional parameters need to be added to conditional object 480 # Other optional parameters need to be added to conditional object
441 conditional = gxtp.Conditional(conditional_root.attrib['name'], 481 conditional = gxtp.Conditional(
442 value_from=conditional_root.attrib.get('value_from', None), 482 conditional_root.attrib["name"],
443 value_ref=conditional_root.attrib.get('value_ref', None), 483 value_from=conditional_root.attrib.get("value_from", None),
444 value_ref_in_group=value_ref_in_group, 484 value_ref=conditional_root.attrib.get("value_ref", None),
445 label=conditional_root.attrib.get('label', None)) 485 value_ref_in_group=value_ref_in_group,
486 label=conditional_root.attrib.get("label", None),
487 )
446 # Deal with child nodes 488 # Deal with child nodes
447 self.load_inputs(conditional, conditional_root) 489 self.load_inputs(conditional, conditional_root)
448 root.append(conditional) 490 root.append(conditional)
449 491
450 def _load_section(self, root, section_root): 492 def _load_section(self, root, section_root):
453 495
454 :param root: root to append conditional to. 496 :param root: root to append conditional to.
455 :param section_root: root of <section> tag. 497 :param section_root: root of <section> tag.
456 :type section_root: :class:`xml.etree._Element` 498 :type section_root: :class:`xml.etree._Element`
457 """ 499 """
458 section = gxtp.Section(section_root.attrib['name'], 500 section = gxtp.Section(
459 section_root.attrib['title'], 501 section_root.attrib["name"],
460 expanded=section_root.attrib.get('expanded', None), 502 section_root.attrib["title"],
461 help=section_root.attrib.get('help', None)) 503 expanded=section_root.attrib.get("expanded", None),
504 help=section_root.attrib.get("help", None),
505 )
462 # Deal with child nodes 506 # Deal with child nodes
463 self.load_inputs(section, section_root) 507 self.load_inputs(section, section_root)
464 root.append(section) 508 root.append(section)
465 509
466 def _load_repeat(self, root, repeat_root): 510 def _load_repeat(self, root, repeat_root):
469 513
470 :param root: root to append repeat to. 514 :param root: root to append repeat to.
471 :param repeat_root: root of <repeat> tag. 515 :param repeat_root: root of <repeat> tag.
472 :param repeat_root: :class:`xml.etree._Element` 516 :param repeat_root: :class:`xml.etree._Element`
473 """ 517 """
474 repeat = gxtp.Repeat(repeat_root.attrib['name'], 518 repeat = gxtp.Repeat(
475 repeat_root.attrib['title'], 519 repeat_root.attrib["name"],
476 min=repeat_root.attrib.get('min', None), 520 repeat_root.attrib["title"],
477 max=repeat_root.attrib.get('max', None), 521 min=repeat_root.attrib.get("min", None),
478 default=repeat_root.attrib.get('default', None)) 522 max=repeat_root.attrib.get("max", None),
523 default=repeat_root.attrib.get("default", None),
524 )
479 # Deal with child nodes 525 # Deal with child nodes
480 self.load_inputs(repeat, repeat_root) 526 self.load_inputs(repeat, repeat_root)
481 root.append(repeat) 527 root.append(repeat)
482 528
483 def load_inputs(self, root, inputs_root): 529 def load_inputs(self, root, inputs_root):
489 :param inputs_root: root of <inputs> tag. 535 :param inputs_root: root of <inputs> tag.
490 :type inputs_root: :class:`xml.etree._Element` 536 :type inputs_root: :class:`xml.etree._Element`
491 """ 537 """
492 for inp_child in inputs_root: 538 for inp_child in inputs_root:
493 try: 539 try:
494 getattr(self, '_load_{}'.format(inp_child.tag))(root, inp_child) 540 getattr(self, "_load_{}".format(inp_child.tag))(root, inp_child)
495 except AttributeError: 541 except AttributeError:
496 logger.warning(inp_child.tag + " tag is not processed for <" + 542 logger.warning(
497 inputs_root.tag + "> tag.") 543 inp_child.tag
544 + " tag is not processed for <"
545 + inputs_root.tag
546 + "> tag."
547 )
498 548
499 549
500 class OutputsParser(object): 550 class OutputsParser(object):
501 """ 551 """
502 Class to parse content of the <outputs> tag from a Galaxy XML wrapper. 552 Class to parse content of the <outputs> tag from a Galaxy XML wrapper.
508 558
509 :param outputs_root: <outputs> root to append <data> to. 559 :param outputs_root: <outputs> root to append <data> to.
510 :param data_root: root of <data> tag. 560 :param data_root: root of <data> tag.
511 :param data_root: :class:`xml.etree._Element` 561 :param data_root: :class:`xml.etree._Element`
512 """ 562 """
513 data = gxtp.OutputData(data_root.attrib.get('name', None), 563 data = gxtp.OutputData(
514 data_root.attrib.get('format', None), 564 data_root.attrib.get("name", None),
515 format_source=data_root.attrib.get('format_source', None), 565 data_root.attrib.get("format", None),
516 metadata_source=data_root.attrib.get('metadata_source', None), 566 format_source=data_root.attrib.get("format_source", None),
517 label=data_root.attrib.get('label', None), 567 metadata_source=data_root.attrib.get("metadata_source", None),
518 from_work_dir=data_root.attrib.get('from_work_dir', None), 568 label=data_root.attrib.get("label", None),
519 hidden=data_root.attrib.get('hidden', False)) 569 from_work_dir=data_root.attrib.get("from_work_dir", None),
570 hidden=data_root.attrib.get("hidden", False),
571 )
520 # Deal with child nodes 572 # Deal with child nodes
521 for data_child in data_root: 573 for data_child in data_root:
522 try: 574 try:
523 getattr(self, '_load_{}'.format(data_child.tag))(data, data_child) 575 getattr(self, "_load_{}".format(data_child.tag))(data, data_child)
524 except AttributeError: 576 except AttributeError:
525 logger.warning(data_child.tag + " tag is not processed for <data>.") 577 logger.warning(data_child.tag + " tag is not processed for <data>.")
526 outputs_root.append(data) 578 outputs_root.append(data)
527 579
528 def _load_change_format(self, root, chfmt_root): 580 def _load_change_format(self, root, chfmt_root):
533 :param chfm_root: root of <change_format> tag. 585 :param chfm_root: root of <change_format> tag.
534 :param chfm_root: :class:`xml.etree._Element` 586 :param chfm_root: :class:`xml.etree._Element`
535 """ 587 """
536 change_format = gxtp.ChangeFormat() 588 change_format = gxtp.ChangeFormat()
537 for chfmt_child in chfmt_root: 589 for chfmt_child in chfmt_root:
538 change_format.append(gxtp.ChangeFormatWhen(chfmt_child.attrib['input'], 590 change_format.append(
539 chfmt_child.attrib['format'], 591 gxtp.ChangeFormatWhen(
540 chfmt_child.attrib['value'])) 592 chfmt_child.attrib["input"],
593 chfmt_child.attrib["format"],
594 chfmt_child.attrib["value"],
595 )
596 )
541 root.append(change_format) 597 root.append(change_format)
542 598
543 def _load_collection(self, outputs_root, coll_root): 599 def _load_collection(self, outputs_root, coll_root):
544 """ 600 """
545 Add <collection> to <outputs>. 601 Add <collection> to <outputs>.
546 602
547 :param outputs_root: <outputs> root to append <collection> to. 603 :param outputs_root: <outputs> root to append <collection> to.
548 :param coll_root: root of <collection> tag. 604 :param coll_root: root of <collection> tag.
549 :param coll_root: :class:`xml.etree._Element` 605 :param coll_root: :class:`xml.etree._Element`
550 """ 606 """
551 collection = gxtp.OutputCollection(coll_root.attrib['name'], 607 collection = gxtp.OutputCollection(
552 type=coll_root.attrib.get('type', None), 608 coll_root.attrib["name"],
553 label=coll_root.attrib.get('label', None), 609 type=coll_root.attrib.get("type", None),
554 format_source=coll_root.attrib.get('format_source', 610 label=coll_root.attrib.get("label", None),
555 None), 611 format_source=coll_root.attrib.get("format_source", None),
556 type_source=coll_root.attrib.get('type_source', None), 612 type_source=coll_root.attrib.get("type_source", None),
557 structured_like=coll_root.attrib.get('structured_like', 613 structured_like=coll_root.attrib.get("structured_like", None),
558 None), 614 inherit_format=coll_root.attrib.get("inherit_format", None),
559 inherit_format=coll_root.attrib.get('inherit_format', 615 )
560 None))
561 # Deal with child nodes 616 # Deal with child nodes
562 for coll_child in coll_root: 617 for coll_child in coll_root:
563 try: 618 try:
564 getattr(self, '_load_{}'.format(coll_child.tag))(collection, coll_child) 619 getattr(self, "_load_{}".format(coll_child.tag))(collection, coll_child)
565 except AttributeError: 620 except AttributeError:
566 logger.warning(coll_child.tag + " tag is not processed for <collection>.") 621 logger.warning(
622 coll_child.tag + " tag is not processed for <collection>."
623 )
567 outputs_root.append(collection) 624 outputs_root.append(collection)
568 625
569 def _load_discover_datasets(self, root, disc_root): 626 def _load_discover_datasets(self, root, disc_root):
570 """ 627 """
571 Add <discover_datasets> to root (<collection>). 628 Add <discover_datasets> to root (<collection>).
572 629
573 :param root: root to append <collection> to. 630 :param root: root to append <collection> to.
574 :param disc_root: root of <discover_datasets> tag. 631 :param disc_root: root of <discover_datasets> tag.
575 :param disc_root: :class:`xml.etree._Element` 632 :param disc_root: :class:`xml.etree._Element`
576 """ 633 """
577 root.append(gxtp.DiscoverDatasets(disc_root.attrib['pattern'], 634 root.append(
578 directory=disc_root.attrib.get('directory', None), 635 gxtp.DiscoverDatasets(
579 format=disc_root.attrib.get('format', None), 636 disc_root.attrib["pattern"],
580 ext=disc_root.attrib.get('ext', None), 637 directory=disc_root.attrib.get("directory", None),
581 visible=disc_root.attrib.get('visible', None))) 638 format=disc_root.attrib.get("format", None),
639 ext=disc_root.attrib.get("ext", None),
640 visible=disc_root.attrib.get("visible", None),
641 )
642 )
582 643
583 def _load_filter(self, root, filter_root): 644 def _load_filter(self, root, filter_root):
584 """ 645 """
585 Add <filter> to root (<collection> or <data>). 646 Add <filter> to root (<collection> or <data>).
586 647
598 :param tests_root: root of <outputs> tag. 659 :param tests_root: root of <outputs> tag.
599 :type tests_root: :class:`xml.etree._Element` 660 :type tests_root: :class:`xml.etree._Element`
600 """ 661 """
601 for out_child in outputs_root: 662 for out_child in outputs_root:
602 try: 663 try:
603 getattr(self, '_load_{}'.format(out_child.tag))(root, out_child) 664 getattr(self, "_load_{}".format(out_child.tag))(root, out_child)
604 except AttributeError: 665 except AttributeError:
605 logger.warning(out_child.tag + " tag is not processed for <outputs>.") 666 logger.warning(out_child.tag + " tag is not processed for <outputs>.")
606 667
607 668
608 class TestsParser(object): 669 class TestsParser(object):
616 677
617 :param root: <test> root to append <param> to. 678 :param root: <test> root to append <param> to.
618 :param repeat_root: root of <param> tag. 679 :param repeat_root: root of <param> tag.
619 :param repeat_root: :class:`xml.etree._Element` 680 :param repeat_root: :class:`xml.etree._Element`
620 """ 681 """
621 test_root.append(gxtp.TestParam(param_root.attrib['name'], 682 test_root.append(
622 value=param_root.attrib.get('value', None), 683 gxtp.TestParam(
623 ftype=param_root.attrib.get('ftype', None), 684 param_root.attrib["name"],
624 dbkey=param_root.attrib.get('dbkey', None))) 685 value=param_root.attrib.get("value", None),
686 ftype=param_root.attrib.get("ftype", None),
687 dbkey=param_root.attrib.get("dbkey", None),
688 )
689 )
625 690
626 def _load_output(self, test_root, output_root): 691 def _load_output(self, test_root, output_root):
627 """ 692 """
628 Add <output> to the <test>. 693 Add <output> to the <test>.
629 694
630 :param root: <test> root to append <output> to. 695 :param root: <test> root to append <output> to.
631 :param repeat_root: root of <output> tag. 696 :param repeat_root: root of <output> tag.
632 :param repeat_root: :class:`xml.etree._Element` 697 :param repeat_root: :class:`xml.etree._Element`
633 """ 698 """
634 test_root.append(gxtp.TestOutput(name=output_root.attrib.get('name', None), 699 test_root.append(
635 file=output_root.attrib.get('file', None), 700 gxtp.TestOutput(
636 ftype=output_root.attrib.get('ftype', None), 701 name=output_root.attrib.get("name", None),
637 sort=output_root.attrib.get('sort', None), 702 file=output_root.attrib.get("file", None),
638 value=output_root.attrib.get('value', None), 703 ftype=output_root.attrib.get("ftype", None),
639 md5=output_root.attrib.get('md5', None), 704 sort=output_root.attrib.get("sort", None),
640 checksum=output_root.attrib.get('checksum', None), 705 value=output_root.attrib.get("value", None),
641 compare=output_root.attrib.get('compare', None), 706 md5=output_root.attrib.get("md5", None),
642 lines_diff=output_root.attrib.get('lines_diff', None), 707 checksum=output_root.attrib.get("checksum", None),
643 delta=output_root.attrib.get('delta', None))) 708 compare=output_root.attrib.get("compare", None),
709 lines_diff=output_root.attrib.get("lines_diff", None),
710 delta=output_root.attrib.get("delta", None),
711 )
712 )
644 713
645 def load_tests(self, root, tests_root): 714 def load_tests(self, root, tests_root):
646 """ 715 """
647 Add <tests> to the root. 716 Add <tests> to the root.
648 717
652 """ 721 """
653 for test_root in tests_root: 722 for test_root in tests_root:
654 test = gxtp.Test() 723 test = gxtp.Test()
655 for test_child in test_root: 724 for test_child in test_root:
656 try: 725 try:
657 getattr(self, '_load_{}'.format(test_child.tag))(test, test_child) 726 getattr(self, "_load_{}".format(test_child.tag))(test, test_child)
658 except AttributeError: 727 except AttributeError:
659 logger.warning(test_child.tag + " tag is not processed within <test>.") 728 logger.warning(
729 test_child.tag + " tag is not processed within <test>."
730 )
660 root.append(test) 731 root.append(test)