@@ -201,8 +201,8 @@ def __init__(
201
201
self .cwlVersion = cwl_version
202
202
self .id = tool_id
203
203
self .label = label
204
- self .requirements = [] # List of Several object inhereting from [Requirement]
205
- self .hints = []
204
+ self .requirements = [] # List of objects inheriting from [Requirement]
205
+ self .hints = [] # List of objects inheriting from [Requirement]
206
206
self .inputs = [] # List of [CommandInputParameter] objects
207
207
self .outputs = [] # List of [CommandOutputParameter] objects
208
208
self .baseCommand = base_command
@@ -233,26 +233,46 @@ def get_dict(self):
233
233
if "$" not in v :
234
234
d [self .namespaces .name ][k ] = v
235
235
236
+ if "inputs" not in d :
237
+ # Tool can have no inputs but still needs to be bound
238
+ d ["inputs" ] = []
239
+
236
240
if self .requirements :
237
241
d ["requirements" ] = {r .get_class (): r .get_dict () for r in self .requirements }
242
+ if self .hints :
243
+ d ["hints" ] = {r .get_class (): r .get_dict () for r in self .hints }
244
+
238
245
return d
239
246
240
247
@classmethod
241
248
def parse_dict (cls , d ):
242
- wf = super (CommandLineTool , cls ).parse_dict (d )
249
+ clt = super (CommandLineTool , cls ).parse_dict (d )
243
250
244
251
reqs = d .get ("requirements" )
245
252
if reqs :
246
253
if isinstance (reqs , list ):
247
- wf .requirements = [Requirement .parse_dict (r ) for r in reqs ]
254
+ clt .requirements = [Requirement .parse_dict (r ) for r in reqs ]
248
255
elif isinstance (reqs , dict ):
249
256
# splat operator here would be so nice {**r, "class": c}
257
+ clt .requirements = []
250
258
for c , r in reqs .items ():
251
259
rdict = {'class' : c }
252
260
rdict .update (r )
253
- wf .requirements .append (Requirement .parse_dict (rdict ))
261
+ clt .requirements .append (Requirement .parse_dict (rdict ))
262
+
263
+ hnts = d .get ("hints" )
264
+ if hnts :
265
+ if isinstance (hnts , list ):
266
+ clt .hints = [Requirement .parse_dict (r ) for r in hnts ]
267
+ elif isinstance (hnts , dict ):
268
+ # splat operator here would be so nice {**r, "class": c}
269
+ clt .hints = []
270
+ for c , r in hnts .items ():
271
+ rdict = {'class' : c }
272
+ rdict .update (r )
273
+ clt .hints .append (Requirement .parse_dict (rdict ))
254
274
255
- return wf
275
+ return clt
256
276
257
277
def export_string (self ):
258
278
ruamel .yaml .add_representer (literal , literal_presenter )
0 commit comments