From 9babd60c409b495f494c6db3197402a8de93f4a0 Mon Sep 17 00:00:00 2001 From: George Marchment <georgemarchment@yahoo.fr> Date: Tue, 12 Mar 2024 11:33:42 +0100 Subject: [PATCH] add small error handling --- src/bioflowinsighterror.py | 2 ++ src/nextflow_building_blocks.py | 15 ++++++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/bioflowinsighterror.py b/src/bioflowinsighterror.py index dd222bb..0dfc769 100644 --- a/src/bioflowinsighterror.py +++ b/src/bioflowinsighterror.py @@ -43,6 +43,8 @@ class BioFlowInsightError(Exception): #* [5] -> A ternary conditional operator was used with an tuple #* [7] -> Tuple with emit (ch1, ch2) = emit.out #* [9] -> Tuple with call (ch1, ch2) = wf() +#* [11] -> Failed to extract the operation or call at the line x. Try rewriting it in a simplified version. + diff --git a/src/nextflow_building_blocks.py b/src/nextflow_building_blocks.py index c436bf2..ce5144c 100644 --- a/src/nextflow_building_blocks.py +++ b/src/nextflow_building_blocks.py @@ -318,16 +318,24 @@ class Nextflow_Building_Blocks: if(match.group(1) in constant.LIST_OPERATORS): #TODO -> the function below might not work perfectly but i don't have any other ideas - #TODO -> IMPORTANT find another way of doing this -> for example if there isn't the same number of curlies/parentheses + #Use if there is an operator called right before opening the curlies/parenthse - curly_left, curly_right = get_curly_count(text[:start]), get_curly_count(text[end:]) + #curly_left, curly_right = get_curly_count(text[:start]), get_curly_count(text[end:]) parenthese_left, parenthese_right = get_parenthese_count(text[:start]), get_parenthese_count(text[end:]) #if(curly_left==0 and curly_right==0 and parenthese_left==0 and parenthese_right==0 and (start, end) not in searched): if(parenthese_left==0 and parenthese_right==0 and (start, end) not in searched): searched.append((start, end)) - pot = extract_executor_from_middle(text, start, end) + try: + pot = extract_executor_from_middle(text, start, end) + except: + try: + temp = text[start-10:end+10] + except: + temp = text[start:end] + raise BioFlowInsightError(f"Failed to extract the operation or call{self.get_string_line(temp)}. Try rewriting it in a simplified version.", num = 11, origin=self) + pot = expand_to_pipe_operators(text, pot) #If the thing which is extracted is not in the conditon of an if @@ -360,6 +368,7 @@ class Nextflow_Building_Blocks: self.executors.append(ope) searching = True break + #--------------------------------------------------------------- #STEP4 - Extract the Executors which only use the pipe operators (which start with a channel) -- GitLab