|
15 | 15 | # WARNING: do not use 'pyyaml' (import yaml), it does invalid parsing of some scientific number representations |
16 | 16 | # see 'Numbers in scientific notation without dot are parsed as string' (https://github.com/yaml/pyyaml/issues/173) |
17 | 17 | # builtin 'json' and 'simplejson' also have this issue (https://github.com/common-workflow-language/cwl-v1.2/issues/252) |
18 | | -from ruamel import yaml |
| 18 | +from ruamel.yaml import YAML |
19 | 19 | from ruamel.yaml.scanner import ScannerError |
20 | 20 |
|
21 | 21 | # https://raw.githubusercontent.com/common-workflow-language/cwl-v1.2/1.2.1_proposed/conformance_tests.yaml |
@@ -76,15 +76,16 @@ def load_file(file_path: str, text: bool = False) -> Union[JSON, str]: |
76 | 76 | :returns: loaded contents either parsed and converted to Python objects or as plain text. |
77 | 77 | :raises ValueError: if YAML or JSON cannot be parsed or loaded from location. |
78 | 78 | """ |
| 79 | + yaml = YAML(typ='safe', pure=True) |
79 | 80 | try: |
80 | 81 | if is_remote_file(file_path): |
81 | 82 | headers = {"Accept": "text/plain"} |
82 | 83 | resp = requests.get(file_path, headers=headers) |
83 | 84 | if resp.status_code != 200: |
84 | 85 | raise ValueError("Loading error: [%s]", file_path) |
85 | | - return resp.content if text else yaml.safe_load(resp.content) |
| 86 | + return resp.content if text else yaml.load(resp.content) |
86 | 87 | with open(file_path, mode="r", encoding="utf-8") as f: |
87 | | - return f.read() if text else yaml.safe_load(f) |
| 88 | + return f.read() if text else yaml.load(f) |
88 | 89 | except OSError as exc: |
89 | 90 | LOGGER.debug("Loading error: %s", exc, exc_info=exc) |
90 | 91 | raise |
|
0 commit comments