@@ -46,12 +46,17 @@ def rewrite_requirements(t):
4646 rewrite_requirements (s )
4747
4848 def update_secondaryFiles (t ):
49- if isinstance (t , MutableSequence ):
50- return [update_secondaryFiles (p ) for p in t ]
49+ if isinstance (t , CommentedSeq ):
50+ new_seq = copy .deepcopy (t )
51+ for index , entry in enumerate (t ):
52+ new_seq [index ] = update_secondaryFiles (entry )
53+ return new_seq
54+ elif isinstance (t , MutableSequence ):
55+ return CommentedSeq ([update_secondaryFiles (p ) for p in t ])
5156 elif isinstance (t , MutableMapping ):
5257 return t
5358 else :
54- return { "pattern" : t }
59+ return CommentedMap ([( "pattern" , t )])
5560
5661 def fix_inputBinding (t ):
5762 for i in t ["inputs" ]:
@@ -71,9 +76,9 @@ def fix_inputBinding(t):
7176 if isinstance (upd , MutableMapping ) and "$graph" in upd :
7277 upd = upd ["$graph" ]
7378 for proc in aslist (upd ):
74- proc .setdefault ("hints" , [] )
75- proc ["hints" ].insert (0 , { "class" : "NetworkAccess" , "networkAccess" : True } )
76- proc ["hints" ].insert (0 , { "class" : "LoadListingRequirement" , "loadListing" : "deep_listing" } )
79+ proc .setdefault ("hints" , CommentedSeq () )
80+ proc ["hints" ].insert (0 , CommentedMap ([( "class" , "NetworkAccess" ),( "networkAccess" , True )]) )
81+ proc ["hints" ].insert (0 , CommentedMap ([( "class" , "LoadListingRequirement" ),( "loadListing" , "deep_listing" )]) )
7782 if "cwlVersion" in proc :
7883 del proc ["cwlVersion" ]
7984
@@ -108,7 +113,7 @@ def checkversion(doc, # type: Union[CommentedSeq, CommentedMap]
108113 metadata , # type: CommentedMap
109114 enable_dev # type: bool
110115):
111- # type: (...) -> Tuple[Union[CommentedSeq, CommentedMap] , Text]
116+ # type: (...) -> Tuple[CommentedMap, Text]
112117 """Check the validity of the version of the give CWL document.
113118
114119 Returns the document and the validated version string.
@@ -151,16 +156,15 @@ def checkversion(doc, # type: Union[CommentedSeq, CommentedMap]
151156
152157
153158def update (doc , loader , baseuri , enable_dev , metadata ):
154- # type: (Union[CommentedSeq, CommentedMap], Loader, Text, bool, Any) -> Union[CommentedSeq, CommentedMap]
159+ # type: (Union[CommentedSeq, CommentedMap], Loader, Text, bool, Any) -> CommentedMap
155160
156- if (metadata .get ("http://commonwl.org/cwltool#original_cwlVersion" ) or
157- (isinstance (doc , CommentedMap ) and doc .get ("http://commonwl.org/cwltool#original_cwlVersion" ))):
158- return doc
159-
160- (cdoc , originalversion ) = checkversion (doc , metadata , enable_dev )
161- version = originalversion
161+ if isinstance (doc , CommentedMap ):
162+ if metadata .get ("http://commonwl.org/cwltool#original_cwlVersion" ) \
163+ or doc .get ("http://commonwl.org/cwltool#original_cwlVersion" ):
164+ return doc
162165
163166 (cdoc , version ) = checkversion (doc , metadata , enable_dev )
167+ originalversion = copy .copy (version )
164168
165169 nextupdate = identity # type: Optional[Callable[[Any, Loader, Text], Tuple[Any, Text]]]
166170
0 commit comments