From 22a49d75cbe5b5c7935603695e48a56b78503af8 Mon Sep 17 00:00:00 2001 From: George Marchment <georgemarchment@yahoo.fr> Date: Thu, 17 Apr 2025 12:30:40 +0200 Subject: [PATCH] Added filter Multi ternary operation --- src/code_.py | 7 +++++++ src/workflow.py | 11 +++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/code_.py b/src/code_.py index f5a3250..519be9e 100644 --- a/src/code_.py +++ b/src/code_.py @@ -194,7 +194,14 @@ class Code: for r in to_replace: old, new = r self.add_to_ternary_operation_dico(old, new) + tmp = code code = code.replace(old, new) + if(old!=new and tmp==code): + raise Exception("This shouldn't happen -> the code wasn't replaced") + #Check if there is still a ternary operation in this case we cannot analyse it + #Cause it is a complexe/multiple ternanry operation + for match in re.finditer(pattern, code): + raise BioFlowInsightError("Detected a multi ternary operation (a ternary operation in a ternary operation). BioFlow-Insight does not support this, try defining it in a different way.", type="Multi ternary operation") return code def rewrite_jump_dot(self, code): diff --git a/src/workflow.py b/src/workflow.py index 73c97d7..976170d 100644 --- a/src/workflow.py +++ b/src/workflow.py @@ -761,8 +761,12 @@ George Marchment, Bryan Brancotte, Marie Schmit, Frédéric Lemoine, Sarah Cohen raise Exception("This shoudn't happen -> either a call to a process or subworkflow outside of main or subworkflow") #Simplifying main - code = code.replace(self.get_workflow_main().get_code(get_OG = True), self.get_workflow_main().simplify_code()) - + tmp = code + old = self.get_workflow_main().get_code(get_OG = True) + new = self.get_workflow_main().simplify_code() + code = code.replace(old, new) + if(tmp==code and old!=new): + raise Exception("This shouldn't happen -> code not replaced") #Adding processes into code for p in processes: @@ -872,7 +876,10 @@ George Marchment, Bryan Brancotte, Marie Schmit, Frédéric Lemoine, Sarah Cohen def rewrite_subworkflow_call(self, code, subworklfow): #Remove the defintion from the code + tmp = code code = code.replace(subworklfow.get_code(get_OG = True), "") + if(tmp==code): + raise Exception("This shouldn't happen") OG_call = subworklfow.get_call() OG_body = subworklfow.get_work() -- GitLab