Fixed delay in command processing

This commit is contained in:
Joshua Ogunyinka
2019-09-05 06:50:34 +01:00
parent 726286430d
commit db1f9df1ab
2 changed files with 13 additions and 9 deletions

View File

@@ -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