1
0
mirror of https://github.com/kellyjonbrazil/jc.git synced 2025-06-25 00:37:31 +02:00

clean up multi-document support

This commit is contained in:
Kelly Brazil
2020-02-03 21:22:30 -08:00
parent 021f8350a3
commit 755a6faf11

View File

@ -31,7 +31,7 @@ class info():
description = 'YAML file parser' description = 'YAML file parser'
author = 'Kelly Brazil' author = 'Kelly Brazil'
author_email = 'kellyjonbrazil@gmail.com' author_email = 'kellyjonbrazil@gmail.com'
details = 'Using the ruamel.yaml library at https://pypi.org/project/ruamel.yaml/' details = 'Using the ruamel.yaml library at https://pypi.org/project/ruamel.yaml'
# compatible options: linux, darwin, cygwin, win32, aix, freebsd # compatible options: linux, darwin, cygwin, win32, aix, freebsd
compatible = ['linux', 'darwin', 'cygwin', 'win32', 'aix', 'freebsd'] compatible = ['linux', 'darwin', 'cygwin', 'win32', 'aix', 'freebsd']
@ -83,13 +83,9 @@ def parse(data, raw=False, quiet=False):
raw_output = [] raw_output = []
# support multiple documents in a file yaml = YAML(typ='safe')
cleandata = data.split('---') for document in yaml.load_all(data):
raw_output.append(document)
if cleandata:
for document in cleandata:
yaml = YAML(typ='safe')
raw_output.append(yaml.load(document))
if raw: if raw:
return raw_output return raw_output