Skip to content
Snippets Groups Projects
Commit 359ecbfb authored by George Marchment's avatar George Marchment
Browse files

Added filter to flag when a condition is not extracted correctly

parent 74de56c5
No related branches found
No related tags found
No related merge requests found
Pipeline #14655 failed with stage
in 2 minutes and 36 seconds
from .outils import remove_comments, get_parenthese_count, get_curly_count, get_code_until_parenthese_count, extract_curly
from .outils import remove_comments, get_parenthese_count, get_curly_count, get_code_until_parenthese_count, extract_curly, get_next_element_caracter
from .bioflowinsighterror import BioFlowInsightError
import re
from . import constant
......@@ -100,6 +100,7 @@ class Code:
temp_code = code[start:]
for match in re.finditer(pattern, temp_code):
if(match.span(0)[0]==0):
_, end_line = match.span(0)
found_if_bloc = True
all = match.group(0)
extarcted = match.group(2).strip()
......@@ -113,6 +114,12 @@ class Code:
if(body!="" and body[0]!="{"):
new = f"if ({condition}) {{\n{body}\n}}\n"
to_replace.append((all, new))
elif(body==""):
char, pos = get_next_element_caracter(temp_code, end_line)
if(char!="{"):
raise BioFlowInsightError(f"The condition '({extracted_condition}' was not extracted correctly. Make sure the condition follows the correct syntaxe.", type="Unable to extract condition")
start+=1
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment