From 6e395b95720a004c20510764de92a355db0412a3 Mon Sep 17 00:00:00 2001 From: George Marchment <georgemarchment@yahoo.fr> Date: Mon, 14 Oct 2024 10:30:08 +0200 Subject: [PATCH] update identification doucle dot operation --- src/operation.py | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/operation.py b/src/operation.py index 47a9fd3..5a90448 100644 --- a/src/operation.py +++ b/src/operation.py @@ -7,7 +7,7 @@ import warnings #- add a list of words illegal for channel eg. [true, process, workflow...] import re -from .outils import get_end_operator, get_end_call +from .outils import get_end_operator, get_end_call, get_curly_count from .code_ import Code from .executor import Executor from .bioflowinsighterror import BioFlowInsightError @@ -718,12 +718,23 @@ class Operation(Executor): # self.calls[str(call)] = call # break - + #Returns if the code if a double dot pattern or not + def check_if_double_dot(self): + pattern = constant.DOUBLE_DOT + is_a_match = bool(re.fullmatch(pattern, self.get_code(clean_pipe = False))) + if(is_a_match): + is_good = True + for match in re.finditer(pattern, self.get_code(clean_pipe = False)): + if(get_curly_count(match.group(2))!=0 or get_curly_count(match.group(3))!=0): + is_good= False + return is_good + + else: + return False def initialise(self): - pattern = constant.DOUBLE_DOT #If the operation is a double dot consition thing - if(bool(re.fullmatch(pattern, self.get_code(clean_pipe = False)))): + if(self.check_if_double_dot()): self.initialise_double_dot() elif(bool(re.fullmatch(constant.DOUBLE_DOT_TUPLE, self.get_code(clean_pipe = False)))): raise BioFlowInsightError(f"A ternary conditional operator was used with an tuple{self.get_string_line(self.get_code(clean_pipe = False))}. BioFlow-Insight doesn't support this yet (see specification list), try defining the operation in a different way.", num=5, origin=self) -- GitLab