Skip to content

Commit

Permalink
fix: fixed handling of comments in XPP files
Browse files Browse the repository at this point in the history
  • Loading branch information
jonrkarr committed Feb 27, 2022
1 parent f28f3cb commit 7db687a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
2 changes: 1 addition & 1 deletion biosimulators_utils/_version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '0.1.165'
__version__ = '0.1.166'
16 changes: 12 additions & 4 deletions biosimulators_utils/model_lang/xpp/validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -702,10 +702,18 @@ def sanitize_model(filename, keep_only_directives=True, exclude_options=None):

with open(sanitized_filename, 'wb') as sanitized_file:
for statement in statements:
i_comment = statement.find(b'#')
if i_comment > -1:
statement = statement[0:i_comment]
statement = statement.strip() + b'\n'
statement = statement.lstrip()
if (
statement.startswith(b'@')
or statement.startswith(b'p ')
or statement.startswith(b'par ')
or statement.startswith(b'param ')
or statement.startswith(b'#')
):
i_comment = statement.find(b'#')
if i_comment > -1:
statement = statement[0:i_comment]
statement = statement.strip() + b'\n'

if not keep_only_directives and statement.lower().startswith(b'only '):
continue
Expand Down

0 comments on commit 7db687a

Please sign in to comment.