comparison toolfactory/galaxyxml/tool/import_xml.py @ 38:a30536c100bf draft

Updated history outputs
author fubar
date Wed, 12 Aug 2020 01:43:46 -0400
parents ce2b1f8ea68d
children
comparison
equal deleted inserted replaced
37:099047ee7094 38:a30536c100bf
1 import logging 1 import logging
2 import xml.etree.ElementTree as ET 2 import xml.etree.ElementTree as ET
3
3 import galaxyxml.tool as gxt 4 import galaxyxml.tool as gxt
4 import galaxyxml.tool.parameters as gxtp 5 import galaxyxml.tool.parameters as gxtp
5 6
6 logging.basicConfig(level=logging.INFO) 7 logging.basicConfig(level=logging.INFO)
7 logger = logging.getLogger(__name__) 8 logger = logging.getLogger(__name__)
113 for req in requirements_root: 114 for req in requirements_root:
114 req_type = req.attrib["type"] 115 req_type = req.attrib["type"]
115 value = req.text 116 value = req.text
116 if req.tag == "requirement": 117 if req.tag == "requirement":
117 version = req.attrib.get("version", None) 118 version = req.attrib.get("version", None)
118 tool.requirements.append( 119 tool.requirements.append(gxtp.Requirement(req_type, value, version=version))
119 gxtp.Requirement(req_type, value, version=version)
120 )
121 elif req.tag == "container": 120 elif req.tag == "container":
122 tool.requirements.append(gxtp.Container(req_type, value)) 121 tool.requirements.append(gxtp.Container(req_type, value))
123 else: 122 else:
124 logger.warning(req.tag + " is not a valid tag for requirements child") 123 logger.warning(req.tag + " is not a valid tag for requirements child")
125 124
348 :param option: root of <option> tag. 347 :param option: root of <option> tag.
349 :type float_param: :class:`xml.etree._Element` 348 :type float_param: :class:`xml.etree._Element`
350 """ 349 """
351 root.append( 350 root.append(
352 gxtp.SelectOption( 351 gxtp.SelectOption(
353 option.attrib.get("value", None), 352 option.attrib.get("value", None), option.text, selected=option.attrib.get("selected", False)
354 option.text,
355 selected=option.attrib.get("selected", False),
356 ) 353 )
357 ) 354 )
358 355
359 def _load_column_options(self, root, column): 356 def _load_column_options(self, root, column):
360 """ 357 """
430 multiple=sel_param.attrib.get("multiple", None), 427 multiple=sel_param.attrib.get("multiple", None),
431 ) 428 )
432 # Deal with child nodes (usually option and options) 429 # Deal with child nodes (usually option and options)
433 for sel_child in sel_param: 430 for sel_child in sel_param:
434 try: 431 try:
435 getattr(self, "_load_{}_select".format(sel_child.tag))( 432 getattr(self, "_load_{}_select".format(sel_child.tag))(select_param, sel_child)
436 select_param, sel_child
437 )
438 except AttributeError: 433 except AttributeError:
439 logger.warning( 434 logger.warning(sel_child.tag + " tag is not processed for <param type='select'>.")
440 sel_child.tag + " tag is not processed for <param type='select'>."
441 )
442 root.append(select_param) 435 root.append(select_param)
443 436
444 def _load_param(self, root, param_root): 437 def _load_param(self, root, param_root):
445 """ 438 """
446 Method to select which type of <param> is being added to the root. 439 Method to select which type of <param> is being added to the root.
537 """ 530 """
538 for inp_child in inputs_root: 531 for inp_child in inputs_root:
539 try: 532 try:
540 getattr(self, "_load_{}".format(inp_child.tag))(root, inp_child) 533 getattr(self, "_load_{}".format(inp_child.tag))(root, inp_child)
541 except AttributeError: 534 except AttributeError:
542 logger.warning( 535 logger.warning(inp_child.tag + " tag is not processed for <" + inputs_root.tag + "> tag.")
543 inp_child.tag
544 + " tag is not processed for <"
545 + inputs_root.tag
546 + "> tag."
547 )
548 536
549 537
550 class OutputsParser(object): 538 class OutputsParser(object):
551 """ 539 """
552 Class to parse content of the <outputs> tag from a Galaxy XML wrapper. 540 Class to parse content of the <outputs> tag from a Galaxy XML wrapper.
587 """ 575 """
588 change_format = gxtp.ChangeFormat() 576 change_format = gxtp.ChangeFormat()
589 for chfmt_child in chfmt_root: 577 for chfmt_child in chfmt_root:
590 change_format.append( 578 change_format.append(
591 gxtp.ChangeFormatWhen( 579 gxtp.ChangeFormatWhen(
592 chfmt_child.attrib["input"], 580 chfmt_child.attrib["input"], chfmt_child.attrib["format"], chfmt_child.attrib["value"]
593 chfmt_child.attrib["format"],
594 chfmt_child.attrib["value"],
595 ) 581 )
596 ) 582 )
597 root.append(change_format) 583 root.append(change_format)
598 584
599 def _load_collection(self, outputs_root, coll_root): 585 def _load_collection(self, outputs_root, coll_root):
616 # Deal with child nodes 602 # Deal with child nodes
617 for coll_child in coll_root: 603 for coll_child in coll_root:
618 try: 604 try:
619 getattr(self, "_load_{}".format(coll_child.tag))(collection, coll_child) 605 getattr(self, "_load_{}".format(coll_child.tag))(collection, coll_child)
620 except AttributeError: 606 except AttributeError:
621 logger.warning( 607 logger.warning(coll_child.tag + " tag is not processed for <collection>.")
622 coll_child.tag + " tag is not processed for <collection>."
623 )
624 outputs_root.append(collection) 608 outputs_root.append(collection)
625 609
626 def _load_discover_datasets(self, root, disc_root): 610 def _load_discover_datasets(self, root, disc_root):
627 """ 611 """
628 Add <discover_datasets> to root (<collection>). 612 Add <discover_datasets> to root (<collection>).
723 test = gxtp.Test() 707 test = gxtp.Test()
724 for test_child in test_root: 708 for test_child in test_root:
725 try: 709 try:
726 getattr(self, "_load_{}".format(test_child.tag))(test, test_child) 710 getattr(self, "_load_{}".format(test_child.tag))(test, test_child)
727 except AttributeError: 711 except AttributeError:
728 logger.warning( 712 logger.warning(test_child.tag + " tag is not processed within <test>.")
729 test_child.tag + " tag is not processed within <test>."
730 )
731 root.append(test) 713 root.append(test)