From 195e10203217eb9772afc1d6f428a9805b1b9d09 Mon Sep 17 00:00:00 2001 From: George Marchment <georgemarchment@yahoo.fr> Date: Wed, 19 Mar 2025 11:03:00 +0100 Subject: [PATCH] Update the extarct emits -> it wans't working correctly (it works on 404 and 314) --- src/emitted.py | 2 +- src/operation.py | 40 ++++++++++++++++++++++++++++++++++++---- 2 files changed, 37 insertions(+), 5 deletions(-) diff --git a/src/emitted.py b/src/emitted.py index b29a0fa..b5c93ed 100644 --- a/src/emitted.py +++ b/src/emitted.py @@ -75,7 +75,7 @@ class Emitted(Channel): else: if(thing_which_emits.get_type()=='Subworkflow'): if(len(thing_which_emits.emit)!=1): - raise BioFlowInsightError(f"One channel was expected in the emit '{self.get_code()}'. Even though multiple emits are defined for the workflow '{self.emitted_by.get_name()}'", num=6, origin=self) + raise BioFlowInsightError(f"One channel was expected in the emit '{self.get_code()}'. Even though multiple emits are defined for the workflow '{self.emitted_by.get_first_element_called().get_name()}'", num=6, origin=self) self.emits = thing_which_emits.emit[0] else: raise Exception("This shoudn't happen!") diff --git a/src/operation.py b/src/operation.py index ef5b570..7d2b11c 100644 --- a/src/operation.py +++ b/src/operation.py @@ -297,6 +297,30 @@ class Operation(Executor): if(bool(re.fullmatch(r"\( *\w+ *(\, *\w+)+ *\) *= *Call_\d+", operation.strip()))): raise BioFlowInsightError(f"A tuple is associated with an call{self.get_string_line(self.get_code(get_OG= True))}. BioFlow-Insight doesn't support this (see specification list), try defining the operation in a different way.", num=9, origin=self) + searching_for_emits = True + while(searching_for_emits): + searching_for_emits = False + stop_pattern_search = False + for pattern in [constant.EMIT_NAME, constant.EMIT_TAB, constant.EMIT_ALONE]: + for match in re.finditer(pattern, operation+" "): + try: + full_code, name_called, name_emitted = match.group(0), match.group(1), match.group(3) + except: + full_code, name_called, name_emitted = match.group(0)[:-1], match.group(1), "" + if(name_emitted==""): + self.add_origin_emits(full_code, name_called, "") + if(name_emitted in constant.LIST_OPERATORS): + full_code = '.'.join(full_code.split(".")[:-1]) + self.add_origin_emits(full_code, name_called, "") + else: + self.add_origin_emits(full_code, name_called, name_emitted) + operation = operation.replace(full_code, "") + searching_for_emits = True + stop_pattern_search = True + break + if(stop_pattern_search): + break + case_operation_starts_with_emit = False #--------------------------- @@ -384,11 +408,19 @@ class Operation(Executor): #TODO -> check this #I've changed this to avoid problems like this : "ch_svdb_dbs.out_occs.toList()" for match in re.finditer(constant.EMIT_OPERATION, operation+" "): + #full_code, name_called = match.group(1), match.group(2) + #self.add_origin_emits(full_code, name_called, "") + ##Remove the emit from the operation code -> so we don't extract it agian + #operation = operation.replace(full_code, "") + + #Old full_code, name_called = match.group(1), match.group(2) - self.add_origin_emits(full_code, name_called, "") - #Remove the emit from the operation code -> so we don't extract it agian - operation = operation.replace(full_code, "") - + #Check that it's a the begining of the operation + operation_until_out = operation[:operation.find("out")] + if(operation_until_out==full_code[:full_code.find("out")]): + self.add_origin_emits(full_code, name_called, "") + case_operation_starts_with_emit = True + operation = operation.replace(full_code, "") -- GitLab