Skip to content

Commit 9bf8baf

Browse files
committed
Switch to ruamel.yaml.
1 parent e275c50 commit 9bf8baf

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

changelog.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Upcoming
22
========
33

4-
* Use pyyaml to format hierarchical info.
4+
* Use ``ruamel.yaml`` to format hierarchical info.
55

66
0.10
77
====

setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
'configobj>=5.0.6',
2525
'pexpect>=3.3',
2626
'fuzzyfinder>=1.0.0',
27-
'PyYAML>=3.13'
27+
'ruamel.yaml>=0.15.72',
2828
],
2929
extras_require={
3030
'testing': [

wharfee/formatter.py

+12-3
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,12 @@
1212
from pygments import highlight
1313
from pygments.lexers.data import JsonLexer
1414
from pygments.formatters.terminal import TerminalFormatter
15-
from yaml import dump
15+
from ruamel.yaml import YAML
16+
17+
try:
18+
from StringIO import StringIO
19+
except ImportError:
20+
from io import StringIO
1621

1722
# Python 3 has no 'basestring' or 'long' type we're checking for.
1823
try:
@@ -212,8 +217,12 @@ def format_data(command, data):
212217

213218

214219
def format_struct(data, indent=4):
215-
text = dump(data, indent=indent, default_flow_style=False)
216-
lines = text.split('\n')
220+
output = StringIO()
221+
yaml = YAML()
222+
yaml.default_flow_style = False
223+
yaml.indent = indent
224+
yaml.dump(data, stream=output)
225+
lines = output.getvalue().split('\n')
217226
return lines
218227

219228

0 commit comments

Comments
 (0)