Skip to content
Snippets Groups Projects
Commit 78099d8b authored by George Marchment's avatar George Marchment
Browse files

Update to the replacement of parameters -> so it doesn't replace a subset by mistake

parent 9b7b4e3f
No related branches found
No related tags found
No related merge requests found
Pipeline #14451 failed with stage
in 2 minutes and 41 seconds
...@@ -6,7 +6,7 @@ import time ...@@ -6,7 +6,7 @@ import time
from .code_ import Code from .code_ import Code
from .condition import Condition from .condition import Condition
from .outils import get_next_param from .outils import get_next_param, replace_group1
from .executor import Executor from .executor import Executor
from .bioflowinsighterror import BioFlowInsightError from .bioflowinsighterror import BioFlowInsightError
from . import constant from . import constant
...@@ -83,7 +83,8 @@ class Call(Executor): ...@@ -83,7 +83,8 @@ class Call(Executor):
if(param.get_type()=="Call"): if(param.get_type()=="Call"):
#If it's not a function -> then we rewrite it #If it's not a function -> then we rewrite it
if(param.get_first_element_called().get_type()!="Function"): if(param.get_first_element_called().get_type()!="Function"):
code = code.replace(param.get_code(get_OG=True), param_new_name) code = replace_group1(code, fr"[^\w]({re.escape(param.get_code(get_OG=True))})", param_new_name)
#code = code.replace(param.get_code(get_OG=True), param_new_name)
new_bit = param.simplify_code(new_name = param_new_name) new_bit = param.simplify_code(new_name = param_new_name)
code = code.replace(tag_to_add, f"{tag_to_add}\n{new_bit}") code = code.replace(tag_to_add, f"{tag_to_add}\n{new_bit}")
...@@ -91,8 +92,8 @@ class Call(Executor): ...@@ -91,8 +92,8 @@ class Call(Executor):
elif(param.get_type()=="Operation"): elif(param.get_type()=="Operation"):
#If it's an artificial operation -> we don't need to do anything #If it's an artificial operation -> we don't need to do anything
if(not param.get_artificial_status()): if(not param.get_artificial_status()):
code = replace_group1(code, fr"[^\w]({re.escape(param.get_code(get_OG=True))})", param_new_name)
code = code.replace(param.get_code(get_OG=True), param_new_name) #code = code.replace(param.get_code(get_OG=True), param_new_name)
lines = param.simplify_code().split('\n') lines = param.simplify_code().split('\n')
if(len(lines)==1): if(len(lines)==1):
new_bit = f"{param_new_name} = {lines[0]}" new_bit = f"{param_new_name} = {lines[0]}"
...@@ -106,7 +107,8 @@ class Call(Executor): ...@@ -106,7 +107,8 @@ class Call(Executor):
raise Exception("This shouldn't happen") raise Exception("This shouldn't happen")
None None
elif(param.get_type()=="Emitted"): elif(param.get_type()=="Emitted"):
code = code.replace(param.get_code(get_OG=True), param_new_name) code = replace_group1(code, fr"[^\w]({re.escape(param.get_code(get_OG=True))})", param_new_name)
#code = code.replace(param.get_code(get_OG=True), param_new_name)
new_bit = f"{param_new_name} = {param.simplify_code()}" new_bit = f"{param_new_name} = {param.simplify_code()}"
code = code.replace(tag_to_add, f"{tag_to_add}\n{new_bit}") code = code.replace(tag_to_add, f"{tag_to_add}\n{new_bit}")
else: else:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment