From db1f9df1abb6d82df09ecbe529b7553b36d26c4f Mon Sep 17 00:00:00 2001 From: Joshua Ogunyinka Date: Thu, 5 Sep 2019 06:50:34 +0100 Subject: [PATCH] Fixed delay in command processing --- Interlace/interlace.py | 1 + Interlace/lib/core/input.py | 21 ++++++++++++--------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/Interlace/interlace.py b/Interlace/interlace.py index 4f84115..962762a 100644 --- a/Interlace/interlace.py +++ b/Interlace/interlace.py @@ -11,6 +11,7 @@ def build_queue(arguments, output): task_list = InputHelper.process_commands(arguments) for task in task_list: output.terminal(Level.THREAD, task.name(), "Added to Queue") + print('Generated {} commands in total'.format(len(task_list))) return task_list diff --git a/Interlace/lib/core/input.py b/Interlace/lib/core/input.py index 92610e6..91e9161 100644 --- a/Interlace/lib/core/input.py +++ b/Interlace/lib/core/input.py @@ -164,13 +164,14 @@ class InputHelper(object): @staticmethod def _process_clean_targets(commands, dirty_targets): - def add_task(t, item_list): - if t not in set(item_list): + def add_task(t, item_list, my_command_set): + if t not in my_command_set: + my_command_set.add(t) item_list.append(t) variable = '_cleantarget_' tasks = [] - + temp = set() # this helps avoid command duplication and re/deconstructing of temporary set for command in commands: for dirty_target in dirty_targets: if command.name().find(variable) != -1: @@ -184,26 +185,28 @@ class InputHelper(object): clean_target = dirty_target.replace('/', '-') new_task = command.clone() new_task.replace(variable, clean_target) - add_task(new_task, tasks) + add_task(new_task, tasks, temp) else: - add_task(command, tasks) + add_task(command, tasks, temp) return tasks @staticmethod def _replace_variable_with_commands(commands, variable, replacements): - def add_task(t, item_list): - if t not in set(item_list): + def add_task(t, item_list, my_set): + if t not in my_set: + my_set.add(t) item_list.append(t) tasks = [] + temp_set = set() # to avoid duplicates for command in commands: for replacement in replacements: if command.name().find(variable) != -1: new_task = command.clone() new_task.replace(variable, replacement) - add_task(new_task, tasks) + add_task(new_task, tasks, temp_set) else: - add_task(command, tasks) + add_task(command, tasks, temp_set) return tasks @staticmethod