From e37c9a29bcfccb9abf8434c0f50702568ee2bebb Mon Sep 17 00:00:00 2001 From: George Marchment <georgemarchment@yahoo.fr> Date: Tue, 11 Feb 2025 10:29:00 +0100 Subject: [PATCH] Updated the search for executors and blocks to have them in a better order --- src/root.py | 38 +++++++++++++++++++++++++------------- 1 file changed, 25 insertions(+), 13 deletions(-) diff --git a/src/root.py b/src/root.py index 3292fdc..250ec9f 100644 --- a/src/root.py +++ b/src/root.py @@ -227,23 +227,35 @@ class Root(Nextflow_Building_Blocks): self.extract_executors() - #TODO i need to sort the execution order out + #This is to get the order of execution + code = self.get_code() position_2_thing_2_analyse = {} for block in self.blocks: - pos = code.find(block.get_code()) - if(pos!=-1): - position_2_thing_2_analyse[pos] = block - code = code.replace(block.get_code(), "a"*len(block.get_code()), 1) - else: + block_code = block.get_code() + found = False + while(not found or len(block_code)==0): + pos = code.find(block_code) + if(pos!=-1): + position_2_thing_2_analyse[pos] = block + code = code.replace(block_code, "a"*len(block_code), 1) + found = True + else: + block_code = block_code[:-1] + if(not found): raise Exception("This shouldn't happen") for e in self.executors: - pos = code.find(e.get_code()) - if(pos!=-1): - position_2_thing_2_analyse[pos] = e - code = code.replace(e.get_code(), "a"*len(e.get_code())) - else: - raise Exception("This shouldn't happen") - + e_code = e.get_code() + found = False + while(not found or len(e_code)==0): + pos = code.find(e_code) + if(pos!=-1): + position_2_thing_2_analyse[pos] = e + code = code.replace(e_code, "a"*len(e_code), 1) + found = True + else: + e_code = e_code[:-1] + if(not found): + raise Exception("This shouldn't happen") sorted_position_2_thing_2_analyse = dict(sorted(position_2_thing_2_analyse.items())) for key in sorted_position_2_thing_2_analyse: -- GitLab