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 076ca57
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 12 deletions.
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 076ca57

Please sign in to comment.