55from typing import (Any , Callable , Dict , List , MutableMapping , MutableSequence ,
66 Optional , Tuple , Union )
77
8+ from functools import partial
9+
810from ruamel .yaml .comments import CommentedMap , CommentedSeq
911from schema_salad import validate
1012from schema_salad .ref_resolver import Loader # pylint: disable=unused-import
@@ -61,8 +63,8 @@ def rewrite_requirements(t): # type: (MutableMapping[Text, Union[Text, Dict[Tex
6163 type (s ), s ))
6264
6365
64- def update_secondaryFiles (t ):
65- # type: (Any) -> Union[MutableSequence[MutableMapping[Text, Text]], MutableMapping[Text, Text]]
66+ def update_secondaryFiles (t , top = False ):
67+ # type: (Any, bool ) -> Union[MutableSequence[MutableMapping[Text, Text]], MutableMapping[Text, Text]]
6668 if isinstance (t , CommentedSeq ):
6769 new_seq = copy .deepcopy (t )
6870 for index , entry in enumerate (t ):
@@ -72,6 +74,8 @@ def update_secondaryFiles(t):
7274 return CommentedSeq ([update_secondaryFiles (p ) for p in t ])
7375 elif isinstance (t , MutableMapping ):
7476 return t
77+ elif top :
78+ return CommentedSeq ([CommentedMap ([("pattern" , t )])])
7579 else :
7680 return CommentedMap ([("pattern" , t )])
7781
@@ -88,7 +92,7 @@ def fix_inputBinding(t): # type: (Dict[Text, Any]) -> None
8892
8993 visit_class (doc , ("CommandLineTool" ,"Workflow" ), rewrite_requirements )
9094 visit_class (doc , ("ExpressionTool" ,"Workflow" ), fix_inputBinding )
91- visit_field (doc , "secondaryFiles" , update_secondaryFiles )
95+ visit_field (doc , "secondaryFiles" , partial ( update_secondaryFiles , top = True ) )
9296
9397 upd = doc
9498 if isinstance (upd , MutableMapping ) and "$graph" in upd :
0 commit comments