From b9ca3b755071c379bd678cecb56a050e763f5521 Mon Sep 17 00:00:00 2001 From: Thomas Nixon Date: Tue, 27 Jun 2023 15:12:30 +0100 Subject: [PATCH] switch from ruamel.yaml to PyYAML --- CHANGELOG.md | 2 ++ ear/compatibility.py | 28 ++++++++++++++++++---------- flake.nix | 2 +- setup.py | 2 +- 4 files changed, 22 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 193a3ed5..e1dde1bd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ ### Changed - Added a warning for audioBlockFormats which have a duration but no rtime; previously these were fixed silently. See [#54]. +- Switched from ruamel.yaml to PyYAML. See [#62]. ## [2.1.0] - 2022-01-26 @@ -153,6 +154,7 @@ Initial release. [#45]: https://github.com/ebu/ebu_adm_renderer/pull/45 [#48]: https://github.com/ebu/ebu_adm_renderer/pull/48 [#54]: https://github.com/ebu/ebu_adm_renderer/pull/54 +[#62]: https://github.com/ebu/ebu_adm_renderer/pull/62 [34b738a]: https://github.com/ebu/ebu_adm_renderer/commit/34b738a [04533fc]: https://github.com/ebu/ebu_adm_renderer/commit/04533fc [222374a]: https://github.com/ebu/ebu_adm_renderer/commit/222374a diff --git a/ear/compatibility.py b/ear/compatibility.py index 88c9e3af..99ead007 100644 --- a/ear/compatibility.py +++ b/ear/compatibility.py @@ -11,20 +11,28 @@ def write_bytes_to_stdout(b): def load_yaml(stream): """load yaml from a file-like object; used to make it easier to cater to - API changes in ruamel.yaml + API changes in the yaml library """ - from ruamel.yaml import YAML + import yaml - yaml = YAML(typ="safe", pure=True) - return yaml.load(stream) + return yaml.load(stream, Loader=yaml.Loader) def dump_yaml_str(yaml_obj): """stringify some yaml""" - from ruamel.yaml import YAML - from six import StringIO + import yaml - yaml = YAML(typ="safe", pure=True) - f = StringIO() - yaml.dump(yaml_obj, f) - return f.getvalue() + return yaml.dump(yaml_obj) + + +def test_yaml(): + from io import StringIO + + obj = {"some": "yaml"} + + yaml_str = dump_yaml_str(obj) + + f = StringIO(yaml_str) + parsed_obj = load_yaml(f) + + assert parsed_obj == obj diff --git a/flake.nix b/flake.nix index b38714c5..d4457f9e 100644 --- a/flake.nix +++ b/flake.nix @@ -12,7 +12,7 @@ packages.ear = python3.pkgs.buildPythonPackage rec { name = "ear"; src = ./.; - propagatedBuildInputs = with python3.pkgs; [ numpy scipy enum34 six attrs multipledispatch lxml ruamel_yaml setuptools ]; + propagatedBuildInputs = with python3.pkgs; [ numpy scipy enum34 six attrs multipledispatch lxml pyyaml setuptools ]; doCheck = true; checkInputs = with python3.pkgs; [ pytest pytest-cov pytest-datafiles soundfile ]; postPatch = '' diff --git a/setup.py b/setup.py index d4332cc9..4249e44d 100644 --- a/setup.py +++ b/setup.py @@ -18,7 +18,7 @@ 'numpy~=1.14', 'scipy~=1.0', 'attrs>=19.3,<22', - 'ruamel.yaml~=0.15', + 'PyYAML~=6.0', 'lxml~=4.4', 'six~=1.11', 'multipledispatch~=0.5',