Skip to content

Commit

Permalink
Merge branch 'feature/cwl1_file_output_inflate' into 'develop'
Browse files Browse the repository at this point in the history
Feature/cwl1 file output inflate

See merge request core/sevenbridges-python!74
  • Loading branch information
danilosbg committed Oct 30, 2020
2 parents 0654fe6 + a9f9fc7 commit 5dd85bb
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions sevenbridges/models/compound/tasks/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from sevenbridges.models.enums import FileApiFormats
from sevenbridges.models.file import File


Expand All @@ -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,
Expand Down

0 comments on commit 5dd85bb

Please sign in to comment.