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
from .code_ import Code
from .condition import Condition
from .outils import get_next_param
from .outils import get_next_param, replace_group1
from .executor import Executor
from .bioflowinsighterror import BioFlowInsightError
from . import constant
......@@ -83,7 +83,8 @@ class Call(Executor):
if(param.get_type()=="Call"):
#If it's not a function -> then we rewrite it
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)
code = code.replace(tag_to_add, f"{tag_to_add}\n{new_bit}")
......@@ -91,8 +92,8 @@ class Call(Executor):
elif(param.get_type()=="Operation"):
#If it's an artificial operation -> we don't need to do anything
if(not param.get_artificial_status()):
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)
lines = param.simplify_code().split('\n')
if(len(lines)==1):
new_bit = f"{param_new_name} = {lines[0]}"
......@@ -106,7 +107,8 @@ class Call(Executor):
raise Exception("This shouldn't happen")
None
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()}"
code = code.replace(tag_to_add, f"{tag_to_add}\n{new_bit}")
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