From 9541b3c58e0b64307668b2cc687dcec991610986 Mon Sep 17 00:00:00 2001 From: George Marchment <georgemarchment@yahoo.fr> Date: Tue, 22 Apr 2025 16:05:17 +0200 Subject: [PATCH] Added filter to flag when a condition is not written correctly --- src/outils.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/outils.py b/src/outils.py index a5d8d5c..a4da11a 100644 --- a/src/outils.py +++ b/src/outils.py @@ -996,8 +996,11 @@ def extract_conditions(code, only_get_inside = True): searching_for_else = False conditions = [] if(code[start:start+2]=="if" and [quote_single, quote_double, triple_single, triple_double]==[False, False, False, False]): - - for match in re.finditer(r"if *\(((.|\n)+)\)\s*\{", code[start:]): + for match in re.finditer(r"if *\([^{]+\n", code[start:]): + if(match.span(0)[0]==0): + raise BioFlowInsightError(f"The condition '({match.group(0).strip()}' was not extracted correctly. It's perhaps due to the jump line in the condition. Make sure the condition follows the correct syntaxe.", type="Unable to extract condition") + + for match in re.finditer(r"if *\((.+)\)\s*\{", code[start:]): if(match.span(0)[0]==0): found_if_bloc = True condition = match.group(1) -- GitLab