Skip to content

Commit

Permalink
Started integration of an Hardcoded parameter substitution module
Browse files Browse the repository at this point in the history
  • Loading branch information
klezVirus committed Sep 21, 2021
1 parent d50b018 commit 0d515af
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
8 changes: 8 additions & 0 deletions inceptor/engine/component/HardcodedArgComponent.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from config.Config import Config
from engine.component.TemplateModuleComponent import TemplateModuleComponent


class HardcodedArgComponent(TemplateModuleComponent):
def __init__(self, index, code):
placeholder = f"####ARG{index}####"
super().__init__(code, placeholder)
12 changes: 10 additions & 2 deletions inceptor/engine/modules/TemplateModule.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ class ModuleNotLoadableException(Exception):
pass


class ModuleNotFoundException(Exception):
pass


class TemplateModule:
def __init__(self, name: str = None, arch=Arch.x64, libraries: list = None, components: list = None):
self.components = components if components else []
Expand Down Expand Up @@ -78,14 +82,18 @@ def from_name(name, **kwargs):
# print(_class_string)
_class = locate(_class_string)
_instance = _class(kwargs=kwargs['kwargs'])
if not _instance.loadable:
if not _instance.loadable or not hasattr(_instance, "loadable"):
raise ModuleNotLoadableException()
return _instance
except ModuleNotCompatibleException:
raise ModuleNotCompatibleException()
except TypeError as e:
if str(e).find("unexpected keyword argument 'kwargs'") > -1:
raise ModuleNotLoadableException()
elif str(e).find("'NoneType' object is not callable") > -1:
raise ModuleNotFoundException()
else:
traceback.print_exc()
except Exception as e:
# traceback.print_exc()
traceback.print_exc()
pass

0 comments on commit 0d515af

Please sign in to comment.