From 28606cde6127921615692460bbb4d80f68b7b727 Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Sun, 21 Mar 2021 15:07:45 +0100 Subject: Enabling load_instructions() to set a temporary namespace, and then reverting it after the instructions are loaded. This is to temporarly override the namespace during import - enabling avoidance of triggering __name__ checks, and at the same time reverting back the namespace automatically to enable .execute() on the script (reusability of classes) --- archinstall/lib/profiles.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'archinstall/lib/profiles.py') diff --git a/archinstall/lib/profiles.py b/archinstall/lib/profiles.py index ef7bba00..8284bf40 100644 --- a/archinstall/lib/profiles.py +++ b/archinstall/lib/profiles.py @@ -135,11 +135,14 @@ class Script(): imported = importlib.util.module_from_spec(self.spec) sys.modules[self.namespace] = imported - print(f"Imported {self} into sys.modules with namespace {self.namespace}.") + print(f"Imported {self} into sys.modules with namespace {self.namespace}") + + if '.py' not in self.namespace: + raise KeyError(f"Debugging: {self.namespace}, {reset_namespace}, {self}") if reset_namespace: self.namespace = original_namespace - + return self def execute(self): -- cgit v1.2.3-54-g00ecf