fix: preserve multiline string formatting (#245)

This commit is contained in:
Robert Kaussow 2022-02-19 21:29:27 +01:00 committed by GitHub
parent aac0ef5f20
commit c5106144ad
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -40,11 +40,13 @@ class Parser:
UnsafeTag.yaml_constructor, UnsafeTag.yaml_constructor,
constructor=ruamel.yaml.SafeConstructor constructor=ruamel.yaml.SafeConstructor
) )
data = defaultdict(dict, (ruamel.yaml.safe_load(yaml_file) or {})) loader = ruamel.yaml.YAML(typ="rt")
data = defaultdict(dict, (loader.load(yaml_file) or {}))
for key, value in data.items(): for key, value in data.items():
self._data["var"][key] = {"value": {key: value}} self._data["var"][key] = {"value": {key: value}}
except ( except (
ruamel.yaml.composer.ComposerError, ruamel.yaml.scanner.ScannerError ruamel.yaml.composer.ComposerError, ruamel.yaml.scanner.ScannerError,
ruamel.yaml.constructor.ConstructorError
) as e: ) as e:
message = "{} {}".format(e.context, e.problem) message = "{} {}".format(e.context, e.problem)
self.log.sysexit_with_message( self.log.sysexit_with_message(