Skip to content

Commit

Permalink
switch from ruamel.yaml to PyYAML
Browse files Browse the repository at this point in the history
  • Loading branch information
tomjnixon committed Aug 30, 2023
1 parent 9e9327b commit b9ca3b7
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 12 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down
28 changes: 18 additions & 10 deletions ear/compatibility.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ''
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down

0 comments on commit b9ca3b7

Please sign in to comment.