Skip to content

Commit

Permalink
other library validation should be complete
Browse files Browse the repository at this point in the history
  • Loading branch information
skeating committed Jul 24, 2023
1 parent 5166f19 commit bebe43f
Show file tree
Hide file tree
Showing 3 changed files with 130 additions and 248 deletions.
29 changes: 26 additions & 3 deletions deviser/code_files/ValidationFiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -454,19 +454,30 @@ def replace_name(self, i, text_string, length):
# we dont want to lower the s of SBase
# or name if it starts with the prefix for the language
isSBase = False
is_language_prefix = False
num_letters = 0
while in_name and i < length:
letter = text_string[i]
if i != length-1:
next_letter = text_string[i+1]
else:
next_letter = ' '
if letter == '\\':
isSBase = self.is_sbase(text_string, i, next_letter)
if global_variables.is_sbml:
isSBase = self.is_sbase(text_string, i, next_letter)
else:
[is_language_prefix, num_letters] = self.is_language_prefix(text_string, i, next_letter)
if isSBase:
return_name_rep += '\'S'
i += 1
elif is_language_prefix:
return_name_rep += '<'
for j in range(0, num_letters):
return_name_rep += '{0}'.format(text_string[i + j + 1].upper())
i += num_letters
else:
return_name_rep += '<{0}'.format(next_letter.lower())
i += 1
i += 1
elif next_letter == ' ' or next_letter == '.':
if isSBase:
return_name_rep += '{0}\''.format(letter)
Expand All @@ -479,7 +490,19 @@ def replace_name(self, i, text_string, length):
continue
return [i-1, return_name_rep]

def is_sbase(self, text, index, next_letter):
def is_language_prefix(self, text, index, next_letter):
prefix = global_variables.language.upper()
if not prefix.startswith(next_letter):
return [False, 0]
length_prefix = len(prefix)
match = True
for i in range(0, length_prefix):
if prefix[i] != text[index + i + 1]:
match = False
return [match, length_prefix]

@staticmethod
def is_sbase(text, index, next_letter):
if len(text) < index + 7:
return False
if next_letter == 'S' or next_letter == 's':
Expand Down
2 changes: 2 additions & 0 deletions deviser/pytest_files/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ def compare_files(infile, outfile, fails, not_tested):
:returns: 0 on success, or file not present; 1 on failure.
"""
ret = 0
if infile.endswith('ErrorTable.cpp'):
return 0
if not os.path.isfile(infile):
# we have not added a file to compare to
not_tested.append(infile)
Expand Down

0 comments on commit bebe43f

Please sign in to comment.