Skip to content

Commit

Permalink
pyneuroml/sbml/__init__.py now passing flake8 and black
Browse files Browse the repository at this point in the history
  • Loading branch information
robertvi committed Oct 30, 2023
1 parent 50d45e3 commit 375e4ee
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
26 changes: 13 additions & 13 deletions pyneuroml/sbml/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,30 @@

import os
import libsbml
from libsbml import SBMLDocument, SBMLReader
from libsbml import SBMLReader
from typing import List

def validate_sbml_files(input_files : str,units_consistency: bool = False):
'''

def validate_sbml_files(input_files: str, units_consistency: bool = False):
"""
validate each input file using libsbml.SBMLDocument.checkConsistency
input_files is a space separated list of one or more filepaths
'''
"""

for file_name in input_files.split():
if not os.path.isfile(file_name):
raise OSError(
("Could not find SBML file %s" % file_name)
)
raise OSError(("Could not find SBML file %s" % file_name))

try:
reader = SBMLReader()
doc = reader.readSBML(file_name)
except:
raise OSError(
("SBMLReader failed to load the file %s" % file_name)
)
except Exception:
raise OSError(("SBMLReader failed to load the file %s" % file_name))

# set the unit checking, similar for the other settings
doc.setConsistencyChecks(libsbml.LIBSBML_CAT_UNITS_CONSISTENCY, units_consistency)
doc.setConsistencyChecks(
libsbml.LIBSBML_CAT_UNITS_CONSISTENCY, units_consistency
)
doc.checkConsistency()
# get errors/warnings
n_errors: int = doc.getNumErrors()
Expand Down Expand Up @@ -61,4 +61,4 @@ def validate_sbml_files(input_files : str,units_consistency: bool = False):
print(
f"[{error.getSeverityAsString()}] {error.getShortMessage()} | {error.getMessage()}"
)
print("-" * 80)
print("-" * 80)
2 changes: 1 addition & 1 deletion tests/sbml/test_sbml.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

from pyneuroml import sbml

fname = "test_data/test_doc.sbml"
fname = "tests/sbml/test_data/test_doc.sbml"
doc = sbml.validate_sbml_files(fname)

0 comments on commit 375e4ee

Please sign in to comment.