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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user