diff options
| author | JaWeRn <j.werner@uib.de> | 2023-11-05 21:03:59 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-11-05 15:03:59 -0500 |
| commit | da23b3c8fb2c9120326e330cab30ed132d5da3a6 (patch) | |
| tree | 7bfdfdc94f0f7bbf02a79b2b8a2c2b4102b6b273 | |
| parent | Update pypi classifiers (diff) | |
| download | config-file-da23b3c8fb2c9120326e330cab30ed132d5da3a6.zip | |
Replace deprecated methods (package ruamel) in the yaml_parser.py (#28)
| -rw-r--r-- | config_file/parsers/yaml_parser.py | 14 |
1 files 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() |