diff --git a/src/workflow.py b/src/workflow.py index b673fc232f33f73c39fa36657934ce1e97ce6535..878d5652d49339780ba15a59144952b39e6187d8 100644 --- a/src/workflow.py +++ b/src/workflow.py @@ -989,6 +989,7 @@ George Marchment, Bryan Brancotte, Marie Schmit, Frédéric Lemoine, Sarah Cohen emits = subworklfow.get_emit() to_replace = [] all_executors = self.get_workflow_main().get_all_executors_in_workflow() + index = 0 for exe in all_executors: #We don't need to check the case call since the workflow has already been rewriteen -> emits only appear in operations if(exe.get_type()=="Operation"): @@ -999,7 +1000,15 @@ George Marchment, Bryan Brancotte, Marie Schmit, Frédéric Lemoine, Sarah Cohen if(emited.get_emitted_by().get_first_element_called()==subworklfow): if(emited.get_emits() not in emits): raise Exception("This shoudn't happen -> since it is the actual subworkflow") - new = new.replace(emited.get_code(), emited.get_emits().get_origins()[0].get_code()) + if(len(emited.get_emits().get_origins())==1): + new = new.replace(emited.get_code(), emited.get_emits().get_origins()[0].get_code()) + else: + #If there are multiple things taken in the emit (if its a complexe operation -> then we create a temporary variable) + param_temp = f"temp_emit_{subworklfow.get_alias_and_id()}_{index}" + first_line = f"{param_temp} = {emited.emits.get_code(get_OG = True)}" + new = new.replace(emited.get_code(), param_temp) + new = first_line+"\n"+new + index+=1 added = True #to_replace.append((exe.get_code(get_OG = True), f"{exe.get_gives()[0].get_code()} = {emited.get_emits().get_origins()[0].get_code()}")) if(added):