Skip to content

Commit 95305ba

Browse files
committed
update ruamel.yaml usage
1 parent d696982 commit 95305ba

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

cwl_utils/cwl_expression_refactor.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919
Union,
2020
)
2121

22-
from ruamel import yaml
22+
from ruamel.yaml.main import YAML
23+
from ruamel.yaml.scalarstring import walk_tree
2324

2425
from cwl_utils.errors import WorkflowException
2526
from cwl_utils.loghandler import _logger as _cwlutilslogger
@@ -105,10 +106,12 @@ def main(args: Optional[List[str]] = None) -> int:
105106
def run(args: argparse.Namespace) -> int:
106107
"""Primary processing loop."""
107108
return_code = 0
109+
yaml = YAML(typ="rt")
110+
yaml.preserve_quotes = True # type: ignore[assignment]
108111
for document in args.inputs:
109112
_logger.info("Processing %s.", document)
110113
with open(document) as doc_handle:
111-
result = yaml.main.round_trip_load(doc_handle, preserve_quotes=True)
114+
result = yaml.load(doc_handle)
112115
version = result["cwlVersion"]
113116
uri = Path(document).resolve().as_uri()
114117
if version == "v1.0":
@@ -156,13 +159,13 @@ def run(args: argparse.Namespace) -> int:
156159
save(result_item, base_url=result_item.loadingOptions.fileuri)
157160
for result_item in result
158161
]
159-
yaml.scalarstring.walk_tree(result_json)
162+
walk_tree(result_json)
160163
# ^ converts multiline strings to nice multiline YAML
161164
with open(output, "w", encoding="utf-8") as output_filehandle:
162165
output_filehandle.write(
163166
"#!/usr/bin/env cwl-runner\n"
164167
) # TODO: teach the codegen to do this?
165-
yaml.main.round_trip_dump(result_json, output_filehandle)
168+
yaml.dump(result_json, output_filehandle)
166169
except WorkflowException as exc:
167170
return_code = 1
168171
_logger.exception("Skipping %s due to error.", document, exc_info=exc)

0 commit comments

Comments
 (0)