@@ -32,9 +32,9 @@ def get_string(self):
3232 l = []
3333 for k , v in self .kwargs .items ():
3434 val = v
35- if hasattr (v , ' get_string' ):
35+ if hasattr (v , " get_string" ):
3636 val = v .get_string ()
37- l .append (' {k}: {v}' .format (k = k , v = val ))
37+ l .append (" {k}: {v}" .format (k = k , v = val ))
3838 return l
3939
4040 def add_docker (self , docker ):
@@ -68,8 +68,13 @@ class Command(WdlBase):
6868 """
6969
7070 class CommandArgument (WdlBase ):
71- def __init__ (self , prefix : str = None , value : str = None , position : int = None ,
72- separate_value_from_prefix : bool = True ):
71+ def __init__ (
72+ self ,
73+ prefix : str = None ,
74+ value : str = None ,
75+ position : int = None ,
76+ separate_value_from_prefix : bool = True ,
77+ ):
7378 self .prefix : Optional [str ] = prefix
7479 self .position : Optional [int ] = position
7580 self .value = value
@@ -82,10 +87,25 @@ def get_string(self):
8287 return (pre + sp + val ).strip ()
8388
8489 class CommandInput (CommandArgument ):
85- def __init__ (self , name : str , optional : bool = False , prefix : str = None , position : int = None ,
86- separate_value_from_prefix : bool = True , default = None , separator = None , true = None , false = None , separate_arrays = None ):
87- super ().__init__ (prefix = prefix , value = None , position = position ,
88- separate_value_from_prefix = separate_value_from_prefix )
90+ def __init__ (
91+ self ,
92+ name : str ,
93+ optional : bool = False ,
94+ prefix : str = None ,
95+ position : int = None ,
96+ separate_value_from_prefix : bool = True ,
97+ default = None ,
98+ separator = None ,
99+ true = None ,
100+ false = None ,
101+ separate_arrays = None ,
102+ ):
103+ super ().__init__ (
104+ prefix = prefix ,
105+ value = None ,
106+ position = position ,
107+ separate_value_from_prefix = separate_value_from_prefix ,
108+ )
89109 self .name = name
90110 self .optional = optional
91111 self .default = default
@@ -95,18 +115,28 @@ def __init__(self, name: str, optional: bool=False, prefix: str=None, position:
95115 self .separate_arrays = separate_arrays
96116
97117 @staticmethod
98- def from_input (inp : Input , prefix : str = None , position : int = None ):
99- return Task .Command .CommandInput (inp .name , inp .type .optional , prefix , position )
118+ def from_input (inp : Input , prefix : str = None , position : int = None ):
119+ return Task .Command .CommandInput (
120+ inp .name , inp .type .optional , prefix , position
121+ )
100122
101123 def get_string (self ):
102- name , array_sep , default , true , false = self .name , self .separator , self .default , self .true , self .false
124+ name , array_sep , default , true , false = (
125+ self .name ,
126+ self .separator ,
127+ self .default ,
128+ self .true ,
129+ self .false ,
130+ )
103131
104132 pr = self .prefix if self .prefix else ""
105133 bc = pr + (" " if self .separate and self .prefix else "" )
106134
107135 if self .separate_arrays :
108136 if array_sep or default or true or false :
109- print ("separate_array take preferences over: separator, default, true, false" )
137+ print (
138+ "separate_array take preferences over: separator, default, true, false"
139+ )
110140 if self .optional :
111141 # Ugly optional workaround: https://github.com/openwdl/wdl/issues/25#issuecomment-315424063
112142 # Additional workaround for 'length(select_first({name}, [])' as length requires a non-optional array
@@ -127,7 +157,7 @@ def get_string(self):
127157 if isinstance (default , bool ):
128158
129159 val = "true" if default else "false"
130- options .append (f' default={ val } ' )
160+ options .append (f" default={ val } " )
131161 if array_sep :
132162 options .append (f'sep="{ array_sep } "' )
133163 if true or false :
@@ -137,30 +167,52 @@ def get_string(self):
137167 stroptions = "" .join (o + " " for o in options )
138168
139169 if self .optional and not default :
140- prewithquotes = f'"{ bc } " + ' if bc .strip () else ''
141- return f' ~{{{ stroptions } { prewithquotes } { name } }}'
170+ prewithquotes = f'"{ bc } " + ' if bc .strip () else ""
171+ return f" ~{{{ stroptions } { prewithquotes } { name } }}"
142172 else :
143173 return bc + f"~{{{ stroptions } { name } }}"
144174
145- def __init__ (self , command , inputs : Optional [List [CommandInput ]]= None , arguments : Optional [List [CommandArgument ]]= None ):
175+ def __init__ (
176+ self ,
177+ command ,
178+ inputs : Optional [List [CommandInput ]] = None ,
179+ arguments : Optional [List [CommandArgument ]] = None ,
180+ ):
146181 self .command = command
147182 self .inputs = inputs if inputs else []
148183 self .arguments = arguments if arguments else []
149184
150- def get_string (self , indent : int = 0 ):
185+ def get_string (self , indent : int = 0 ):
151186 tb = " "
152187 base_command = self .command if self .command else ""
153188 if not (self .inputs or self .arguments ):
154189 return indent * tb + base_command
155190
156191 # build up command
157- args = sorted ([* self .inputs , * self .arguments ], key = lambda a : a .position if a .position else 0 )
158- command : str = base_command if isinstance (base_command , str ) else " " .join (base_command )
192+ args = sorted (
193+ [* self .inputs , * self .arguments ],
194+ key = lambda a : a .position if a .position else 0 ,
195+ )
196+ command : str = base_command if isinstance (base_command , str ) else " " .join (
197+ base_command
198+ )
159199 tbed_arg_indent = tb * (indent + 1 )
160200
161- return indent * tb + command + "" .join ([" \\ \n " + tbed_arg_indent + a .get_string () for a in args ])
201+ return (
202+ indent * tb
203+ + command
204+ + "" .join ([" \\ \n " + tbed_arg_indent + a .get_string () for a in args ])
205+ )
162206
163- def __init__ (self , name : str , inputs : List [Input ]= None , outputs : List [Output ]= None , command : Command = None , runtime : Runtime = None , version = "draft-2" ):
207+ def __init__ (
208+ self ,
209+ name : str ,
210+ inputs : List [Input ] = None ,
211+ outputs : List [Output ] = None ,
212+ command : Command = None ,
213+ runtime : Runtime = None ,
214+ version = "draft-2" ,
215+ ):
164216 self .name = name
165217 self .inputs = inputs if inputs else []
166218 self .outputs = outputs if outputs else []
@@ -186,12 +238,15 @@ def get_string(self):
186238 inputs_block , command_block , runtime_block , output_block = "" , "" , "" , ""
187239
188240 if self .inputs :
189- inputs_block = f"{ tb } input {{\n " + "\n " .join (2 * tb + i .get_string () for i in self .inputs ) + f"\n { tb } }}"
241+ inputs_block = (
242+ f"{ tb } input {{\n "
243+ + "\n " .join (2 * tb + i .get_string () for i in self .inputs )
244+ + f"\n { tb } }}"
245+ )
190246
191247 if self .outputs :
192248 output_block = "{tb}output {{\n {outs}\n {tb}}}" .format (
193- tb = tb ,
194- outs = "\n " .join ((2 * tb ) + o .get_string () for o in self .outputs )
249+ tb = tb , outs = "\n " .join ((2 * tb ) + o .get_string () for o in self .outputs )
195250 )
196251
197252 if self .command :
@@ -200,15 +255,11 @@ def get_string(self):
200255 com = "\n " .join (c .get_string (indent = 2 ) for c in self .command )
201256 else :
202257 com = self .command .get_string (indent = 2 )
203- command_block = "{tb}command <<<\n {args}\n {tb}>>>" .format (
204- tb = tb ,
205- args = com
206- )
258+ command_block = "{tb}command <<<\n {args}\n {tb}>>>" .format (tb = tb , args = com )
207259
208260 if self .runtime :
209261 runtime_block = "{tb}runtime {{\n {args}\n {tb}}}" .format (
210- tb = tb ,
211- args = "\n " .join ((2 * tb ) + a for a in self .runtime .get_string ())
262+ tb = tb , args = "\n " .join ((2 * tb ) + a for a in self .runtime .get_string ())
212263 )
213264
214265 return self .format .format (
@@ -217,5 +268,5 @@ def get_string(self):
217268 command_block = command_block ,
218269 runtime_block = runtime_block ,
219270 output_block = output_block ,
220- version = self .version
271+ version = self .version ,
221272 )
0 commit comments