diff --git a/sevenbridges/models/compound/tasks/__init__.py b/sevenbridges/models/compound/tasks/__init__.py index 26af891..d9f925e 100644 --- a/sevenbridges/models/compound/tasks/__init__.py +++ b/sevenbridges/models/compound/tasks/__init__.py @@ -1,3 +1,4 @@ +from sevenbridges.models.enums import FileApiFormats from sevenbridges.models.file import File @@ -12,14 +13,30 @@ def map_input_output(item, api): return [map_input_output(it, api) for it in item] elif isinstance(item, dict) and 'class' in item: - if item['class'].lower() in ('file', 'directory'): + file_class_list = [ + FileApiFormats.FILE.lower(), + FileApiFormats.FOLDER.lower() + ] + if item['class'].lower() in file_class_list: _secondary_files = [] for _file in item.get('secondaryFiles', []): _secondary_files.append({'id': _file['path']}) data = { 'id': item['path'] } - data.update({k: item[k] for k in item if k != 'path'}) + # map class to type + if item['class'].lower() == FileApiFormats.FOLDER.lower(): + data['type'] = 'folder' + else: + data['type'] = 'file' + + # map cwl 1 file name + if 'basename' in item: + data['name'] = item['basename'] + + data.update( + {k: item[k] for k in item if k not in ['path', 'basename']} + ) if _secondary_files: data.update({ '_secondary_files': _secondary_files,