diff --git a/src/subworkflow.py b/src/subworkflow.py index 713ec15a928d32e87970d410a2ee3da3969c4a1c..e8e1a4b2c764fd8528556257cfa152a40ac8768e 100644 --- a/src/subworkflow.py +++ b/src/subworkflow.py @@ -123,17 +123,30 @@ class Subworkflow(Main): for e in self.emit: if(len(e.gives)==1): ch = e.gives[0] - temp = code_after_emit - code_after_emit = replace_group1(code_after_emit, fr"[^\w]({re.escape(ch.get_code())})[^\w]", f"{ch.get_code()}_{name}") - if(temp==code_after_emit): - raise Exception("This shoudn't happen -> code hasn't been replaced") + if(ch.get_type()=="Channel"): + temp = code_after_emit + code_after_emit = replace_group1(code_after_emit, fr"[^\w]({re.escape(ch.get_code())})[^\w]", f"{ch.get_code()}_{name}") + if(temp==code_after_emit): + raise Exception("This shoudn't happen -> code hasn't been replaced") + elif(ch.get_type()=="Emitted"): + #Case it's an emitted -> we don't change anything -> it is already unique (since the ID has been added to the call) + None + else: + raise Exception("This shouldn't happen") else: ch = e.origins[0] - temp = code_after_emit - code_after_emit = replace_group1(code_after_emit, fr"[^\w]({re.escape(ch.get_code())})[^\w]", f"{ch.get_code()}_{name}") - code_up_to_emit+=f"\n{ch.get_code()}_{name} = {ch.get_code()}" - if(temp==code_after_emit): - raise Exception("This shoudn't happen -> code hasn't been replaced") + if(ch.get_type()=="Channel"): + temp = code_after_emit + code_after_emit = replace_group1(code_after_emit, fr"[^\w]({re.escape(ch.get_code())})[^\w]", f"{ch.get_code()}_{name}") + code_up_to_emit+=f"\n{ch.get_code()}_{name} = {ch.get_code()}" + if(temp==code_after_emit): + raise Exception("This shoudn't happen -> code hasn't been replaced") + elif(ch.get_type()=="Emitted"): + #Case it's an emitted -> we don't change anything -> it is already unique (since the ID has been added to the call) + None + else: + raise Exception("This shouldn't happen") + #In the emits replacing the 'ch = ....' by 'ch' and adding 'ch = ....' at the end of the body