Mercurial > repos > fubar > tool_factory_2
annotate toolfactory/galaxyxml/tool/parameters/__init__.py @ 36:ce2b1f8ea68d draft
passes flake8 tests finally :)
author | fubar |
---|---|
date | Mon, 10 Aug 2020 23:24:41 -0400 |
parents | 5d38cb3d9be8 |
children | a30536c100bf |
rev | line source |
---|---|
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
1 from builtins import str |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
2 from builtins import object |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
3 from lxml import etree |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
4 from galaxyxml import Util |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
5 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
6 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
7 class XMLParam(object): |
36 | 8 name = "node" |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
9 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
10 def __init__(self, *args, **kwargs): |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
11 # http://stackoverflow.com/a/12118700 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
12 self.children = [] |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
13 kwargs = {k: v for k, v in list(kwargs.items()) if v is not None} |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
14 kwargs = Util.coerce(kwargs, kill_lists=True) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
15 kwargs = Util.clean_kwargs(kwargs, final=True) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
16 self.node = etree.Element(self.name, **kwargs) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
17 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
18 def append(self, sub_node): |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
19 if self.acceptable_child(sub_node): |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
20 # If one of ours, they aren't etree nodes, they're custom objects |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
21 if issubclass(type(sub_node), XMLParam): |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
22 self.node.append(sub_node.node) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
23 self.children.append(sub_node) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
24 else: |
36 | 25 raise Exception( |
26 "Child was unacceptable to parent (%s is not appropriate for %s)" | |
27 % (type(self), type(sub_node)) | |
28 ) | |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
29 else: |
36 | 30 raise Exception( |
31 "Child was unacceptable to parent (%s is not appropriate for %s)" | |
32 % (type(self), type(sub_node)) | |
33 ) | |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
34 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
35 def validate(self): |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
36 # Very few need validation, but some nodes we may want to have |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
37 # validation routines on. Should only be called when DONE. |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
38 for child in self.children: |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
39 # If any child fails to validate return false. |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
40 if not child.validate(): |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
41 return False |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
42 return True |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
43 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
44 def cli(self): |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
45 lines = [] |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
46 for child in self.children: |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
47 lines.append(child.command_line()) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
48 # lines += child.command_line() |
36 | 49 return "\n".join(lines) |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
50 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
51 def command_line(self): |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
52 return None |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
53 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
54 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
55 class RequestParamTranslation(XMLParam): |
36 | 56 name = "request_param_translation" |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
57 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
58 def __init__(self, **kwargs): |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
59 self.node = etree.Element(self.name) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
60 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
61 def acceptable_child(self, child): |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
62 return isinstance(child, RequestParamTranslation) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
63 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
64 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
65 class RequestParam(XMLParam): |
36 | 66 name = "request_param" |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
67 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
68 def __init__(self, galaxy_name, remote_name, missing, **kwargs): |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
69 # TODO: bulk copy locals into self.attr? |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
70 self.galaxy_name = galaxy_name |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
71 # http://stackoverflow.com/a/1408860 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
72 params = Util.clean_kwargs(locals().copy()) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
73 super(RequestParam, self).__init__(**params) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
74 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
75 def acceptable_child(self, child): |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
76 return isinstance(child, AppendParam) and self.galaxy_name == "URL" |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
77 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
78 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
79 class AppendParam(XMLParam): |
36 | 80 name = "append_param" |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
81 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
82 def __init__(self, separator="&", first_separator="?", join="=", **kwargs): |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
83 params = Util.clean_kwargs(locals().copy()) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
84 super(AppendParam, self).__init__(**params) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
85 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
86 def acceptable_child(self, child): |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
87 return isinstance(child, AppendParamValue) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
88 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
89 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
90 class AppendParamValue(XMLParam): |
36 | 91 name = "value" |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
92 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
93 def __init__(self, name="_export", missing="1", **kwargs): |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
94 params = Util.clean_kwargs(locals().copy()) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
95 super(AppendParamValue, self).__init__(**params) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
96 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
97 def acceptable_child(self, child): |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
98 return False |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
99 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
100 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
101 class EdamOperations(XMLParam): |
36 | 102 name = "edam_operations" |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
103 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
104 def acceptable_child(self, child): |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
105 return issubclass(type(child), EdamOperation) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
106 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
107 def has_operation(self, edam_operation): |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
108 """ |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
109 Check the presence of a given edam_operation. |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
110 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
111 :type edam_operation: STRING |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
112 """ |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
113 for operation in self.children: |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
114 if operation.node.text == edam_operation: |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
115 return True |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
116 return False |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
117 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
118 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
119 class EdamOperation(XMLParam): |
36 | 120 name = "edam_operation" |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
121 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
122 def __init__(self, value): |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
123 super(EdamOperation, self).__init__() |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
124 self.node.text = str(value) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
125 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
126 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
127 class EdamTopics(XMLParam): |
36 | 128 name = "edam_topics" |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
129 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
130 def acceptable_child(self, child): |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
131 return issubclass(type(child), EdamTopic) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
132 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
133 def has_topic(self, edam_topic): |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
134 """ |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
135 Check the presence of a given edam_topic. |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
136 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
137 :type edam_topic: STRING |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
138 """ |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
139 for topic in self.children: |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
140 if topic.node.text == edam_topic: |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
141 return True |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
142 return False |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
143 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
144 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
145 class EdamTopic(XMLParam): |
36 | 146 name = "edam_topic" |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
147 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
148 def __init__(self, value): |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
149 super(EdamTopic, self).__init__() |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
150 self.node.text = str(value) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
151 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
152 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
153 class Requirements(XMLParam): |
36 | 154 name = "requirements" |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
155 # This bodes to be an issue -__- |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
156 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
157 def acceptable_child(self, child): |
36 | 158 return issubclass(type(child), Requirement) or issubclass( |
159 type(child), Container | |
160 ) | |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
161 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
162 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
163 class Requirement(XMLParam): |
36 | 164 name = "requirement" |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
165 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
166 def __init__(self, type, value, version=None, **kwargs): |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
167 params = Util.clean_kwargs(locals().copy()) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
168 passed_kwargs = {} |
36 | 169 passed_kwargs["version"] = params["version"] |
170 passed_kwargs["type"] = params["type"] | |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
171 super(Requirement, self).__init__(**passed_kwargs) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
172 self.node.text = str(value) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
173 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
174 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
175 class Container(XMLParam): |
36 | 176 name = "container" |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
177 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
178 def __init__(self, type, value, **kwargs): |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
179 params = Util.clean_kwargs(locals().copy()) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
180 passed_kwargs = {} |
36 | 181 passed_kwargs["type"] = params["type"] |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
182 super(Container, self).__init__(**passed_kwargs) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
183 self.node.text = str(value) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
184 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
185 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
186 class Configfiles(XMLParam): |
36 | 187 name = "configfiles" |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
188 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
189 def acceptable_child(self, child): |
36 | 190 return issubclass(type(child), Configfile) or issubclass( |
191 type(child), ConfigfileDefaultInputs | |
192 ) | |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
193 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
194 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
195 class Configfile(XMLParam): |
36 | 196 name = "configfile" |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
197 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
198 def __init__(self, name, text, **kwargs): |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
199 params = Util.clean_kwargs(locals().copy()) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
200 passed_kwargs = {} |
36 | 201 passed_kwargs["name"] = params["name"] |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
202 super(Configfile, self).__init__(**passed_kwargs) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
203 self.node.text = etree.CDATA(str(text)) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
204 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
205 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
206 class ConfigfileDefaultInputs(XMLParam): |
36 | 207 name = "inputs" |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
208 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
209 def __init__(self, name, **kwargs): |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
210 params = Util.clean_kwargs(locals().copy()) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
211 passed_kwargs = {} |
36 | 212 passed_kwargs["name"] = params["name"] |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
213 super(ConfigfileDefaultInputs, self).__init__(**passed_kwargs) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
214 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
215 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
216 class Inputs(XMLParam): |
36 | 217 name = "inputs" |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
218 # This bodes to be an issue -__- |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
219 |
36 | 220 def __init__( |
221 self, | |
222 action=None, | |
223 check_value=None, | |
224 method=None, | |
225 target=None, | |
226 nginx_upload=None, | |
227 **kwargs, | |
228 ): | |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
229 params = Util.clean_kwargs(locals().copy()) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
230 super(Inputs, self).__init__(**params) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
231 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
232 def acceptable_child(self, child): |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
233 return issubclass(type(child), InputParameter) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
234 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
235 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
236 class InputParameter(XMLParam): |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
237 def __init__(self, name, **kwargs): |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
238 # TODO: look at |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
239 self.mako_identifier = name |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
240 # We use kwargs instead of the usual locals(), so manually copy the |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
241 # name to kwargs |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
242 if name is not None: |
36 | 243 kwargs["name"] = name |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
244 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
245 # Handle positional parameters |
36 | 246 if "positional" in kwargs and kwargs["positional"]: |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
247 self.positional = True |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
248 else: |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
249 self.positional = False |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
250 |
36 | 251 if "num_dashes" in kwargs: |
252 self.num_dashes = kwargs["num_dashes"] | |
253 del kwargs["num_dashes"] | |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
254 else: |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
255 self.num_dashes = 0 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
256 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
257 self.space_between_arg = " " |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
258 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
259 # Not sure about this :( |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
260 # https://wiki.galaxyproject.org/Tools/BestPractices#Parameter_help |
36 | 261 if "label" in kwargs: |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
262 # TODO: replace with positional attribute |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
263 if len(self.flag()) > 0: |
36 | 264 if kwargs["label"] is None: |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
265 kwargs[ |
36 | 266 "label" |
267 ] = "Author did not provide help for this parameter... " | |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
268 if not self.positional: |
36 | 269 kwargs["argument"] = self.flag() |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
270 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
271 super(InputParameter, self).__init__(**kwargs) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
272 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
273 def command_line(self): |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
274 before = self.command_line_before() |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
275 cli = self.command_line_actual() |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
276 after = self.command_line_after() |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
277 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
278 complete = [x for x in (before, cli, after) if x is not None] |
36 | 279 return "\n".join(complete) |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
280 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
281 def command_line_before(self): |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
282 try: |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
283 return self.command_line_before_override |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
284 except Exception: |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
285 return None |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
286 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
287 def command_line_after(self): |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
288 try: |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
289 return self.command_line_after_override |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
290 except Exception: |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
291 return None |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
292 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
293 def command_line_actual(self): |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
294 try: |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
295 return self.command_line_override |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
296 except Exception: |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
297 if self.positional: |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
298 return self.mako_name() |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
299 else: |
36 | 300 return "%s%s%s" % ( |
301 self.flag(), | |
302 self.space_between_arg, | |
303 self.mako_name(), | |
304 ) | |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
305 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
306 def mako_name(self): |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
307 # TODO: enhance logic to check up parents for things like |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
308 # repeat>condotion>param |
36 | 309 return "$" + self.mako_identifier |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
310 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
311 def flag(self): |
36 | 312 flag = "-" * self.num_dashes |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
313 return flag + self.mako_identifier |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
314 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
315 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
316 class Section(InputParameter): |
36 | 317 name = "section" |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
318 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
319 def __init__(self, name, title, expanded=None, help=None, **kwargs): |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
320 params = Util.clean_kwargs(locals().copy()) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
321 super(Section, self).__init__(**params) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
322 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
323 def acceptable_child(self, child): |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
324 return issubclass(type(child), InputParameter) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
325 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
326 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
327 class Repeat(InputParameter): |
36 | 328 name = "repeat" |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
329 |
36 | 330 def __init__(self, name, title, min=None, max=None, default=None, **kwargs): |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
331 params = Util.clean_kwargs(locals().copy()) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
332 # Allow overriding |
36 | 333 self.command_line_before_override = "#for $i in $%s:" % name |
334 self.command_line_after_override = "#end for" | |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
335 # self.command_line_override |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
336 super(Repeat, self).__init__(**params) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
337 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
338 def acceptable_child(self, child): |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
339 return issubclass(type(child), InputParameter) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
340 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
341 def command_line_actual(self): |
36 | 342 if hasattr(self, "command_line_override"): |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
343 return self.command_line_override |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
344 else: |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
345 return "%s" % self.mako_name() |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
346 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
347 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
348 class Conditional(InputParameter): |
36 | 349 name = "conditional" |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
350 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
351 def __init__(self, name, **kwargs): |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
352 params = Util.clean_kwargs(locals().copy()) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
353 super(Conditional, self).__init__(**params) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
354 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
355 def acceptable_child(self, child): |
36 | 356 return issubclass(type(child), InputParameter) and not isinstance( |
357 child, Conditional | |
358 ) | |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
359 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
360 def validate(self): |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
361 # Find a way to check if one of the kids is a WHEN |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
362 pass |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
363 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
364 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
365 class When(InputParameter): |
36 | 366 name = "when" |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
367 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
368 def __init__(self, value): |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
369 params = Util.clean_kwargs(locals().copy()) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
370 super(When, self).__init__(None, **params) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
371 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
372 def acceptable_child(self, child): |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
373 return issubclass(type(child), InputParameter) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
374 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
375 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
376 class Param(InputParameter): |
36 | 377 name = "param" |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
378 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
379 # This...isn't really valid as-is, and shouldn't be used. |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
380 def __init__(self, name, optional=None, label=None, help=None, **kwargs): |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
381 params = Util.clean_kwargs(locals().copy()) |
36 | 382 params["type"] = self.type |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
383 super(Param, self).__init__(**params) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
384 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
385 if type(self) == Param: |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
386 raise Exception( |
36 | 387 "Param class is not an actual parameter type, use a subclass of Param" |
388 ) | |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
389 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
390 def acceptable_child(self, child): |
36 | 391 return issubclass( |
392 type(child, InputParameter) or isinstance(child), ValidatorParam | |
393 ) | |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
394 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
395 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
396 class TextParam(Param): |
36 | 397 type = "text" |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
398 |
36 | 399 def __init__( |
400 self, name, optional=None, label=None, help=None, value=None, **kwargs | |
401 ): | |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
402 params = Util.clean_kwargs(locals().copy()) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
403 super(TextParam, self).__init__(**params) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
404 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
405 def command_line_actual(self): |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
406 try: |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
407 return self.command_line_override |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
408 except Exception: |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
409 if self.positional: |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
410 return self.mako_name() |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
411 else: |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
412 return f"{self.flag}{self.space_between_arg}'{self.mako_name()}'" |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
413 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
414 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
415 class _NumericParam(Param): |
36 | 416 def __init__( |
417 self, | |
418 name, | |
419 value, | |
420 optional=None, | |
421 label=None, | |
422 help=None, | |
423 min=None, | |
424 max=None, | |
425 **kwargs, | |
426 ): | |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
427 params = Util.clean_kwargs(locals().copy()) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
428 super(_NumericParam, self).__init__(**params) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
429 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
430 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
431 class IntegerParam(_NumericParam): |
36 | 432 type = "integer" |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
433 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
434 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
435 class FloatParam(_NumericParam): |
36 | 436 type = "float" |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
437 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
438 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
439 class BooleanParam(Param): |
36 | 440 type = "boolean" |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
441 |
36 | 442 def __init__( |
443 self, | |
444 name, | |
445 optional=None, | |
446 label=None, | |
447 help=None, | |
448 checked=False, | |
449 truevalue=None, | |
450 falsevalue=None, | |
451 **kwargs, | |
452 ): | |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
453 params = Util.clean_kwargs(locals().copy()) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
454 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
455 super(BooleanParam, self).__init__(**params) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
456 if truevalue is None: |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
457 # If truevalue and falsevalue are None, then we use "auto", the IUC |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
458 # recommended default. |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
459 # |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
460 # truevalue is set to the parameter's value, and falsevalue is not. |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
461 # |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
462 # Unfortunately, mako_identifier is set as a result of the super |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
463 # call, which we shouldn't call TWICE, so we'll just hack around this :( |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
464 # params['truevalue'] = '%s%s' % (self.) |
36 | 465 self.node.attrib["truevalue"] = self.flag() |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
466 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
467 if falsevalue is None: |
36 | 468 self.node.attrib["falsevalue"] = "" |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
469 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
470 def command_line_actual(self): |
36 | 471 if hasattr(self, "command_line_override"): |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
472 return self.command_line_override |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
473 else: |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
474 return "%s" % self.mako_name() |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
475 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
476 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
477 class DataParam(Param): |
36 | 478 type = "data" |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
479 |
36 | 480 def __init__( |
481 self, | |
482 name, | |
483 optional=None, | |
484 label=None, | |
485 help=None, | |
486 format=None, | |
487 multiple=None, | |
488 **kwargs, | |
489 ): | |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
490 params = Util.clean_kwargs(locals().copy()) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
491 super(DataParam, self).__init__(**params) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
492 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
493 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
494 class SelectParam(Param): |
36 | 495 type = "select" |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
496 |
36 | 497 def __init__( |
498 self, | |
499 name, | |
500 optional=None, | |
501 label=None, | |
502 help=None, | |
503 data_ref=None, | |
504 display=None, | |
505 multiple=None, | |
506 options=None, | |
507 default=None, | |
508 **kwargs, | |
509 ): | |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
510 params = Util.clean_kwargs(locals().copy()) |
36 | 511 del params["options"] |
512 del params["default"] | |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
513 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
514 super(SelectParam, self).__init__(**params) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
515 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
516 if options is not None and default is not None: |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
517 if default not in options: |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
518 raise Exception("Specified a default that isn't in options") |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
519 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
520 if options: |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
521 for k, v in list(sorted(options.items())): |
36 | 522 selected = k == default |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
523 self.append(SelectOption(k, v, selected=selected)) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
524 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
525 def acceptable_child(self, child): |
36 | 526 return issubclass(type(child), SelectOption) or issubclass(type(child), Options) |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
527 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
528 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
529 class SelectOption(InputParameter): |
36 | 530 name = "option" |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
531 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
532 def __init__(self, value, text, selected=False, **kwargs): |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
533 params = Util.clean_kwargs(locals().copy()) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
534 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
535 passed_kwargs = {} |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
536 if selected: |
36 | 537 passed_kwargs["selected"] = "true" |
538 passed_kwargs["value"] = params["value"] | |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
539 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
540 super(SelectOption, self).__init__(None, **passed_kwargs) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
541 self.node.text = str(text) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
542 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
543 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
544 class Options(InputParameter): |
36 | 545 name = "options" |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
546 |
36 | 547 def __init__( |
548 self, | |
549 from_dataset=None, | |
550 from_file=None, | |
551 from_data_table=None, | |
552 from_parameter=None, | |
553 **kwargs, | |
554 ): | |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
555 params = Util.clean_kwargs(locals().copy()) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
556 super(Options, self).__init__(None, **params) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
557 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
558 def acceptable_child(self, child): |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
559 return issubclass(type(child), Column) or issubclass(type(child), Filter) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
560 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
561 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
562 class Column(InputParameter): |
36 | 563 name = "column" |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
564 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
565 def __init__(self, name, index, **kwargs): |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
566 params = Util.clean_kwargs(locals().copy()) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
567 super(Column, self).__init__(**params) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
568 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
569 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
570 class Filter(InputParameter): |
36 | 571 name = "filter" |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
572 |
36 | 573 def __init__( |
574 self, | |
575 type, | |
576 column=None, | |
577 name=None, | |
578 ref=None, | |
579 key=None, | |
580 multiple=None, | |
581 separator=None, | |
582 keep=None, | |
583 value=None, | |
584 ref_attribute=None, | |
585 index=None, | |
586 **kwargs, | |
587 ): | |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
588 params = Util.clean_kwargs(locals().copy()) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
589 super(Filter, self).__init__(**params) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
590 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
591 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
592 class ValidatorParam(InputParameter): |
36 | 593 name = "validator" |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
594 |
36 | 595 def __init__( |
596 self, | |
597 type, | |
598 message=None, | |
599 filename=None, | |
600 metadata_name=None, | |
601 metadata_column=None, | |
602 line_startswith=None, | |
603 min=None, | |
604 max=None, | |
605 **kwargs, | |
606 ): | |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
607 params = Util.clean_kwargs(locals().copy()) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
608 super(ValidatorParam, self).__init__(**params) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
609 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
610 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
611 class Outputs(XMLParam): |
36 | 612 name = "outputs" |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
613 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
614 def acceptable_child(self, child): |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
615 return isinstance(child, OutputData) or isinstance(child, OutputCollection) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
616 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
617 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
618 class OutputData(XMLParam): |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
619 """Copypasta of InputParameter, needs work |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
620 """ |
36 | 621 |
622 name = "data" | |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
623 |
36 | 624 def __init__( |
625 self, | |
626 name, | |
627 format, | |
628 format_source=None, | |
629 metadata_source=None, | |
630 label=None, | |
631 from_work_dir=None, | |
632 hidden=False, | |
633 **kwargs, | |
634 ): | |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
635 # TODO: validate format_source&metadata_source against something in the |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
636 # XMLParam children tree. |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
637 self.mako_identifier = name |
36 | 638 if "num_dashes" in kwargs: |
639 self.num_dashes = kwargs["num_dashes"] | |
640 del kwargs["num_dashes"] | |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
641 else: |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
642 self.num_dashes = 0 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
643 self.space_between_arg = " " |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
644 params = Util.clean_kwargs(locals().copy()) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
645 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
646 super(OutputData, self).__init__(**params) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
647 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
648 def command_line(self): |
36 | 649 if hasattr(self, "command_line_override"): |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
650 return self.command_line_override |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
651 else: |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
652 return "%s%s%s" % (self.flag(), self.space_between_arg, self.mako_name()) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
653 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
654 def mako_name(self): |
36 | 655 return "$" + self.mako_identifier |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
656 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
657 def flag(self): |
36 | 658 flag = "-" * self.num_dashes |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
659 return flag + self.mako_identifier |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
660 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
661 def acceptable_child(self, child): |
36 | 662 return ( |
663 isinstance(child, OutputFilter) | |
664 or isinstance(child, ChangeFormat) | |
665 or isinstance(child, DiscoverDatasets) | |
666 ) | |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
667 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
668 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
669 class OutputFilter(XMLParam): |
36 | 670 name = "filter" |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
671 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
672 def __init__(self, text, **kwargs): |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
673 params = Util.clean_kwargs(locals().copy()) |
36 | 674 del params["text"] |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
675 super(OutputFilter, self).__init__(**params) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
676 self.node.text = text |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
677 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
678 def acceptable_child(self, child): |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
679 return False |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
680 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
681 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
682 class ChangeFormat(XMLParam): |
36 | 683 name = "change_format" |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
684 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
685 def __init__(self, **kwargs): |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
686 params = Util.clean_kwargs(locals().copy()) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
687 super(ChangeFormat, self).__init__(**params) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
688 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
689 def acceptable_child(self, child): |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
690 return isinstance(child, ChangeFormatWhen) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
691 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
692 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
693 class ChangeFormatWhen(XMLParam): |
36 | 694 name = "when" |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
695 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
696 def __init__(self, input, format, value, **kwargs): |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
697 params = Util.clean_kwargs(locals().copy()) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
698 super(ChangeFormatWhen, self).__init__(**params) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
699 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
700 def acceptable_child(self, child): |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
701 return False |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
702 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
703 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
704 class OutputCollection(XMLParam): |
36 | 705 name = "collection" |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
706 |
36 | 707 def __init__( |
708 self, | |
709 name, | |
710 type=None, | |
711 label=None, | |
712 format_source=None, | |
713 type_source=None, | |
714 structured_like=None, | |
715 inherit_format=None, | |
716 **kwargs, | |
717 ): | |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
718 params = Util.clean_kwargs(locals().copy()) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
719 super(OutputCollection, self).__init__(**params) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
720 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
721 def acceptable_child(self, child): |
36 | 722 return ( |
723 isinstance(child, OutputData) | |
724 or isinstance(child, OutputFilter) | |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
725 or isinstance(child, DiscoverDatasets) |
36 | 726 ) |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
727 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
728 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
729 class DiscoverDatasets(XMLParam): |
36 | 730 name = "discover_datasets" |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
731 |
36 | 732 def __init__( |
733 self, pattern, directory=None, format=None, ext=None, visible=None, **kwargs | |
734 ): | |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
735 params = Util.clean_kwargs(locals().copy()) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
736 super(DiscoverDatasets, self).__init__(**params) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
737 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
738 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
739 class Tests(XMLParam): |
36 | 740 name = "tests" |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
741 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
742 def acceptable_child(self, child): |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
743 return issubclass(type(child), Test) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
744 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
745 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
746 class Test(XMLParam): |
36 | 747 name = "test" |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
748 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
749 def acceptable_child(self, child): |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
750 return isinstance(child, TestParam) or isinstance(child, TestOutput) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
751 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
752 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
753 class TestParam(XMLParam): |
36 | 754 name = "param" |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
755 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
756 def __init__(self, name, value=None, ftype=None, dbkey=None, **kwargs): |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
757 params = Util.clean_kwargs(locals().copy()) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
758 super(TestParam, self).__init__(**params) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
759 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
760 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
761 class TestOutput(XMLParam): |
36 | 762 name = "output" |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
763 |
36 | 764 def __init__( |
765 self, | |
766 name=None, | |
767 file=None, | |
768 ftype=None, | |
769 sort=None, | |
770 value=None, | |
771 md5=None, | |
772 checksum=None, | |
773 compare=None, | |
774 lines_diff=None, | |
775 delta=None, | |
776 **kwargs, | |
777 ): | |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
778 params = Util.clean_kwargs(locals().copy()) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
779 super(TestOutput, self).__init__(**params) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
780 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
781 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
782 class Citations(XMLParam): |
36 | 783 name = "citations" |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
784 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
785 def acceptable_child(self, child): |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
786 return issubclass(type(child), Citation) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
787 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
788 def has_citation(self, type, value): |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
789 """ |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
790 Check the presence of a given citation. |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
791 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
792 :type type: STRING |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
793 :type value: STRING |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
794 """ |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
795 for citation in self.children: |
36 | 796 if citation.node.attrib["type"] == type and citation.node.text == value: |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
797 return True |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
798 return False |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
799 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
800 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
801 class Citation(XMLParam): |
36 | 802 name = "citation" |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
803 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
804 def __init__(self, type, value): |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
805 passed_kwargs = {} |
36 | 806 passed_kwargs["type"] = type |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
807 super(Citation, self).__init__(**passed_kwargs) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
808 self.node.text = str(value) |