From da23b3c8fb2c9120326e330cab30ed132d5da3a6 Mon Sep 17 00:00:00 2001 From: JaWeRn Date: Sun, 5 Nov 2023 21:03:59 +0100 Subject: Replace deprecated methods (package ruamel) in the yaml_parser.py (#28) --- config_file/parsers/yaml_parser.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/config_file/parsers/yaml_parser.py b/config_file/parsers/yaml_parser.py index fc4239a..4c39582 100644 --- a/config_file/parsers/yaml_parser.py +++ b/config_file/parsers/yaml_parser.py @@ -1,3 +1,4 @@ +from io import StringIO from typing import Type from .base_parser import BaseParser @@ -17,15 +18,14 @@ class YamlParser(BaseParser): @property def decode_error(self) -> Type[Exception]: from ruamel.yaml import YAMLError - return YAMLError def loads(self, contents: str) -> dict: - from ruamel.yaml import round_trip_load - - return round_trip_load(contents) + from ruamel.yaml import YAML + return YAML().load(contents) def dumps(self, loaded_contents: dict) -> str: - from ruamel.yaml import round_trip_dump - - return round_trip_dump(loaded_contents) + from ruamel.yaml import YAML + buffer = StringIO() + YAML().dump(loaded_contents, buffer) + return buffer.getvalue() -- cgit v1.2.3