[ck2cti] Show name of species with undefined elements in error message

This commit is contained in:
Ray Speth 2019-02-18 16:25:30 -05:00
parent aa9721dbe9
commit d04fd8cc39

View file

@ -1995,17 +1995,16 @@ class Parser(object):
def getSpeciesString(self, speciesList, indent):
speciesNameLength = 1
elementsFromSpecies = set()
allElements = set(self.elements)
for s in speciesList:
if s.composition is None:
raise InputParseError('No thermo data found for species: {0!r}'.format(s.label))
elementsFromSpecies.update(s.composition)
missingElements = set(s.composition) - allElements
if missingElements:
raise InputParseError("Undefined elements in species '{}':"
" {}".format(s.label, ','.join(repr(e) for e in missingElements)))
speciesNameLength = max(speciesNameLength, len(s.label))
missingElements = elementsFromSpecies - set(self.elements)
if missingElements:
raise InputParseError('Undefined elements: ' + str(missingElements))
speciesNames = ['']
speciesPerLine = max(int((80-indent)/(speciesNameLength + 2)), 1)