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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
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
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
25 raise Exception(
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
26 "Child was unacceptable to parent (%s is not appropriate for %s)"
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
27 % (type(self), type(sub_node))
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
28 )
35
5d38cb3d9be8 added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff changeset
29 else:
36
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
30 raise Exception(
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
31 "Child was unacceptable to parent (%s is not appropriate for %s)"
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
32 % (type(self), type(sub_node))
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
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
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
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
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
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
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
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
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
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
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
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
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
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
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
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
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
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
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
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
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
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
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
158 return issubclass(type(child), Requirement) or issubclass(
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
159 type(child), Container
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
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
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
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
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
169 passed_kwargs["version"] = params["version"]
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
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
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
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
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
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
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
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
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
190 return issubclass(type(child), Configfile) or issubclass(
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
191 type(child), ConfigfileDefaultInputs
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
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
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
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
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
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
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
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
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
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
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
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
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
220 def __init__(
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
221 self,
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
222 action=None,
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
223 check_value=None,
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
224 method=None,
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
225 target=None,
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
226 nginx_upload=None,
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
227 **kwargs,
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
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
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
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
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
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
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
251 if "num_dashes" in kwargs:
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
252 self.num_dashes = kwargs["num_dashes"]
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
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
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
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
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
264 if kwargs["label"] is None:
35
5d38cb3d9be8 added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff changeset
265 kwargs[
36
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
266 "label"
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
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
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
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
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
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
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
300 return "%s%s%s" % (
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
301 self.flag(),
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
302 self.space_between_arg,
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
303 self.mako_name(),
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
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
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
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
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
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
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
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
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
328 name = "repeat"
35
5d38cb3d9be8 added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff changeset
329
36
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
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
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
333 self.command_line_before_override = "#for $i in $%s:" % name
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
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
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
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
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
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
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
356 return issubclass(type(child), InputParameter) and not isinstance(
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
357 child, Conditional
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
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
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
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
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
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
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
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
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
387 "Param class is not an actual parameter type, use a subclass of Param"
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
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
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
391 return issubclass(
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
392 type(child, InputParameter) or isinstance(child), ValidatorParam
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
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
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
397 type = "text"
35
5d38cb3d9be8 added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff changeset
398
36
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
399 def __init__(
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
400 self, name, optional=None, label=None, help=None, value=None, **kwargs
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
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
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
416 def __init__(
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
417 self,
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
418 name,
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
419 value,
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
420 optional=None,
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
421 label=None,
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
422 help=None,
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
423 min=None,
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
424 max=None,
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
425 **kwargs,
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
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
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
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
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
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
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
440 type = "boolean"
35
5d38cb3d9be8 added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff changeset
441
36
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
442 def __init__(
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
443 self,
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
444 name,
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
445 optional=None,
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
446 label=None,
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
447 help=None,
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
448 checked=False,
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
449 truevalue=None,
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
450 falsevalue=None,
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
451 **kwargs,
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
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
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
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
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
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
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
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
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
478 type = "data"
35
5d38cb3d9be8 added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff changeset
479
36
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
480 def __init__(
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
481 self,
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
482 name,
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
483 optional=None,
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
484 label=None,
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
485 help=None,
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
486 format=None,
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
487 multiple=None,
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
488 **kwargs,
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
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
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
495 type = "select"
35
5d38cb3d9be8 added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff changeset
496
36
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
497 def __init__(
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
498 self,
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
499 name,
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
500 optional=None,
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
501 label=None,
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
502 help=None,
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
503 data_ref=None,
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
504 display=None,
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
505 multiple=None,
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
506 options=None,
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
507 default=None,
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
508 **kwargs,
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
509 ):
35
5d38cb3d9be8 added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff changeset
510 params = Util.clean_kwargs(locals().copy())
36
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
511 del params["options"]
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
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
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
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
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
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
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
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
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
537 passed_kwargs["selected"] = "true"
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
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
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
545 name = "options"
35
5d38cb3d9be8 added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff changeset
546
36
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
547 def __init__(
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
548 self,
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
549 from_dataset=None,
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
550 from_file=None,
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
551 from_data_table=None,
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
552 from_parameter=None,
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
553 **kwargs,
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
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
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
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
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
571 name = "filter"
35
5d38cb3d9be8 added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff changeset
572
36
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
573 def __init__(
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
574 self,
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
575 type,
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
576 column=None,
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
577 name=None,
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
578 ref=None,
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
579 key=None,
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
580 multiple=None,
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
581 separator=None,
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
582 keep=None,
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
583 value=None,
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
584 ref_attribute=None,
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
585 index=None,
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
586 **kwargs,
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
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
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
593 name = "validator"
35
5d38cb3d9be8 added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff changeset
594
36
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
595 def __init__(
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
596 self,
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
597 type,
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
598 message=None,
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
599 filename=None,
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
600 metadata_name=None,
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
601 metadata_column=None,
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
602 line_startswith=None,
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
603 min=None,
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
604 max=None,
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
605 **kwargs,
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
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
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
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
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
621
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
622 name = "data"
35
5d38cb3d9be8 added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff changeset
623
36
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
624 def __init__(
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
625 self,
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
626 name,
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
627 format,
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
628 format_source=None,
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
629 metadata_source=None,
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
630 label=None,
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
631 from_work_dir=None,
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
632 hidden=False,
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
633 **kwargs,
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
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
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
638 if "num_dashes" in kwargs:
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
639 self.num_dashes = kwargs["num_dashes"]
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
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
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
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
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
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
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
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
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
662 return (
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
663 isinstance(child, OutputFilter)
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
664 or isinstance(child, ChangeFormat)
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
665 or isinstance(child, DiscoverDatasets)
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
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
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
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
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
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
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
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
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
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
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
705 name = "collection"
35
5d38cb3d9be8 added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff changeset
706
36
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
707 def __init__(
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
708 self,
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
709 name,
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
710 type=None,
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
711 label=None,
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
712 format_source=None,
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
713 type_source=None,
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
714 structured_like=None,
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
715 inherit_format=None,
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
716 **kwargs,
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
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
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
722 return (
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
723 isinstance(child, OutputData)
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
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
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
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
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
730 name = "discover_datasets"
35
5d38cb3d9be8 added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff changeset
731
36
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
732 def __init__(
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
733 self, pattern, directory=None, format=None, ext=None, visible=None, **kwargs
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
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
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
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
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
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
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
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
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
762 name = "output"
35
5d38cb3d9be8 added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff changeset
763
36
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
764 def __init__(
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
765 self,
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
766 name=None,
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
767 file=None,
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
768 ftype=None,
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
769 sort=None,
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
770 value=None,
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
771 md5=None,
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
772 checksum=None,
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
773 compare=None,
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
774 lines_diff=None,
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
775 delta=None,
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
776 **kwargs,
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
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
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
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
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
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
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
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
ce2b1f8ea68d passes flake8 tests finally :)
fubar
parents: 35
diff changeset
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)