Skip to content

Commit

Permalink
Fix usage of latest ruamel.yaml
Browse files Browse the repository at this point in the history
  • Loading branch information
rly committed Oct 26, 2023
1 parent c1552c6 commit 66a0db0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
15 changes: 7 additions & 8 deletions hdmf_docutils/doctools/rst.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,15 +290,14 @@ def spec_to_yaml(spec):
import json
import sys

try:
from ruamel import yaml
except ImportError:
import yaml
from ruamel.yaml import YAML
from ruamel.yaml.compat import StringIO
clean_spec = json.loads(json.dumps(spec, sort_keys=True, indent=4, separators=(',', ': ')))
if sys.version_info[0] == 3:
return yaml.dump(clean_spec, default_flow_style=False)
else:
return yaml.safe_dump(clean_spec, default_flow_style=False)
yaml = YAML(pure=True)
yaml.default_flow_style = False
stream = StringIO()
yaml.dump(clean_spec, stream)
return stream.getvalue()

def add_spec(self, spec):
"""
Expand Down
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
'pillow',
'sphinx',
'sphinx-gallery',
'sphinx_rtd_theme'
'sphinx_rtd_theme',
'ruamel.yaml'
],
'setup_requires': 'pytest-runner',
'packages': find_packages(),
Expand Down

0 comments on commit 66a0db0

Please sign in to comment.