EvalEvaluator is called only if in root context. Added action and action_context to ExecutionContext

This commit is contained in:
2020-06-12 17:47:29 +02:00
parent c43a3ef946
commit 912455c343
27 changed files with 292 additions and 117 deletions
+23
View File
@@ -1,6 +1,8 @@
from core.builtin_concepts import BuiltinConcepts
from core.sheerka.services.sheerka_service import BaseService
CONCEPTS_FILE = "_concepts.txt"
class SheerkaAdmin(BaseService):
NAME = "Admin"
@@ -11,6 +13,7 @@ class SheerkaAdmin(BaseService):
def initialize(self):
self.sheerka.bind_service_method(self.caches_names)
self.sheerka.bind_service_method(self.cache)
self.sheerka.bind_service_method(self.restore)
def caches_names(self):
"""
@@ -29,3 +32,23 @@ class SheerkaAdmin(BaseService):
return self.sheerka.new(BuiltinConcepts.NOT_FOUND, body={"cache": name})
return self.sheerka.cache_manager.caches[name].cache.copy()
def restore(self):
"""
Restore the state with all previous valid concept definitions
:return:
"""
try:
self.sheerka.during_restore = True
with open(CONCEPTS_FILE, "r") as f:
for line in f.readlines():
line = line.strip()
if line == "" or line.startswith("#"):
continue
self.sheerka.log.info(line)
res = self.sheerka.evaluate_user_input(line)
if len(res) > 1 or not res[0].status:
self.sheerka.log.error("Error detected !")
self.sheerka.during_restore = False
except IOError:
pass