From 55d474f5fdca8a88bed1395b36d45a6678af2cb1 Mon Sep 17 00:00:00 2001 From: George Marchment <georgemarchment@yahoo.fr> Date: Tue, 1 Apr 2025 10:52:46 +0200 Subject: [PATCH] Update function "remove_empty_conditions_place_anker" -> removing the process so that the conditions inside process are not extracted --- src/outils.py | 14 +++++++++++--- src/workflow.py | 5 ++--- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/outils.py b/src/outils.py index c5d6769..32c7aa9 100644 --- a/src/outils.py +++ b/src/outils.py @@ -922,7 +922,6 @@ def is_git_directory(path = '.'): #TODO -> need to update this -> if the same condition appears multiple times in the code -> in the dico it is only counted once #Right now the function is not recursif -> since i call blocks recursively and that this function is only used by blocks -> it is indirectrly called recursiverly def extract_conditions(code, only_get_inside = True): - conditions_dico = {} index_condition = 0 @@ -1367,8 +1366,17 @@ def remove_empty_conditions(code): return code #This function removes the empty conditions -> while keeping the anker_clusters -> if it's orignally in a condtion -def remove_empty_conditions_place_anker(code): - conditions = extract_conditions(code) +def remove_empty_conditions_place_anker(code, workflow): + #We remove the processes and functions from the code so that the conditions in the processes are not extracted + temp_code = code + for m in workflow.get_first_file().get_modules_defined(): + if(m.get_type() in ["Process", "Function"]): + tmp = temp_code + temp_code = temp_code.replace(m.get_code(), "a"*len(m.get_code())) + if(tmp==temp_code): + raise Exception("Something went wrong -> the code was not updated") + + conditions = extract_conditions(temp_code) OG_anker= "//Anker_clusters" pos = code.find(OG_anker) conditions_containing_anker = [] diff --git a/src/workflow.py b/src/workflow.py index 9c0c736..dd66787 100644 --- a/src/workflow.py +++ b/src/workflow.py @@ -365,6 +365,7 @@ George Marchment, Bryan Brancotte, Marie Schmit, Frédéric Lemoine, Sarah Cohen #Putting || back code = code.replace("$OR$", "||") + #put_modified_operations_back #TODO -> add the other things necessary to reformat code #Somethimes this is incorrect but that's due to the fact that the DSL1 analysis isn't as clean as the DSL2 analyse (concerning the conditions) @@ -809,9 +810,7 @@ George Marchment, Bryan Brancotte, Marie Schmit, Frédéric Lemoine, Sarah Cohen ternary_operation_dico = self.ternary_operation_dico map_element_dico = self.map_element_dico - - if(self.duplicate): #First check if there are any duplicate operations #That method is in the "get_order_execution_executors" method -> so we just run that first @@ -965,7 +964,7 @@ George Marchment, Bryan Brancotte, Marie Schmit, Frédéric Lemoine, Sarah Cohen raise Exception("This shoudn't happen") #Remove the empty conditions left in the code - code = remove_empty_conditions_place_anker(code) + code = remove_empty_conditions_place_anker(code, self) #Add the subworkflow defintions -- GitLab