Refactored sheerka execution flow + Enhanced log management
This commit is contained in:
@@ -5,12 +5,9 @@ from core.concept import Concept
|
||||
from evaluators.BaseEvaluator import OneReturnValueEvaluator
|
||||
from parsers.ConceptLexerParser import ParsingExpression, ParsingExpressionVisitor
|
||||
from parsers.DefaultParser import DefConceptNode
|
||||
import logging
|
||||
|
||||
from parsers.PythonParser import PythonNode
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class ConceptOrRuleNameVisitor(ParsingExpressionVisitor):
|
||||
"""
|
||||
@@ -49,7 +46,7 @@ class AddConceptEvaluator(OneReturnValueEvaluator):
|
||||
isinstance(return_value.value.value, DefConceptNode)
|
||||
|
||||
def eval(self, context, return_value):
|
||||
log.debug("Adding a new concept")
|
||||
context.log(self.log, "Adding a new concept", self.name)
|
||||
def_concept_node = return_value.value.value
|
||||
sheerka = context.sheerka
|
||||
|
||||
@@ -89,6 +86,9 @@ class AddConceptEvaluator(OneReturnValueEvaluator):
|
||||
concept.bnf = def_concept_node.definition.value.value
|
||||
|
||||
ret = sheerka.create_new_concept(context, concept)
|
||||
if not ret.status:
|
||||
error_cause = sheerka.value(ret.body)
|
||||
context.log(self.log, f"Failed to add concept '{concept.name}'. Reason: {error_cause}", self.name)
|
||||
return sheerka.ret(self.name, ret.status, ret.value, parents=[return_value])
|
||||
|
||||
@staticmethod
|
||||
|
||||
Reference in New Issue
Block a user