5
5
from typing import (Any , Callable , Dict , List , MutableMapping , MutableSequence ,
6
6
Optional , Tuple , Union )
7
7
8
+ from functools import partial
9
+
8
10
from ruamel .yaml .comments import CommentedMap , CommentedSeq
9
11
from schema_salad import validate
10
12
from 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
61
63
type (s ), s ))
62
64
63
65
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]]
66
68
if isinstance (t , CommentedSeq ):
67
69
new_seq = copy .deepcopy (t )
68
70
for index , entry in enumerate (t ):
@@ -72,6 +74,8 @@ def update_secondaryFiles(t):
72
74
return CommentedSeq ([update_secondaryFiles (p ) for p in t ])
73
75
elif isinstance (t , MutableMapping ):
74
76
return t
77
+ elif top :
78
+ return CommentedSeq ([CommentedMap ([("pattern" , t )])])
75
79
else :
76
80
return CommentedMap ([("pattern" , t )])
77
81
@@ -88,7 +92,7 @@ def fix_inputBinding(t): # type: (Dict[Text, Any]) -> None
88
92
89
93
visit_class (doc , ("CommandLineTool" ,"Workflow" ), rewrite_requirements )
90
94
visit_class (doc , ("ExpressionTool" ,"Workflow" ), fix_inputBinding )
91
- visit_field (doc , "secondaryFiles" , update_secondaryFiles )
95
+ visit_field (doc , "secondaryFiles" , partial ( update_secondaryFiles , top = True ) )
92
96
93
97
upd = doc
94
98
if isinstance (upd , MutableMapping ) and "$graph" in upd :
0 commit comments