[YAML] Append rather than replace extra description

This commit is contained in:
Ingmar Schoegl
2020-02-10 09:35:53 -06:00
committed by Bryan W. Weber
parent 1a081d12db
commit efe17fd81a
2 changed files with 7 additions and 6 deletions

View File

@@ -39,8 +39,8 @@ duplicate transport data) to be ignored. The '--name=<name>' option
is used to override default phase names (i.e. 'gas').
The '--extra=<filename>' option takes a YAML file as input. This option can be
used to specify an alternative file description, or to define custom fields that
are included in the YAML output.
used to add to the file description, or to define custom fields that are
included in the YAML output.
"""
from collections import defaultdict, OrderedDict
@@ -1355,7 +1355,9 @@ class Parser:
# replace header lines
if 'description' in yml:
if isinstance(yml['description'], str):
self.header_lines = yml.pop('description').split('\n')
if self.header_lines:
self.header_lines += ['']
self.header_lines += yml.pop('description').split('\n')
else:
raise InputError("The alternate description provided in "
"'{}' needs to be a string".format(path))

View File

@@ -454,9 +454,8 @@ class ck2yamlTest(converterTestCommon, utilities.CanteraTest):
with open(output, 'rt', encoding="utf-8") as stream:
yml = yaml.safe_load(stream)
desc = yml['description']
self.assertEqual(yml['description'],
'This is an alternative description.')
desc = yml['description'].split('\n')[-1]
self.assertEqual(desc, 'This is an alternative description.')
for key in ['foo', 'bar']:
self.assertIn(key, yml.keys())