Fixed #61 : SheerkaDebugManager: Add get_value()
Fixed #60 : Hash error when ReturnValue is a list of list Fixed #59 : Implement smart_get() Fixed #58 : SheerkaPromptCompleter: Cannot parse concept token Fixed #57 : SheerkaPrompt: Add concept autocompletion Fixed #56 : automatically backup command Fixed #54 : I can record execution status Fixed #53 : ConceptManager: modify_concept fails
This commit is contained in:
@@ -497,3 +497,17 @@ class ExecutionContext:
|
||||
return False
|
||||
|
||||
return False
|
||||
|
||||
def set_state_is_modified(self):
|
||||
root_parent = self
|
||||
while root_parent._parent is not None:
|
||||
root_parent = root_parent._parent
|
||||
|
||||
root_parent.values["is_state_modified"] = True
|
||||
|
||||
def is_state_modified(self):
|
||||
root_parent = self
|
||||
while root_parent._parent is not None:
|
||||
root_parent = root_parent._parent
|
||||
|
||||
return "is_state_modified" in root_parent.values and bool(root_parent.values["is_state_modified"]) is True
|
||||
|
||||
@@ -106,6 +106,7 @@ class Sheerka(Concept):
|
||||
self.save_execution_context = True
|
||||
self.enable_process_return_values = True
|
||||
self.enable_process_rules = True
|
||||
self.enable_commands_backup = True
|
||||
|
||||
self.methods_with_context = {"test_using_context"} # only the names, the method is defined in sheerka_methods
|
||||
self.sheerka_methods = {
|
||||
@@ -158,8 +159,6 @@ class Sheerka(Concept):
|
||||
Loads the current configuration
|
||||
Notes that when it's the first time, it also create the needed working folders
|
||||
:param root_folder: root configuration folder
|
||||
:param save_execution_context:
|
||||
:param enable_process_return_values:
|
||||
:return: ReturnValue(Success or Error)
|
||||
"""
|
||||
|
||||
@@ -167,6 +166,7 @@ class Sheerka(Concept):
|
||||
self.enable_process_return_values = kwargs.get("enable_process_return_values",
|
||||
self.enable_process_return_values)
|
||||
self.enable_process_rules = kwargs.get("enable_process_rules", self.enable_process_rules)
|
||||
self.enable_commands_backup = kwargs.get("enable_commands_backup", self.enable_commands_backup)
|
||||
|
||||
try:
|
||||
self.during_initialisation = True
|
||||
@@ -370,7 +370,7 @@ class Sheerka(Concept):
|
||||
if self.enable_process_rules:
|
||||
ret = self.execute_rules(execution_context, ret, RULES_EVALUATE_STEPS, RULES_EXECUTE_STEPS)
|
||||
|
||||
if self.om.is_dirty:
|
||||
if self.om.is_dirty():
|
||||
self.om.commit(execution_context)
|
||||
|
||||
self.publish(execution_context, EVENT_USER_INPUT_EVALUATED)
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
import sys
|
||||
import os
|
||||
import time
|
||||
from os import path
|
||||
|
||||
from core.builtin_concepts_ids import BuiltinConcepts, BuiltinContainers
|
||||
from core.builtin_helpers import ensure_concept_or_rule
|
||||
from core.concept import Concept
|
||||
from core.global_symbols import SHEERKA_BACKUP_FOLDER
|
||||
from core.sheerka.services.SheerkaHistoryManager import SheerkaHistoryManager
|
||||
from core.sheerka.services.SheerkaMemory import SheerkaMemory
|
||||
from core.sheerka.services.sheerka_service import BaseService
|
||||
|
||||
CONCEPTS_FILE_LITE = "_concepts_lite.txt"
|
||||
CONCEPTS_FILE_FULL = "_concepts_full.txt"
|
||||
CONCEPTS_FILE_FULL = "full.sb"
|
||||
CONCEPTS_FILE_TO_USE = CONCEPTS_FILE_FULL
|
||||
|
||||
|
||||
@@ -70,7 +70,7 @@ class SheerkaAdmin(BaseService):
|
||||
|
||||
return self.sheerka.om.current_sdp()
|
||||
|
||||
def restore(self, concept_file=CONCEPTS_FILE_TO_USE):
|
||||
def restore(self, backup_file=CONCEPTS_FILE_TO_USE):
|
||||
"""
|
||||
Restore the state with all previous valid concept definitions
|
||||
:return:
|
||||
@@ -79,7 +79,7 @@ class SheerkaAdmin(BaseService):
|
||||
def restore_from_file(file_name):
|
||||
_nb_lines, _nb_instructions, _nb_lines_in_error = 0, 0, 0
|
||||
_min_time, _max_time = None, None
|
||||
file_path = path.join(path.dirname(sys.argv[0]), file_name)
|
||||
file_path = path.join(backup_folder, file_name)
|
||||
if not path.exists(file_path):
|
||||
print(f"\u001b[31mFile '{file_path}' is not found !\u001b[0m")
|
||||
return 0, 0, 1
|
||||
@@ -90,7 +90,7 @@ class SheerkaAdmin(BaseService):
|
||||
line = line.strip()
|
||||
|
||||
if line.startswith("#import "):
|
||||
to_import = "_concepts_" + line[8:] + ".txt"
|
||||
to_import = line[8:] + ".sb"
|
||||
print(f" ==== Importing {to_import} ==== ")
|
||||
res = restore_from_file(to_import)
|
||||
_nb_lines += res[0]
|
||||
@@ -122,8 +122,12 @@ class SheerkaAdmin(BaseService):
|
||||
|
||||
return _nb_lines, _nb_instructions, _nb_lines_in_error, _min_time, _max_time
|
||||
|
||||
if not concept_file.startswith("_concepts"):
|
||||
concept_file = f"_concepts_{concept_file}.txt"
|
||||
backup_folder = os.getenv(SHEERKA_BACKUP_FOLDER)
|
||||
if backup_folder is None:
|
||||
return self.sheerka.ret(self.NAME, False, self.sheerka.err(SHEERKA_BACKUP_FOLDER + " is not defined"))
|
||||
|
||||
if not backup_file.endswith(".sb"):
|
||||
backup_file = backup_file + ".sb"
|
||||
|
||||
try:
|
||||
start = time.time_ns()
|
||||
@@ -132,7 +136,7 @@ class SheerkaAdmin(BaseService):
|
||||
enable_process_return_values_previous_value = self.sheerka.enable_process_return_values
|
||||
self.sheerka.enable_process_return_values = False
|
||||
|
||||
nb_lines, nb_instructions, nb_lines_in_error, min_time, max_time = restore_from_file(concept_file)
|
||||
nb_lines, nb_instructions, nb_lines_in_error, min_time, max_time = restore_from_file(backup_file)
|
||||
|
||||
self.sheerka.enable_process_return_values = enable_process_return_values_previous_value
|
||||
self.sheerka.save_execution_context = True
|
||||
|
||||
@@ -13,7 +13,8 @@ from core.builtin_concepts_ids import BuiltinConcepts, AllBuiltinConcepts, Built
|
||||
from core.builtin_helpers import ensure_concept, ensure_bnf
|
||||
from core.concept import Concept, DEFINITION_TYPE_DEF, DEFINITION_TYPE_BNF, freeze_concept_attrs, ConceptMetadata, \
|
||||
VARIABLE_PREFIX
|
||||
from core.global_symbols import EVENT_CONCEPT_CREATED, NotInit, NotFound, ErrorObj, EVENT_CONCEPT_DELETED, NoFirstToken
|
||||
from core.global_symbols import EVENT_CONCEPT_CREATED, NotInit, NotFound, ErrorObj, EVENT_CONCEPT_DELETED, NoFirstToken, \
|
||||
EVENT_CONCEPT_MODIFIED
|
||||
from core.sheerka.services.sheerka_service import BaseService
|
||||
from core.tokenizer import Tokenizer, TokenKind
|
||||
from parsers.BnfNodeParser import RegExDef
|
||||
@@ -118,6 +119,7 @@ class SheerkaConceptManager(BaseService):
|
||||
self.sheerka.bind_service_method(self.set_id_if_needed, True)
|
||||
self.sheerka.bind_service_method(self.set_attr, True)
|
||||
self.sheerka.bind_service_method(self.get_attr, False)
|
||||
self.sheerka.bind_service_method(self.smart_get_attr, False)
|
||||
self.sheerka.bind_service_method(self.set_property, True, as_name="set_prop")
|
||||
self.sheerka.bind_service_method(self.get_property, False, as_name="get_prop")
|
||||
self.sheerka.bind_service_method(self.get_by_key, False, visible=False)
|
||||
@@ -346,7 +348,7 @@ class SheerkaConceptManager(BaseService):
|
||||
if modify_source:
|
||||
self._update_concept(context, concept, to_add, to_remove)
|
||||
|
||||
# KSI 2021-02-16 publish the modification of the concept only when someone needs it
|
||||
sheerka.publish(context, EVENT_CONCEPT_MODIFIED, {"old": concept, "new": new_concept})
|
||||
return sheerka.ret(self.NAME, True, sheerka.new(BuiltinConcepts.NEW_CONCEPT, body=new_concept))
|
||||
|
||||
def remove_concept(self, context, concept):
|
||||
@@ -390,7 +392,6 @@ class SheerkaConceptManager(BaseService):
|
||||
def set_attr(self, concept, attribute, value):
|
||||
"""
|
||||
Modifies an attribute of a concept (concept.values)
|
||||
:param context:
|
||||
:param concept:
|
||||
:param attribute:
|
||||
:param value:
|
||||
@@ -416,7 +417,6 @@ class SheerkaConceptManager(BaseService):
|
||||
def get_attr(self, concept, attribute):
|
||||
"""
|
||||
Returns the attribute of a concept
|
||||
:param context:
|
||||
:param concept:
|
||||
:param attribute:
|
||||
:return:
|
||||
@@ -431,6 +431,72 @@ class SheerkaConceptManager(BaseService):
|
||||
return self.sheerka.new(BuiltinConcepts.NOT_FOUND, body={"#concept": concept, "#attr": attribute})
|
||||
return value
|
||||
|
||||
def smart_get_attr(self, concept, attribute):
|
||||
|
||||
def get_obj_value(c, concept_to_look_for):
|
||||
"""
|
||||
Return the body of the concept c if it is an instance of concept_to_look_for
|
||||
Go deeper in the bodies until the concept_to_look_for is found
|
||||
:param c:
|
||||
:param concept_to_look_for:
|
||||
:return:
|
||||
"""
|
||||
while c.body is not NotInit:
|
||||
if self.sheerka.isinstance(c.body, concept_to_look_for):
|
||||
return c.body
|
||||
c = c.body
|
||||
|
||||
return None
|
||||
|
||||
ensure_concept()
|
||||
if not self.sheerka.is_success(concept):
|
||||
return concept
|
||||
|
||||
value = self.get_attr(concept, attribute)
|
||||
if not self.sheerka.isinstance(value, BuiltinConcepts.NOT_FOUND):
|
||||
return value
|
||||
|
||||
if not isinstance(attribute, Concept):
|
||||
return self.sheerka.new(BuiltinConcepts.NOT_FOUND, body={"#concept": concept, "#attr": attribute})
|
||||
|
||||
# try to be smart
|
||||
result = []
|
||||
|
||||
# first look in children
|
||||
for k, v in concept.variables().items():
|
||||
attr_as_concept_key, attr_concept_id = core.utils.unstr_concept(k)
|
||||
if attr_concept_id is not None:
|
||||
attr_as_concept = self.sheerka.fast_resolve((attr_as_concept_key, attr_concept_id), return_new=False)
|
||||
if attr_as_concept is not None and self.sheerka.isa(attribute, attr_as_concept):
|
||||
if hasattr(v, "__iter__"):
|
||||
for _v in v:
|
||||
value = get_obj_value(_v, attribute)
|
||||
if value is not None:
|
||||
result.append(value)
|
||||
else:
|
||||
value = get_obj_value(v, attribute)
|
||||
if value is not None:
|
||||
result.append(value)
|
||||
|
||||
if len(result) > 0:
|
||||
return result[0] if len(result) == 1 else result
|
||||
|
||||
# then try the ancestors
|
||||
for k, v in concept.variables().items():
|
||||
attr_as_concept_key, attr_concept_id = core.utils.unstr_concept(k)
|
||||
if attr_concept_id is not None:
|
||||
attr_as_concept = self.sheerka.fast_resolve((attr_as_concept_key, attr_concept_id), return_new=False)
|
||||
if attr_as_concept is not None and self.sheerka.isa(attr_as_concept, attribute):
|
||||
if isinstance(v, list):
|
||||
result.extend(v)
|
||||
else:
|
||||
result.append(v)
|
||||
|
||||
if len(result) > 0:
|
||||
return result[0] if len(result) == 1 else result
|
||||
|
||||
return self.sheerka.new(BuiltinConcepts.NOT_FOUND, body={"#concept": concept, "#attr": attribute})
|
||||
|
||||
def get_property(self, concept, prop):
|
||||
"""
|
||||
Returns the value of a concept property
|
||||
|
||||
@@ -322,6 +322,7 @@ class SheerkaDebugManager(BaseService):
|
||||
def initialize(self):
|
||||
self.sheerka.bind_service_method(self.set_debug, True)
|
||||
self.sheerka.bind_service_method(self.inspect, False)
|
||||
self.sheerka.bind_service_method(self.get_value, False)
|
||||
self.sheerka.bind_service_method(self.get_debugger, False)
|
||||
self.sheerka.bind_service_method(self.reset_debug, False)
|
||||
self.sheerka.bind_service_method(self.set_debug_var, True)
|
||||
@@ -802,6 +803,26 @@ class SheerkaDebugManager(BaseService):
|
||||
|
||||
return self.get_inner_values(obj.body, **kwargs)
|
||||
|
||||
def get_value(self, obj):
|
||||
"""
|
||||
Returns the underlying values of an object
|
||||
:param obj:
|
||||
:return:
|
||||
"""
|
||||
if isinstance(obj, list):
|
||||
return [self.get_value(item) for item in obj]
|
||||
|
||||
if isinstance(obj, set):
|
||||
return {self.get_value(item) for item in obj}
|
||||
|
||||
if isinstance(obj, tuple):
|
||||
return tuple(self.get_value(item) for item in obj)
|
||||
|
||||
if isinstance(obj, Concept):
|
||||
return self.get_value(self.sheerka.objvalue(obj))
|
||||
|
||||
return obj
|
||||
|
||||
@staticmethod
|
||||
def get_debug_repr(obj, **kwargs):
|
||||
if kwargs.get("as_bag", False):
|
||||
@@ -897,3 +918,4 @@ class SheerkaDebugManager(BaseService):
|
||||
del res["self"]
|
||||
|
||||
return res
|
||||
|
||||
|
||||
@@ -31,9 +31,9 @@ class SheerkaHasAManager(BaseService):
|
||||
return self.sheerka.ret(
|
||||
self.NAME,
|
||||
False,
|
||||
self.sheerka.new(BuiltinConcepts.PropertyAlreadyDefined,
|
||||
body=concept_b,
|
||||
name=BuiltinConcepts.HASA,
|
||||
self.sheerka.new(BuiltinConcepts.PROPERTY_ALREADY_DEFINED,
|
||||
property_value=concept_b,
|
||||
property_name=BuiltinConcepts.HASA,
|
||||
concept=concept_a))
|
||||
|
||||
merged_concepts = merge_sets(concept_a.get_prop(BuiltinConcepts.HASA), {concept_b})
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
from collections import namedtuple
|
||||
|
||||
from core.global_symbols import NotInit
|
||||
from core.sheerka.services.sheerka_service import BaseService
|
||||
from sdp.sheerkaDataProvider import Event
|
||||
|
||||
@@ -7,14 +8,22 @@ hist = namedtuple("HistoryTest", "text status") # tests purposes only
|
||||
|
||||
|
||||
class History:
|
||||
def __init__(self, event: Event, result):
|
||||
def __init__(self, event: Event, result, extra_info):
|
||||
self.event = event
|
||||
self.result = result
|
||||
self._status = None
|
||||
self.extra_info = extra_info
|
||||
self._status = NotInit
|
||||
self._is_state_modified = NotInit
|
||||
self._format_instructions = None
|
||||
|
||||
def __str__(self):
|
||||
msg = f"{self.event.get_digest()} {self.event.date.strftime('%d/%m/%Y %H:%M:%S')} : {self.event.message}"
|
||||
if self.is_state_modified is NotInit:
|
||||
state_modified_str = "[?]"
|
||||
else:
|
||||
state_modified_str = "[X]" if self.is_state_modified else "[ ]"
|
||||
event_date = self.event.date.strftime('%d/%m/%Y %H:%M:%S')
|
||||
|
||||
msg = f"{self.event.get_digest()} {event_date} {state_modified_str} : {self.event.message}"
|
||||
status = self.status
|
||||
if status is not None:
|
||||
msg += f" => {status}"
|
||||
@@ -40,12 +49,28 @@ class History:
|
||||
|
||||
@property
|
||||
def status(self):
|
||||
if self._status:
|
||||
if self._status is not NotInit:
|
||||
return self._status
|
||||
|
||||
if self.extra_info and "status" in self.extra_info:
|
||||
self._status = self.extra_info["status"]
|
||||
return self._status
|
||||
|
||||
self._status = self.result.get_status() if self.result else None
|
||||
return self._status
|
||||
|
||||
@property
|
||||
def is_state_modified(self):
|
||||
if self._is_state_modified is not NotInit:
|
||||
return self._is_state_modified
|
||||
|
||||
if self.extra_info and "is_state_modified" in self.extra_info:
|
||||
self._is_state_modified = self.extra_info["is_state_modified"]
|
||||
return self._is_state_modified
|
||||
|
||||
self._is_state_modified = self.result.is_state_modified() if self.result else None
|
||||
return self._is_state_modified
|
||||
|
||||
def get_format_instructions(self):
|
||||
return self._format_instructions
|
||||
|
||||
@@ -73,4 +98,10 @@ class SheerkaHistoryManager(BaseService):
|
||||
result = self.sheerka.om.current_sdp().load_result(event.get_digest())
|
||||
except (IOError, KeyError):
|
||||
result = None
|
||||
yield History(event, result)
|
||||
|
||||
try:
|
||||
extra_info = self.sheerka.om.current_sdp().load_result_extra_info(event.get_digest())
|
||||
except (IOError, KeyError):
|
||||
extra_info = None
|
||||
|
||||
yield History(event, result, extra_info)
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
import ast
|
||||
import os
|
||||
|
||||
from cache.Cache import Cache
|
||||
from core.builtin_concepts import BuiltinConcepts
|
||||
from core.global_symbols import EVENT_USER_INPUT_EVALUATED, EVENT_CONCEPT_CREATED, NotFound
|
||||
from core.global_symbols import EVENT_USER_INPUT_EVALUATED, EVENT_CONCEPT_CREATED, NotFound, EVENT_CONCEPT_MODIFIED, \
|
||||
EVENT_CONCEPT_DELETED, EVENT_CONCEPT_PRECEDENCE_MODIFIED, EVENT_RULE_CREATED, EVENT_RULE_DELETED, \
|
||||
EVENT_RULE_PRECEDENCE_MODIFIED, SHEERKA_BACKUP_FOLDER, SHEERKA_BACKUP_FILE
|
||||
from core.sheerka.services.sheerka_service import BaseService
|
||||
from core.utils import CONSOLE_COLORS_MAP as CCM
|
||||
from core.utils import as_bag
|
||||
@@ -40,6 +43,14 @@ class SheerkaResultManager(BaseService):
|
||||
self.sheerka.subscribe(EVENT_USER_INPUT_EVALUATED, self.user_input_evaluated)
|
||||
self.sheerka.subscribe(EVENT_CONCEPT_CREATED, self.new_concept_created)
|
||||
|
||||
self.sheerka.subscribe(EVENT_CONCEPT_CREATED, self.on_global_state_is_modified)
|
||||
self.sheerka.subscribe(EVENT_CONCEPT_MODIFIED, self.on_global_state_is_modified)
|
||||
self.sheerka.subscribe(EVENT_CONCEPT_DELETED, self.on_global_state_is_modified)
|
||||
self.sheerka.subscribe(EVENT_CONCEPT_PRECEDENCE_MODIFIED, self.on_global_state_is_modified)
|
||||
self.sheerka.subscribe(EVENT_RULE_CREATED, self.on_global_state_is_modified)
|
||||
self.sheerka.subscribe(EVENT_RULE_DELETED, self.on_global_state_is_modified)
|
||||
self.sheerka.subscribe(EVENT_RULE_PRECEDENCE_MODIFIED, self.on_global_state_is_modified)
|
||||
|
||||
def initialize_deferred(self, context, is_first_time):
|
||||
self.restore_values(*self.state_vars)
|
||||
|
||||
@@ -59,6 +70,11 @@ class SheerkaResultManager(BaseService):
|
||||
|
||||
@staticmethod
|
||||
def get_predicate(**kwargs):
|
||||
"""
|
||||
Create a filtering predicate from a arguments
|
||||
:param kwargs:
|
||||
:return:
|
||||
"""
|
||||
if len(kwargs) == 0:
|
||||
return None
|
||||
res = []
|
||||
@@ -241,13 +257,25 @@ class SheerkaResultManager(BaseService):
|
||||
:param execution_context:
|
||||
:return:
|
||||
"""
|
||||
extra_info = {
|
||||
"status": execution_context.get_status(),
|
||||
"is_state_modified": execution_context.is_state_modified(),
|
||||
}
|
||||
if self.sheerka.save_execution_context:
|
||||
try:
|
||||
self.sheerka.om.current_sdp().save_result(execution_context)
|
||||
except Exception as ex:
|
||||
print(f"{CCM['red']}Failed to save execution context. Reason: {ex}{CCM['reset']}")
|
||||
|
||||
# save extra info
|
||||
try:
|
||||
self.sheerka.om.current_sdp().save_result_extra_info(execution_context.event.get_digest(), extra_info)
|
||||
except Exception as ex:
|
||||
print(f"{CCM['red']}Failed to save execution context extra info. Reason: {ex}{CCM['reset']}")
|
||||
pass
|
||||
# self.log.error(f"Failed to save execution context. Reason: {ex}")
|
||||
|
||||
# write the command in a backup file if needed
|
||||
self.backup_command(execution_context)
|
||||
|
||||
self.executions_contexts_cache.put(execution_context.event.get_digest(), execution_context)
|
||||
self.last_execution = execution_context
|
||||
@@ -298,11 +326,21 @@ class SheerkaResultManager(BaseService):
|
||||
return self.last_errors
|
||||
|
||||
def new_concept_created(self, context, concept):
|
||||
"""
|
||||
Subscriber (callback) when a new concept is created
|
||||
:param context:
|
||||
:param concept:
|
||||
:return:
|
||||
"""
|
||||
self.last_created_concept = concept
|
||||
self.last_created_concept_id = concept.id
|
||||
|
||||
self.sheerka.record_var(context, self.NAME, "last_created_concept_id", concept.id)
|
||||
|
||||
@staticmethod
|
||||
def on_global_state_is_modified(context, *argv, **kwargs):
|
||||
context.set_state_is_modified()
|
||||
|
||||
def get_last_created_concept(self, context):
|
||||
if self.last_created_concept:
|
||||
return self.last_created_concept
|
||||
@@ -333,3 +371,24 @@ class SheerkaResultManager(BaseService):
|
||||
consumed = 0
|
||||
|
||||
return None
|
||||
|
||||
def backup_command(self, execution_context):
|
||||
if (self.sheerka.during_restore or
|
||||
not execution_context.is_state_modified() or
|
||||
not self.sheerka.enable_commands_backup):
|
||||
return
|
||||
|
||||
folder = os.getenv(SHEERKA_BACKUP_FOLDER)
|
||||
if folder is None:
|
||||
print(f"{CCM['red']}Cannot backup command. Backup folder (env SHEERKA_BACKUP_FOLDER) is not defined.{CCM['reset']}")
|
||||
return
|
||||
|
||||
file = os.getenv(SHEERKA_BACKUP_FILE)
|
||||
if file is None:
|
||||
print(f"{CCM['red']}Cannot backup command. Backup file (env SHEERKA_BACKUP_FILE) is not defined.{CCM['reset']}")
|
||||
return
|
||||
|
||||
full_path = os.path.join(folder, file)
|
||||
with open(full_path, "a") as f:
|
||||
f.write(f"{execution_context.event.message}\n")
|
||||
|
||||
|
||||
@@ -42,8 +42,14 @@ class SheerkaVariableManager(BaseService):
|
||||
|
||||
def __init__(self, sheerka):
|
||||
super().__init__(sheerka, order=3)
|
||||
|
||||
# Bound variables:
|
||||
# automatically set services (including Sheerka) attributes at startup or at ontology creation / deletion
|
||||
self.bound_variables = {
|
||||
self.sheerka.name: {"enable_process_return_values", "save_execution_context", "enable_process_rules"}
|
||||
self.sheerka.name: {"enable_process_return_values",
|
||||
"save_execution_context",
|
||||
"enable_process_rules",
|
||||
"enable_commands_backup"}
|
||||
}
|
||||
|
||||
def initialize(self):
|
||||
@@ -88,6 +94,7 @@ class SheerkaVariableManager(BaseService):
|
||||
if who in self.bound_variables and key in self.bound_variables[who]:
|
||||
service = self.sheerka if who == self.sheerka.name else self.sheerka.services[who]
|
||||
setattr(service, key, value)
|
||||
print(f"{service=} is set")
|
||||
|
||||
def load_var(self, who, key):
|
||||
variable = self.sheerka.om.get(self.VARIABLES_ENTRY, who + "|" + key)
|
||||
|
||||
Reference in New Issue
Block a user