[ck2cti] Improve error messages for unparsable transport entries
Print the full transport line to aid in identifying the problem
This commit is contained in:
parent
4f4a2bd071
commit
b2acc43a81
2 changed files with 7 additions and 10 deletions
|
|
@ -1953,6 +1953,7 @@ class Parser(object):
|
|||
"""
|
||||
|
||||
for i,line in enumerate(lines):
|
||||
original_line = line
|
||||
line = line.strip()
|
||||
if not line or line.startswith('!'):
|
||||
continue
|
||||
|
|
@ -1966,17 +1967,13 @@ class Parser(object):
|
|||
|
||||
data = line.split()
|
||||
|
||||
if len(data) < 7:
|
||||
raise InputParseError('Unable to parse transport data: not'
|
||||
' enough parameters on line {0} of "{1}".'.format(
|
||||
line_offset + i, filename))
|
||||
if len(data) > 7:
|
||||
raise InputParseError('Extra parameters found in transport entry'
|
||||
' for species "{0}" on line {1} of "{2}"'.format(
|
||||
data[0], line_offset + i, filename))
|
||||
|
||||
speciesName = data[0]
|
||||
if speciesName in self.speciesDict:
|
||||
if len(data) != 7:
|
||||
raise InputParseError('Unable to parse line {0} of {1}:\n"""\n{2}"""\n'
|
||||
'6 transport parameters expected, but found {3}.'.format(
|
||||
line_offset + i, filename, original_line, len(data)-1))
|
||||
|
||||
if self.speciesDict[speciesName].transport is None:
|
||||
self.speciesDict[speciesName].transport = TransportData(*data, comment=comment)
|
||||
else:
|
||||
|
|
|
|||
|
|
@ -349,7 +349,7 @@ class chemkinConverterTest(utilities.CanteraTest):
|
|||
quiet=True)
|
||||
|
||||
def test_transport_extra_column_entries(self):
|
||||
with self.assertRaisesRegex(ck2cti.InputParseError, 'Extra parameters'):
|
||||
with self.assertRaisesRegex(ck2cti.InputParseError, '572.400'):
|
||||
convertMech(pjoin(self.test_data_dir, 'h2o2.inp'),
|
||||
transportFile=pjoin(self.test_data_dir, 'h2o2-extra-column-entries-tran.dat'),
|
||||
outName=pjoin(self.test_work_dir, 'h2o2_extra-column-entries-tran.cti'),
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue