Mercurial > repos > fubar > tool_factory_2
comparison toolfactory/galaxyxml/tool/__init__.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 copy | 1 import copy |
2 import logging | 2 import logging |
3 | |
4 from galaxyxml import GalaxyXML, Util | |
5 from galaxyxml.tool.parameters import XMLParam | |
6 | |
3 from lxml import etree | 7 from lxml import etree |
4 from galaxyxml import Util, GalaxyXML | |
5 from galaxyxml.tool.parameters import XMLParam | |
6 | 8 |
7 VALID_TOOL_TYPES = ("data_source", "data_source_async") | 9 VALID_TOOL_TYPES = ("data_source", "data_source_async") |
8 VALID_URL_METHODS = ("get", "post") | 10 VALID_URL_METHODS = ("get", "post") |
9 | 11 |
10 logging.basicConfig(level=logging.INFO) | 12 logging.basicConfig(level=logging.INFO) |
11 logger = logging.getLogger(__name__) | 13 logger = logging.getLogger(__name__) |
12 | 14 |
13 | 15 |
14 class Tool(GalaxyXML): | 16 class Tool(GalaxyXML): |
17 | |
15 def __init__( | 18 def __init__( |
16 self, | 19 self, |
17 name, | 20 name, |
18 id, | 21 id, |
19 version, | 22 version, |
49 kwargs = Util.coerce(kwargs) | 52 kwargs = Util.coerce(kwargs) |
50 self.root = etree.Element("tool", **kwargs) | 53 self.root = etree.Element("tool", **kwargs) |
51 | 54 |
52 if tool_type is not None: | 55 if tool_type is not None: |
53 if tool_type not in VALID_TOOL_TYPES: | 56 if tool_type not in VALID_TOOL_TYPES: |
54 raise Exception( | 57 raise Exception("Tool type must be one of %s" % ",".join(VALID_TOOL_TYPES)) |
55 "Tool type must be one of %s" % ",".join(VALID_TOOL_TYPES) | |
56 ) | |
57 else: | 58 else: |
58 kwargs["tool_type"] = tool_type | 59 kwargs["tool_type"] = tool_type |
59 | 60 |
60 if URL_method is not None: | 61 if URL_method is not None: |
61 if URL_method in VALID_URL_METHODS: | 62 if URL_method in VALID_URL_METHODS: |
62 kwargs["URL_method"] = URL_method | 63 kwargs["URL_method"] = URL_method |
63 else: | 64 else: |
64 raise Exception( | 65 raise Exception("URL_method must be one of %s" % ",".join(VALID_URL_METHODS)) |
65 "URL_method must be one of %s" % ",".join(VALID_URL_METHODS) | |
66 ) | |
67 | 66 |
68 description_node = etree.SubElement(self.root, "description") | 67 description_node = etree.SubElement(self.root, "description") |
69 description_node.text = description | 68 description_node.text = description |
70 | 69 |
71 def add_comment(self, comment_txt): | 70 def add_comment(self, comment_txt): |
148 | 147 |
149 if keep_old_command: | 148 if keep_old_command: |
150 if getattr(self, "command", None): | 149 if getattr(self, "command", None): |
151 command_node.text = etree.CDATA(export_xml.command) | 150 command_node.text = etree.CDATA(export_xml.command) |
152 else: | 151 else: |
153 logger.warning( | 152 logger.warning("The tool does not have any old command stored. " + "Only the command line is written.") |
154 "The tool does not have any old command stored. " | |
155 + "Only the command line is written." | |
156 ) | |
157 command_node.text = export_xml.executable | 153 command_node.text = export_xml.executable |
158 else: | 154 else: |
159 actual_cli = "%s %s" % ( | 155 actual_cli = "%s %s" % (export_xml.executable, export_xml.clean_command_string(command_line)) |
160 export_xml.executable, | |
161 export_xml.clean_command_string(command_line), | |
162 ) | |
163 command_node.text = etree.CDATA(actual_cli.strip()) | 156 command_node.text = etree.CDATA(actual_cli.strip()) |
164 | 157 |
165 try: | 158 try: |
166 export_xml.append(export_xml.inputs) | 159 export_xml.append(export_xml.inputs) |
167 except Exception: | 160 except Exception: |