diff options
author | Lars Wirzenius <liw@liw.fi> | 2018-03-17 11:28:16 +0200 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2018-03-17 11:40:02 +0200 |
commit | e302233956c4d6b83392b57c455fc596f1e7a00e (patch) | |
tree | 630153e0d7239b99fa488539d399dc3a0453cf45 | |
parent | e92515e92689e1a9b7950f936758b191bc61c33a (diff) | |
download | extrautils-e302233956c4d6b83392b57c455fc596f1e7a00e.tar.gz |
Fix: represent long string with the | style
-rwxr-xr-x | prettyml | 10 |
1 files changed, 10 insertions, 0 deletions
@@ -13,6 +13,16 @@ def inputs(args): yield '-', sys.stdin +def string_representer(dumper, data): + style = None + if '\n' in data: + style = '|' + return dumper.represent_scalar('tag:yaml.org,2002:str', data, style=style) + + +yaml.add_representer(str, string_representer, Dumper=yaml.SafeDumper) + + objs = [] for filename, f in inputs(sys.argv[1:]): objs.append(yaml.load(f, Loader=yaml.CSafeLoader)) |