diff --git a/src/workflow.py b/src/workflow.py index 7e496aff14ab9f6942bd8637319ffcbb499fe4e2..b7497c73324ab07a11eff786fd0d917d5bb9e8a0 100644 --- a/src/workflow.py +++ b/src/workflow.py @@ -675,17 +675,30 @@ George Marchment, Bryan Brancotte, Marie Schmit, Frédéric Lemoine, Sarah Cohen new = exe.get_code(get_OG = True).replace(emited.get_code(), emited.get_emits().get_origins()[0].get_code()) #to_replace.append((exe.get_code(get_OG = True), f"{exe.get_gives()[0].get_code()} = {emited.get_emits().get_origins()[0].get_code()}")) to_replace.append((exe.get_code(get_OG = True), new)) + #This dictionnary is used to check if the replacement has already been done (in the case of dupliactes in new) + dico_replace = {} for r in to_replace: old, new = r - temp_code = code - #Case of channel = channel - if(new.find("=")!=-1): - if(new.split("=")[0].strip()==new.split("=")[1].strip()): - new = '' - #code = code.replace(old, new) - code = replace_group1(code, fr"({re.escape(old)})[^\w]", new) - if(temp_code==code): - raise Exception("Something went wrong: The code hasn't changed") + need_to_replace = True + try: + t = dico_replace[old] + if(t==new): + need_to_replace = False + else: + raise Exception("This shouldn't happen") + except: + dico_replace[old]= new + + if(need_to_replace): + temp_code = code + #Case of channel = channel + if(new.find("=")!=-1): + if(new.split("=")[0].strip()==new.split("=")[1].strip()): + new = '' + #code = code.replace(old, new) + code = replace_group1(code, fr"({re.escape(old)})[^\w]", new) + if(temp_code==code): + raise Exception("Something went wrong: The code hasn't changed") return code