Preparing modelspace release
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
from modelspace.ModelSpace import ModelSpace
|
||||
from shell.Handlers.ABS import Handler
|
||||
from modelspace.Repository import global_repo
|
||||
|
||||
@@ -8,12 +9,57 @@ class ModelSpaceHandler(Handler):
|
||||
self.forwarding_table: dict[str, Handler] = {
|
||||
}
|
||||
self.handle_table: dict = {
|
||||
'create_inter': self._create_inter
|
||||
'create-inter': self._create_inter,
|
||||
'install': self._install,
|
||||
'install-all': self._install_all,
|
||||
# 'create': self._create,
|
||||
'load': self._load,
|
||||
# 'show': self._show,
|
||||
# 'activate': self._activate,
|
||||
|
||||
}
|
||||
|
||||
self._loaded_instances: dict[str, ModelSpace] = {}
|
||||
self._active_instance: ModelSpace | None = None
|
||||
pass
|
||||
|
||||
def _create_inter(self, command: list[str], pos=0):
|
||||
global_repo.add_model_package_interactive()
|
||||
self.succeed = True
|
||||
|
||||
def _load(self, command: list[str], pos = 0):
|
||||
keys, args = self.parse_arguments(command[pos:], ['path', 'layout', 'name'])
|
||||
self._check_arg(keys, 'path')
|
||||
self._check_arg(keys, 'layout')
|
||||
if not keys['name']: keys['name'] = 'app'
|
||||
i = ModelSpace(global_repo, path=keys['path'], layout=keys['layout'])
|
||||
# if not i.config.created: raise self.execution_error("ACTIVATE INSTANCE: instance not exists")
|
||||
self._loaded_instances[keys['name']] = i
|
||||
self._active_instance = i
|
||||
print(f"instance {keys['path']} loaded and activated. identified by {keys['name']}")
|
||||
self.succeed = True
|
||||
|
||||
# def _activate(self, command: list[str], pos = 0):
|
||||
# keys, args = self.parse_arguments(command[pos:], ['name'])
|
||||
# self._check_arg(keys, 'name')
|
||||
# i = self._loaded_instances.get(command[1], None)
|
||||
# if i:
|
||||
# self._active_instance = i
|
||||
# else:
|
||||
# raise ValueError(f"pyapp {keys['name']} not loaded")
|
||||
#
|
||||
# def _show(self, command: list[str], pos = 0):
|
||||
# print("Environment type:", self._active_instance.config.env_type)
|
||||
# # TODO Add new config info (app section)
|
||||
|
||||
# def _create(self, command: list[str], pos = 0):
|
||||
# keys, args = self.parse_arguments(command[pos:], ['env', 'path', 'python'])
|
||||
|
||||
def _install(self, command: list[str], pos = 0):
|
||||
for resource in command[pos:]: self._active_instance.install(resource)
|
||||
self.succeed = True
|
||||
|
||||
def _install_all(self, command: list[str], pos = 0):
|
||||
for resource in global_repo.model_sub_repo.resources.keys:
|
||||
self._active_instance.install(resource, answer='all')
|
||||
self.succeed = True
|
||||
|
||||
|
||||
Reference in New Issue
Block a user