|
19 | 19 | Union,
|
20 | 20 | )
|
21 | 21 |
|
22 |
| -from ruamel import yaml |
| 22 | +from ruamel.yaml.main import YAML |
| 23 | +from ruamel.yaml.scalarstring import walk_tree |
23 | 24 |
|
24 | 25 | from cwl_utils.errors import WorkflowException
|
25 | 26 | from cwl_utils.loghandler import _logger as _cwlutilslogger
|
@@ -105,10 +106,12 @@ def main(args: Optional[List[str]] = None) -> int:
|
105 | 106 | def run(args: argparse.Namespace) -> int:
|
106 | 107 | """Primary processing loop."""
|
107 | 108 | return_code = 0
|
| 109 | + yaml = YAML(typ="rt") |
| 110 | + yaml.preserve_quotes = True # type: ignore[assignment] |
108 | 111 | for document in args.inputs:
|
109 | 112 | _logger.info("Processing %s.", document)
|
110 | 113 | with open(document) as doc_handle:
|
111 |
| - result = yaml.main.round_trip_load(doc_handle, preserve_quotes=True) |
| 114 | + result = yaml.load(doc_handle) |
112 | 115 | version = result["cwlVersion"]
|
113 | 116 | uri = Path(document).resolve().as_uri()
|
114 | 117 | if version == "v1.0":
|
@@ -156,13 +159,13 @@ def run(args: argparse.Namespace) -> int:
|
156 | 159 | save(result_item, base_url=result_item.loadingOptions.fileuri)
|
157 | 160 | for result_item in result
|
158 | 161 | ]
|
159 |
| - yaml.scalarstring.walk_tree(result_json) |
| 162 | + walk_tree(result_json) |
160 | 163 | # ^ converts multiline strings to nice multiline YAML
|
161 | 164 | with open(output, "w", encoding="utf-8") as output_filehandle:
|
162 | 165 | output_filehandle.write(
|
163 | 166 | "#!/usr/bin/env cwl-runner\n"
|
164 | 167 | ) # TODO: teach the codegen to do this?
|
165 |
| - yaml.main.round_trip_dump(result_json, output_filehandle) |
| 168 | + yaml.dump(result_json, output_filehandle) |
166 | 169 | except WorkflowException as exc:
|
167 | 170 | return_code = 1
|
168 | 171 | _logger.exception("Skipping %s due to error.", document, exc_info=exc)
|
|
0 commit comments