12
12
from pathlib import Path
13
13
from typing import Any , Callable , Dict , List , MutableMapping , Optional , Set , Union
14
14
15
- from schema_salad .sourceline import SourceLine , add_lc_filename , cmap
16
-
17
15
import ruamel .yaml
18
16
from ruamel .yaml .comments import CommentedMap # for consistent sort order
17
+ from schema_salad .sourceline import SourceLine , add_lc_filename , cmap
19
18
20
19
_logger = logging .getLogger ("cwl-upgrader" ) # pylint: disable=invalid-name
21
20
defaultStreamHandler = logging .StreamHandler () # pylint: disable=invalid-name
@@ -203,7 +202,7 @@ def load_cwl_document(path: Union[str, Path]) -> Any:
203
202
204
203
205
204
def write_cwl_document (document : Any , path : Path ) -> None :
206
- """
205
+ r """
207
206
Serialize the document using the Ruamel YAML round trip dumper.
208
207
209
208
Will also prepend "#!/usr/bin/env cwl-runner\n" and
@@ -294,7 +293,7 @@ def v1_1_to_v1_2(document: CommentedMap, out_dir: Path, root_dir: Path) -> Comme
294
293
def draft3_to_v1_0 (
295
294
document : CommentedMap , out_dir : Path , root_dir : Path
296
295
) -> CommentedMap :
297
- """Transformation loop."""
296
+ """Transform loop for draft-3 to v1.0 ."""
298
297
_draft3_to_v1_0 (document , out_dir , root_dir )
299
298
if isinstance (document , MutableMapping ):
300
299
for key , value in document .items ():
@@ -312,14 +311,14 @@ def draft3_to_v1_0(
312
311
def draft3_to_v1_1 (
313
312
document : CommentedMap , out_dir : Path , root_dir : Path
314
313
) -> CommentedMap :
315
- """transformation loop."""
314
+ """Transform loop for draft-3 to v1.1 ."""
316
315
return v1_0_to_v1_1 (draft3_to_v1_0 (document , out_dir , root_dir ), out_dir , root_dir )
317
316
318
317
319
318
def draft3_to_v1_2 (
320
319
document : CommentedMap , out_dir : Path , root_dir : Path
321
320
) -> CommentedMap :
322
- """transformation loop."""
321
+ """Transform loop for draft-3 to v1.2 ."""
323
322
return v1_1_to_v1_2 (
324
323
v1_0_to_v1_1 (draft3_to_v1_0 (document , out_dir , root_dir ), out_dir , root_dir ),
325
324
out_dir ,
@@ -405,7 +404,7 @@ def _v1_0_to_v1_1(
405
404
process = v1_0_to_v1_1 (
406
405
load_cwl_document (str (path )), out_dir , root_dir
407
406
)
408
- write_cwl_document (process , path .name , out_dir )
407
+ write_cwl_document (process , out_dir / path .name )
409
408
elif isinstance (steps , MutableMapping ):
410
409
for step_name in steps :
411
410
with SourceLine (steps , step_name , Exception ):
@@ -491,7 +490,7 @@ def _v1_1_to_v1_2(
491
490
with SourceLine (steps , index , Exception ):
492
491
if "run" in entry and isinstance (entry ["run" ], CommentedMap ):
493
492
process = entry ["run" ]
494
- _v1_1_to_v1_2 (process , out_dir )
493
+ _v1_1_to_v1_2 (process , out_dir , root_dir )
495
494
if "cwlVersion" in process :
496
495
del process ["cwlVersion" ]
497
496
@@ -504,7 +503,7 @@ def _v1_1_to_v1_2(
504
503
process = v1_1_to_v1_2 (
505
504
load_cwl_document (str (path )), out_dir , root_dir
506
505
)
507
- write_cwl_document (process , path .name , out_dir , root_dir )
506
+ write_cwl_document (process , out_dir / path .name )
508
507
elif isinstance (steps , MutableMapping ):
509
508
for step_name in steps :
510
509
with SourceLine (steps , step_name , Exception ):
0 commit comments