From aa591e040a80667e628164eacdd7b8e0385cfe7f Mon Sep 17 00:00:00 2001 From: George Marchment <georgemarchment@yahoo.fr> Date: Mon, 31 Mar 2025 10:10:16 +0200 Subject: [PATCH] Added check to not try and rewrite the same thing (it was creating an error) --- src/workflow.py | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/src/workflow.py b/src/workflow.py index 7e496af..b7497c7 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 -- GitLab