18
18
logging .basicConfig (level = logging .INFO )
19
19
logger = logging .getLogger (__name__ )
20
20
21
- # Class(es) ------------------------------
21
+ # Class(es) ------------------------------
22
+
22
23
23
24
class CWLToolParser (object ):
24
25
"""
@@ -28,7 +29,7 @@ class CWLToolParser(object):
28
29
def _init_tool (self , cwl_dict ):
29
30
"""
30
31
Init tool from existing CWL tool.
31
-
32
+
32
33
:param cwl_dict: Full content of CWL file
33
34
:type cwl_dict: DICT
34
35
"""
@@ -161,7 +162,7 @@ def _load_outputs(self, tool, outputs_el):
161
162
def import_cwl (self , cwl_path ):
162
163
"""
163
164
Load content of cwl into the :class:`cwlgen.CommandLineTool` object.
164
-
165
+
165
166
:param cwl_path: Path of the CWL tool to be loaded.
166
167
:type cwl_path: STRING
167
168
:return: CWL tool content in cwlgen model.
@@ -172,7 +173,7 @@ def import_cwl(self, cwl_path):
172
173
tool = self ._init_tool (cwl_dict )
173
174
for key , element in cwl_dict .items ():
174
175
try :
175
- getattr (self , '_load_{}' .format (key ))(tool , element )
176
+ getattr (self , '_load_{}' .format (key ))(tool , element )
176
177
except AttributeError :
177
178
logger .warning (key + " content is not processed (yet)." )
178
179
return tool
@@ -183,6 +184,95 @@ class InputsParser(object):
183
184
Class to parse content of inputs from an existing CWL Tool.
184
185
"""
185
186
187
+ def _load_label (self , input_obj , label_el ):
188
+ """
189
+ Load the content of type into the input object.
190
+
191
+ :param input_obj: input obj
192
+ :type input_obj: : :class:`cwlgen.CommandInputParameter`
193
+ :param label_el: Content of label
194
+ :type label_el: STRING
195
+ """
196
+ input_obj .label = label_el
197
+
198
+ def _load_secondaryFiles (self , input_obj , secfile_el ):
199
+ """
200
+ Load the content of secondaryFiles into the input object.
201
+
202
+ :param input_obj: input obj
203
+ :type input_obj: : :class:`cwlgen.CommandInputParameter`
204
+ :param secfile_el: Content of secondaryFile
205
+ :type secfile_el: STRING
206
+ """
207
+ input_obj .secondary_file = secfile_el
208
+
209
+ def _load_format (self , input_obj , format_el ):
210
+ """
6D4E
211
+ Load the content of format into the input object.
212
+
213
+ :param input_obj: input obj
214
+ :type input_obj: : :class:`cwlgen.CommandInputParameter`
215
+ :param format_el: Content of format
216
+ :type format_el: STRING
217
+ """
218
+ input_obj .format = format_el
219
+
220
+ def _load_streamable (self , input_obj , stream_el ):
221
+ """
222
+ Load the content of streamable into the input object.
223
+
224
+ :param input_obj: input obj
225
+ :type input_obj: : :class:`cwlgen.CommandInputParameter`
226
+ :param stream_el: Content of streamable
227
+ :type type_el: BOOLEAN
228
+ """
229
+ input_obj .streamable = stream_el
230
+
231
+ def _load_doc (self , input_obj , doc_el ):
232
+ """
233
+ Load the content of doc into the input object.
234
+
235
+ :param input_obj: input obj
236
+ :type input_obj: : :class:`cwlgen.CommandInputParameter`
237
+ :param doc_el: Content of doc
238
+ :type doc_el: STRING
239
+ """
240
+ input_obj .doc = doc_el
241
+
242
+ def _load_inputBinding (self , input_obj , inpb_el ):
243
+ """
244
+ Load the content of inputBinding into the input object.
245
+
246
+ :param input_obj: input obj
247
+ :type input_obj: : :class:`cwlgen.CommandInputParameter`
248
+ :param inpb_el: Content of inputBinding
249
+ :type inpb_el: DICT
250
+ """
251
+ ibparser = InputBindingParser ()
252
+ ibparser .load_inbinding (input_obj , inpb_el )
253
+
254
+ def _load_default (self , input_obj , def_el ):
255
+ """
256
+ Load the content of default into the input object.
257
+
258
+ :param input_obj: input obj
259
+ :type input_obj: : :class:`cwlgen.CommandInputParameter`
260
+ :param default_el: Content of default
261
+ :type default_el: STRING
262
+ """
263
+ input_obj .default = def_el
264
+
265
+ def _load_type (self , input_obj , type_el ):
266
+ """
267
+ Load the content of type into the input object.
268
+
269
+ :param input_obj: input obj
270
+ :type input_obj: : :class:`cwlgen.CommandInputParameter`
271
+ :param type_el: Content of type
272
+ :type type_el: STRING
273
+ """
274
+ input_obj .type = type_el
275
+
186
276
def load_inputs (self , inputs , inputs_el ):
187
277
"""
188
278
Load the content of inputs into the inputs list.
@@ -203,11 +293,180 @@ def load_inputs(self, inputs, inputs_el):
203
293
inputs .append (input_obj )
204
294
205
295
296
+ class InputBindingParser (object ):
297
+ """
298
+ Class to parse content of inputBinding of input from existing CWL Tool.
299
+ """
300
+
301
+ def _load_loadContents (self , inbinding_obj , loadcontents_el ):
302
+ """
303
+ Load the content of loadContents into the input object.
304
+
305
+ :param inbinding_obj: input_binding object
306
+ :loadContents inbinding_obj: : :class:`cwlgen.CommandLineBinding`
307
+ :param loadcontents_el: Content of loadContents
308
+ :loadContents loadcontents_el: BOOLEAN
309
+ """
310
+ inbinding_obj .load_contents = loadcontents_el
311
+
312
+ def _load_position (self , inbinding_obj , position_el ):
313
+ """
314
+ Load the content of position into the input object.
315
+
316
+ :param inbinding_obj: input_binding object
317
+ :loadContents inbinding_obj: : :class:`cwlgen.CommandLineBinding`
318
+ :param position_el: Content of loadContents
319
+ :loadContents position_el: INT
320
+ """
321
+ inbinding_obj .position = position_el
322
+
323
+ def _load_prefix (self , inbinding_obj , prefix_el ):
324
+ """
325
+ Load the content of prefix into the input object.
326
+
327
+ :param inbinding_obj: input_binding object
328
+ :loadContents inbinding_obj: : :class:`cwlgen.CommandLineBinding`
329
+ :param prefix_el: Content of loadContents
330
+ :loadContents prefix_el: STRING
331
+ """
332
+ inbinding_obj .prefix = prefix_el
333
+
334
+ def _load_separate (self , inbinding_obj , separate_el ):
335
+ """
336
+ Load the content of separate into the input object.
337
+
338
+ :param inbinding_obj: input_binding object
339
+ :loadContents inbinding_obj: : :class:`cwlgen.CommandLineBinding`
340
+ :param separate_el: Content of loadContents
341
+ :loadContents separate_el: BOOLEAN
342
+ """
343
+ inbinding_obj .separate = separate_el
344
+
345
+ def _load_itemSeparator (self , inbinding_obj , itemsep_el ):
346
+ """
347
+ Load the content of itemSeparator into the input object.
348
+
349
+ :param inbinding_obj: input_binding object
350
+ :loadContents inbinding_obj: : :class:`cwlgen.CommandLineBinding`
351
+ :param itemsep_el: Content of loadContents
352
+ :loadContents itemsep_el: STRING
353
+ """
354
+ inbinding_obj .item_separator = itemsep_el
355
+
356
+ def _load_valueFrom (self , inbinding_obj , valuefrom_el ):
357
+ """
358
+ Load the content of valueFrom into the input object.
359
+
360
+ :param inbinding_obj: input_binding object
361
+ :loadContents inbinding_obj: : :class:`cwlgen.CommandLineBinding`
362
+ :param valuefrom_el: Content of loadContents
363
+ :loadContents valuefrom_el: STRING
364
+ """
365
+ inbinding_obj .value_from = valuefrom_el
366
+
367
+ def _load_shellQuote (self , inbinding_obj , shellquote_el ):
368
+ """
369
+ Load the content of shellQuote into the input object.
370
+
371
+ :param inbinding_obj: input_binding object
372
+ :loadContents inbinding_obj: : :class:`cwlgen.CommandLineBinding`
373
+ :param shellquote_el: Content of loadContents
374
+ :loadContents shellquote_el: BOOLEAN
375
+ """
376
+ inbinding_obj .shell_quote = shellquote_el
377
+
378
+ def load_inbinding (self , input_obj , inbinding_el ):
379
+ """
380
+ Load the content of inputBinding into the input object.
381
+
382
+ :param input_obj: input object
383
+ :type input_obj: :class:`cwlgen.CommandInputParameter`
384
+ :param inbinding_el: Content of inputs
385
+ :type inbinding_el: DICT
386
+ """
387
+ inbinding_obj = cwlgen .CommandLineBinding ()
388
+ for key , value in inbinding_el .items ():
389
+ try :
390
+ getattr (self , '_load_{}' .format (key ))(inbinding_obj , value )
391
+ except AttributeError :
392
+ logger .warning (key + " content for inputBinding is not processed (yet)." )
393
+ input_obj .input_binding = inbinding_obj
394
+
395
+
206
396
class OutputsParser (object ):
207
397
"""
208
398
Class to parse content of outputs from an existing CWL Tool.
209
399
"""
210
400
401
+ def _load_label (self , output_obj , label_el ):
402
+ """
403
+ Load the content of type into the output object.
404
+
405
+ :param output_obj: output obj
406
+ :type output_obj: : :class:`cwlgen.CommandInputParameter`
407
+ :param label_el: Content of label
408
+ :type label_el: STRING
409
+ """
410
+ output_obj .label = label_el
411
+
412
+ def _load_secondaryFiles (self , output_obj , secfile_el ):
413
+ """
414
+ Load the content of secondaryFiles into the output object.
415
+
416
+ :param output_obj: output obj
417
+ :type output_obj: : :class:`cwlgen.CommandInputParameter`
418
+ :param secfile_el: Content of secondaryFile
419
+ :type secfile_el: STRING
420
+ """
421
+ output_obj .secondary_file = secfile_el
422
+
423
+ def _load_format (self , output_obj , format_el ):
424
+ """
425
+ Load the content of format into the output object.
426
+
427
+ :param output_obj: output obj
428
+ :type output_obj: : :class:`cwlgen.CommandInputParameter`
429
+ :param format_el: Content of format
430
+ :type format_el: STRING
431
+ """
432
+ output_obj .format = format_el
433
+
434
+ def _load_streamable (self , output_obj , stream_el ):
435
+ """
436
+ Load the content of streamable into the output object.
437
+
438
+ :param output_obj: output obj
439
+ :type output_obj: : :class:`cwlgen.CommandInputParameter`
440
+ :param stream_el: Content of streamable
441
+ :type type_el: BOOLEAN
442
+ """
443
+ output_obj .streamable = stream_el
444
+
445
+ def _load_doc (self , output_obj , doc_el ):
446
+ """
447
+ Load the content of doc into the output object.
448
+
449
+ :param output_obj: output obj
450
+ :type output_obj: : :class:`cwlgen.CommandInputParameter`
451
+ :param doc_el: Content of doc
452
+ :type doc_el: STRING
453
+ """
454
+ output_obj .doc = doc_el
455
+
456
+ def _load_outputBinding (self , output_obj , inpb_el ):
457
+ pass
458
+
459
+ def _load_type (self , output_obj , type_el ):
460
+ """
461
+ Load the content of type into the output object.
462
+
463
+ :param output_obj: output obj
464
+ :type output_obj: : :class:`cwlgen.CommandInputParameter`
465
+ :param type_el: Content of type
466
+ :type type_el: STRING
467
+ """
468
+ output_obj .type = type_el
469
+
211
470
def load_outputs (self , outputs , outputs_el ):
212
471
"""
213
472
Load the content of outputs into the outputs list.
0 commit comments