Skip to content
This repository was archived by the owner on Jun 9, 2020. It is now read-only.

Commit 3ec6ebd

Browse files
committed
Ensures type can export from CommandInputArraySchema
1 parent 9b500b9 commit 3ec6ebd

File tree

1 file changed

+30
-9
lines changed

1 file changed

+30
-9
lines changed

cwlgen/elements.py

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -99,14 +99,24 @@ def get_dict(self):
9999
:return: dictionnary of the object
100100
:rtype: DICT
101101
'''
102-
dict_param = {k: v for k, v in vars(self).items() if v is not None and v is not False}
103-
if dict_param['type'] != 'File':
104-
# Remove what is only for File
105-
for key in ['format', 'secondaryFiles', 'streamable']:
106-
try:
107-
del(dict_param[key])
108-
except KeyError:
109-
pass
102+
manual = ["type"]
103+
dict_param = {k: v for k, v in vars(self).items() if v is not None and v is not False and k not in manual}
104+
105+
should_have_file_related_keys = False
106+
107+
if isinstance(self.type, str):
108+
dict_param["type"] = self.type
109+
should_have_file_related_keys = self.type == "File"
110+
111+
elif isinstance(self.type, CommandInputArraySchema):
112+
dict_param["type"] = self.type.get_dict()
113+
should_have_file_related_keys = self.type.type == "File"
114+
115+
keys_to_remove = [k for k in ['format', 'secondaryFiles', 'streamable'] if k in dict_param]
116+
117+
if not should_have_file_related_keys:
118+
for key in keys_to_remove:
119+
del(dict_param[key])
110120
return dict_param
111121

112122

@@ -129,4 +139,15 @@ def __init__(self, items=None, label=None, input_binding=None):
129139
self.type = "array"
130140
self.items = parse_param_type(items)
131141
self.label = label
132-
self.input_binding = input_binding
142+
self.inputBinding = input_binding
143+
144+
def get_dict(self):
145+
'''
146+
Transform the object to a [DICT] to write CWL.
147+
148+
:return: dictionnary of the object
149+
:rtype: DICT
150+
'''
151+
dict_binding = {k: v for k, v in vars(self).items() if v is not None}
152+
return dict_binding
153+

0 commit comments

Comments
 (0)