From 8787a2fe35908c14fe4d99b6e3277f5bc06365b5 Mon Sep 17 00:00:00 2001 From: DavdaJames Date: Mon, 6 Oct 2025 20:41:53 +0530 Subject: [PATCH 1/2] optimized the sort_loops in module.py and also improved readability --- nettacker/core/module.py | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/nettacker/core/module.py b/nettacker/core/module.py index 17ab60601..c09df20ca 100644 --- a/nettacker/core/module.py +++ b/nettacker/core/module.py @@ -118,26 +118,21 @@ def generate_loops(self): self.module_content["payloads"] = expand_module_steps(self.module_content["payloads"]) def sort_loops(self): - steps = [] for index in range(len(self.module_content["payloads"])): - for step in copy.deepcopy(self.module_content["payloads"][index]["steps"]): - if "dependent_on_temp_event" not in step[0]["response"]: - steps.append(step) + no_dep = [] + dep_temp_only = [] + dep_normal = [] for step in copy.deepcopy(self.module_content["payloads"][index]["steps"]): - if ( - "dependent_on_temp_event" in step[0]["response"] - and "save_to_temp_events_only" in step[0]["response"] - ): - steps.append(step) + resp = step[0]["response"] + if "dependent_on_temp_event" not in resp: + no_dep.append(step) + elif "save_to_temp_events_only" in resp: + dep_temp_only.append(step) + else: + dep_normal.append(step) - for step in copy.deepcopy(self.module_content["payloads"][index]["steps"]): - if ( - "dependent_on_temp_event" in step[0]["response"] - and "save_to_temp_events_only" not in step[0]["response"] - ): - steps.append(step) - self.module_content["payloads"][index]["steps"] = steps + self.module_content["payloads"][index]["steps"] = no_dep + dep_temp_only + dep_normal def start(self): active_threads = [] From baca7f54e698c256078fa3899c07e35c56352646 Mon Sep 17 00:00:00 2001 From: DavdaJames Date: Mon, 13 Oct 2025 01:28:36 +0530 Subject: [PATCH 2/2] improved array variable naming --- nettacker/core/module.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/nettacker/core/module.py b/nettacker/core/module.py index c09df20ca..c867351b7 100644 --- a/nettacker/core/module.py +++ b/nettacker/core/module.py @@ -119,20 +119,24 @@ def generate_loops(self): def sort_loops(self): for index in range(len(self.module_content["payloads"])): - no_dep = [] - dep_temp_only = [] - dep_normal = [] + steps_without_dependencies = [] + steps_with_temp_dependencies = [] + steps_with_normal_dependencies = [] for step in copy.deepcopy(self.module_content["payloads"][index]["steps"]): resp = step[0]["response"] if "dependent_on_temp_event" not in resp: - no_dep.append(step) + steps_without_dependencies.append(step) elif "save_to_temp_events_only" in resp: - dep_temp_only.append(step) + steps_with_temp_dependencies.append(step) else: - dep_normal.append(step) + steps_with_normal_dependencies.append(step) - self.module_content["payloads"][index]["steps"] = no_dep + dep_temp_only + dep_normal + self.module_content["payloads"][index]["steps"] = ( + steps_without_dependencies + + steps_with_temp_dependencies + + steps_with_normal_dependencies + ) def start(self): active_threads = []