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

Just cleaning up a bit

parent 6af425b8
No related branches found
No related tags found
No related merge requests found
Pipeline #14234 failed with stage
in 2 minutes and 17 seconds
...@@ -11,7 +11,6 @@ class BioFlowInsightError(Exception): ...@@ -11,7 +11,6 @@ class BioFlowInsightError(Exception):
""" """
def __init__(self, error, num, origin = None): def __init__(self, error, num, origin = None):
self.origin = origin self.origin = origin
#TODO -> add message at the end
if(origin!=None): if(origin!=None):
super().__init__(f"[{num}] Error in the file '{self.origin.get_file_address()}': "+error) super().__init__(f"[{num}] Error in the file '{self.origin.get_file_address()}': "+error)
else: else:
......
...@@ -16,6 +16,8 @@ class Condition: ...@@ -16,6 +16,8 @@ class Condition:
conditions_dico = self.origin.get_file_conditions() conditions_dico = self.origin.get_file_conditions()
#conditions_dico_temp = extract_conditions(code)
#print(conditions_dico==conditions_dico_temp)
pos = code.find(thing_defined) pos = code.find(thing_defined)
for c in conditions_dico: for c in conditions_dico:
condition_extend = conditions_dico[c] condition_extend = conditions_dico[c]
......
...@@ -125,8 +125,6 @@ class Include(Nextflow_Building_Blocks): ...@@ -125,8 +125,6 @@ class Include(Nextflow_Building_Blocks):
for match in re.finditer(pattern_as, include): for match in re.finditer(pattern_as, include):
found = True found = True
if(self.get_duplicate_status()): if(self.get_duplicate_status()):
#TODO -> try shallow copy too
#thing_as = copy.copy(self.file.get_element_from_name(match.group(1)))
thing_as = copy.deepcopy(self.file.get_element_from_name(match.group(1))) thing_as = copy.deepcopy(self.file.get_element_from_name(match.group(1)))
thing_as.set_alias(match.group(3)) thing_as.set_alias(match.group(3))
self.defines.append(thing_as) self.defines.append(thing_as)
......
from .nextflow_building_blocks import Nextflow_Building_Blocks from .nextflow_building_blocks import Nextflow_Building_Blocks
from .bioflowinsighterror import BioFlowInsightError from .bioflowinsighterror import BioFlowInsightError
import re import re
from .outils import get_dico_from_tab_from_id from .outils import get_dico_from_tab_from_id, extract_conditions
from . import constant from . import constant
class Main_DSL2(Nextflow_Building_Blocks): class Main_DSL2(Nextflow_Building_Blocks):
def __init__(self, code, origin): def __init__(self, code, origin):
Nextflow_Building_Blocks.__init__(self, code) Nextflow_Building_Blocks.__init__(self, code)
self.origin = origin self.origin = origin
self.calls = [] self.calls = []
self.initialised = False self.initialised = False
self.conditions=None
def get_channels(self): def get_channels(self):
return self.channels return self.channels
def get_workflow_code(self): def get_workflow_code(self):
return self.get_code() return self.get_code()
def get_file_conditions(self):
if(self.conditions==None):
self.conditions = extract_conditions(self.get_code())
return self.conditions
def get_type(self): def get_type(self):
return "Main DSL2" return "Main DSL2"
......
...@@ -37,9 +37,8 @@ class Nextflow_File(Nextflow_Building_Blocks): ...@@ -37,9 +37,8 @@ class Nextflow_File(Nextflow_Building_Blocks):
if(self.first_file==True): if(self.first_file==True):
self.origin.set_DSL(self.which_DSL()) self.origin.set_DSL(self.which_DSL())
self.graph = None self.graph = None
self.conditions = extract_conditions(self.get_code())
self.added_2_rocrate = False self.added_2_rocrate = False
self.conditions=None
self.check_file_correctness() self.check_file_correctness()
self.do_start_stuff() self.do_start_stuff()
#self.extract_metadata() #self.extract_metadata()
...@@ -55,6 +54,8 @@ class Nextflow_File(Nextflow_Building_Blocks): ...@@ -55,6 +54,8 @@ class Nextflow_File(Nextflow_Building_Blocks):
return self.get_code() return self.get_code()
def get_file_conditions(self): def get_file_conditions(self):
if(self.conditions==None):
self.conditions = extract_conditions(self.get_code())
return self.conditions return self.conditions
...@@ -237,16 +238,14 @@ class Nextflow_File(Nextflow_Building_Blocks): ...@@ -237,16 +238,14 @@ class Nextflow_File(Nextflow_Building_Blocks):
def which_DSL(self): def which_DSL(self):
DSL = "DSL2" DSL = "DSL2"
#If there are include #If there are include
self.extract_includes() pattern = constant.FULL_INLCUDE_2
if(len(self.includes)>0): for match in re.finditer(pattern, self.get_code()):
return DSL return DSL
#If there are subworkflows #If there are subworkflows
self.extract_subworkflows() for match in re.finditer(constant.SUBWORKFLOW_HEADER, self.get_code()):
if(len(self.subworkflows)>0):
return DSL return DSL
#If there is the main #If there is the main
self.extract_main() for match in re.finditer(constant.WORKFLOW_HEADER_2, '\n'+self.get_code()+'\n'):
if(self.main!=None):
return DSL return DSL
#Analyse the processes #Analyse the processes
self.extract_processes() self.extract_processes()
......
...@@ -975,9 +975,7 @@ def extract_conditions(code): ...@@ -975,9 +975,7 @@ def extract_conditions(code):
if(code[start-1]!="\\" or (code[start-1]=="\\" and code[start-2]=="\\")): if(code[start-1]!="\\" or (code[start-1]=="\\" and code[start-2]=="\\")):
quote_double=False quote_double=False
#TODO add "else if" compatibaliaty
#TODO Right now -> support only for if/else written with curlies -> not on single line #TODO Right now -> support only for if/else written with curlies -> not on single line
def adding_inside(conditions_dico, code, start_inside, end_inside): def adding_inside(conditions_dico, code, start_inside, end_inside):
temp_dico = extract_conditions(code[start_inside:end_inside]) temp_dico = extract_conditions(code[start_inside:end_inside])
for c in temp_dico: for c in temp_dico:
......
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