Skip to content

Commit e656cc1

Browse files
committed
Add WorkflowConditional for wrapping an if block
1 parent 4712860 commit e656cc1

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

wdlgen/workflowcall.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,17 @@ def get_string(self, indent=1):
4545
)
4646

4747

48+
class WorkflowConditional(WorkflowCallBase):
49+
def __init__(self, condition: str, calls: List[WorkflowCall]=None):
50+
self.condition = condition
51+
self.calls = calls or []
52+
53+
def get_string(self, indent=1):
54+
body = "\n".join(c.get_string(indent=indent + 1) for c in self.calls)
55+
return "{ind}if ({condition}) {{\n {body}\n{ind}}}"\
56+
.format(ind=indent * ' ', condition=self.condition, body=body)
57+
58+
4859
class WorkflowScatter(WorkflowCallBase):
4960

5061
def __init__(self, identifier: str, expression: str, calls: List[WorkflowCall]=None):

0 commit comments

Comments
 (0)