8000 cover outputBinding for import · phenoflow/python-cwlgen@796dc57 · GitHub
[go: up one dir, main page]

Skip to content

Commit 796dc57

Browse files
committed
cover outputBinding for import
1 parent d89becb commit 796dc57

File tree

3 files changed

+83
-2
lines changed

3 files changed

+83
-2
lines changed

cwlgen/import_cwl.py

Lines changed: 67 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -453,8 +453,17 @@ def _load_doc(self, output_obj, doc_el):
453453
"""
454454
output_obj.doc = doc_el
455455

456-
def _load_outputBinding(self, output_obj, inpb_el):
457-
pass
456+
def _load_outputBinding(self, output_obj, outpb_el):
457+
"""
458+
Load the content of outputBinding into the output object.
459+
460+
:param output_obj: output obj
461+
:type output_obj: : :class:`cwlgen.CommandOutputParameter`
462+
:param outpb_el: Content of outputBinding
463+
:type outpb_el: DICT
464+
"""
465+
obparser = OutputBindingParser()
466+
obparser.load_outbinding(output_obj, outpb_el)
458467

459468
def _load_type(self, output_obj, type_el):
460469
"""
@@ -485,3 +494,59 @@ def load_outputs(self, outputs, outputs_el):
485494
except AttributeError:
486495
logger.warning(key + " content for output is not processed (yet).")
487496
outputs.append(output_obj)
497+
498+
499+
class OutputBindingParser(object):
500+
"""
501+
Class to parse content of outputBinding of output from existing CWL Tool.
502+
"""
503+
504+
def _load_glob(self, outbinding_obj, glob_el):
505+
"""
506+
Load the content of glob into the outputBinding object.
507+
508+
:param outbinding_obj: outputBinding object
509+
:glob outbinding_obj: : :class:`cwlgen.CommandOutputBinding`
510+
:param glob_el: Content of glob
511+
:glob glob_el: STRING
512+
"""
513+
outbinding_obj.glob = glob_el
514+
515+
def _load_loadContents(self, outbinding_obj, loadcontents_el):
516+
"""
517+
Load the content of loadContents into the outputBinding object.
518+
519+
:param outbinding_obj: outputBinding object
520+
:loadContents outbinding_obj: : :class:`cwlgen.CommandOutputBinding`
521+
:param loadcontents_el: Content of loadContents
522+
:loadContents loadcontents_el: BOOLEAN
523+
"""
524+
outbinding_obj.loadContents = loadcontents_el
525+
526+
def _load_outputEval(self, outbinding_obj, outputeval_el):
527+
"""
528+
Load the content of outputEval into the outputBinding object.
529+
530+
:param outbinding_obj: outputBinding object
531+
:outputEval outbinding_obj: : :class:`cwlgen.CommandOutputBinding`
532+
:param outputeval_el: Content of outputEval
533+
:outputEval outputeval_el: STRING
534+
"""
535+
outbinding_obj.outputEval = outputeval_el
536+
537+
def load_outbinding(self, output_obj, outbinding_el):
538+
"""
539+
Load the content of outputBinding into the output object.
540+
541+
:param output_obj: output object
542+
:type output_obj: :class:`cwlgen.CommandOutputParameter`
543+
:param outbinding_el: Content of outputBinding element
544+
:type outbinding_el: DICT
545+ """
546+
outbinding_obj = cwlgen.CommandOutputBinding()
547+
for key, value in outbinding_el.items():
548+
try:
549+
getattr(self, '_load_{}'.format(key))(outbinding_obj, value)
550+
except AttributeError:
551+
logger.warning(key + " content for outputBinding is not processed (yet).")
552+
output_obj.outputBinding = outbinding_obj

test/import_cwl.cwl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,8 @@ outputs:
3333
format: format_1930
3434
streamable: True
3535
doc: 'documentation_out'
36+
outputBinding:
37+
glob: "find"
38+
loadContents: True
39+
outputEval: "eval"
3640
type: File

test/test_unit_import.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,3 +123,15 @@ def test_load_doc(self):
123123

124124
def test_load_type(self):
125125
self.assertEqual(self.tool.outputs[0].type, 'File')
126+
127+
128+
class TestOutputBindingParser(TestImport):
129+
130+
def test_load_glob(self):
131+
self.assertEqual(self.tool.outputs[0].outputBinding.glob, 'find')
132+
133+
def test_load_loadContents(self):
134+
self.assertTrue(self.tool.outputs[0].outputBinding.loadContents)
135+
136+
def test_load_outputEval(self):
137+
self.assertEqual(self.tool.outputs[0].outputBinding.outputEval, "eval")

0 commit comments

Comments
 (0)
0