From a5f2b1ad691c192e456e2c0b5d208d921a933a4f Mon Sep 17 00:00:00 2001 From: Dave Beck Date: Thu, 21 Nov 2019 08:53:37 -0800 Subject: [PATCH] Report errors detected in SBML when parsing Prior to this change, the checkSBMLDocument function in SBMLLint/common/util.py would check if the error count during parsing of the document was non-zero and raise a ValueError if so. This change still raises a ValueError, but it adds the contents of the python-libsml error log to the ValueError to the message parameter to enable users to identify and correct parsing errors. In addition, this change modifies the lint function in SBMLLint/tools/sbmllint.py to pass the name of the SBML file that is currently being parsed to the call to checkSBMLDocument so that the ValueError can report the model filename in the expression parameter, rather than an empty string. --- SBMLLint/common/util.py | 4 ++-- SBMLLint/tools/sbmllint.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/SBMLLint/common/util.py b/SBMLLint/common/util.py index ac50281..6aff821 100644 --- a/SBMLLint/common/util.py +++ b/SBMLLint/common/util.py @@ -86,5 +86,5 @@ def uniqueify(collection): def checkSBMLDocument(document, model_reference=""): if (document.getNumErrors() > 0): - raise ValueError("Errors in SBML document\n%s" - % model_reference) + raise ValueError("Errors in SBML document\n%s" + % model_reference, document.getErrorLog().toString()) diff --git a/SBMLLint/tools/sbmllint.py b/SBMLLint/tools/sbmllint.py index 15d8f23..112e686 100644 --- a/SBMLLint/tools/sbmllint.py +++ b/SBMLLint/tools/sbmllint.py @@ -46,7 +46,7 @@ def lint(model_reference, file_out=sys.stdout, xml = util.getXML(model_reference) reader = tesbml.SBMLReader() document = reader.readSBMLFromString(xml) - util.checkSBMLDocument(document) + util.checkSBMLDocument(document, model_reference) model = document.getModel() # if mass_balance_check==STRUCTURED_NAMES: