mirror of
https://github.com/Cantera/cantera.git
synced 2025-02-25 18:55:29 -06:00
[YAML] Append rather than replace extra description
This commit is contained in:
committed by
Bryan W. Weber
parent
1a081d12db
commit
efe17fd81a
@@ -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))
|
||||
|
||||
@@ -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())
|
||||
|
||||
|
||||
Reference in New Issue
Block a user