Refactored sheerka execution flow + Enhanced log management
This commit is contained in:
+56
-31
@@ -11,46 +11,71 @@ class BuiltinConcepts(Enum):
|
||||
The key if the name of the concept
|
||||
The id is a sequential number given just before the concept is saved in sdp
|
||||
|
||||
The values of the enum are just a convenient way for me to group the concepts
|
||||
The values of the enum is not used the code
|
||||
"""
|
||||
SHEERKA = 1
|
||||
SUCCESS = 2
|
||||
ERROR = 3
|
||||
UNKNOWN_CONCEPT = 4 # the request concept is not recognized
|
||||
RETURN_VALUE = 5 # a value is returned
|
||||
CONCEPT_TOO_LONG = 6 # concept cannot be processed by exactConcept parser
|
||||
NEW_CONCEPT = 7 # when a new concept is added
|
||||
UNKNOWN_PROPERTY = 8 # when requesting for a unknown property
|
||||
PARSER_RESULT = 9
|
||||
TOO_MANY_SUCCESS = 10 # when expecting a limited number of successful return value
|
||||
TOO_MANY_ERRORS = 11 # when expecting a limited number of successful return value
|
||||
NOT_FOR_ME = 12 # a parser recognize that the entry is not meant for it
|
||||
IS_EMPTY = 13 # when a set is empty
|
||||
INVALID_RETURN_VALUE = 14 # the return value of an evaluator is not correct
|
||||
BEFORE_PARSING = 15 # activated before evaluation by the parsers
|
||||
PARSING = 16 # activated during the parsing. It contains the text to parse
|
||||
AFTER_PARSING = 17 # after parsing
|
||||
BEFORE_EVALUATION = 18 # before evaluation
|
||||
EVALUATION = 19 # activated when the parsing process seems to be finished
|
||||
AFTER_EVALUATION = 20 # activated when the parsing process seems to be finished
|
||||
CONCEPT_ALREADY_DEFINED = 21 # when you try to add the same concept twice
|
||||
NOP = 22 # no operation concept. Does nothing
|
||||
PROPERTY_EVAL_ERROR = 23 # cannot evaluate a property of a concept
|
||||
ENUMERATION = 24 # represents a list or a set
|
||||
LIST = 25 # represents a list
|
||||
CANNOT_RESOLVE_VALUE_ERROR = 26 # In presence of a concept where the default value is not know
|
||||
SHEERKA = "sheerka"
|
||||
|
||||
NODE = 200
|
||||
GENERIC_NODE = 201
|
||||
IDENTIFIER_NODE = 202
|
||||
BEFORE_PARSING = "before parsing" # activated before evaluation by the parsers
|
||||
PARSING = "parsing" # activated during the parsing. It contains the text to parse
|
||||
AFTER_PARSING = "after parsing" # after parsing
|
||||
BEFORE_EVALUATION = "before evaluation" # before evaluation
|
||||
EVALUATION = "evaluation" # activated when the parsing process seems to be finished
|
||||
AFTER_EVALUATION = "after evaluation" # activated when the parsing process seems to be finished
|
||||
BEFORE_RENDERING = "before rendering" # activate before the output is rendered
|
||||
RENDERING = "rendering" # rendering the response from sheerka
|
||||
AFTER_RENDERING = "after rendering" # rendering the response from sheerka
|
||||
|
||||
USER_INPUT = "user input" # represent an input from an user
|
||||
SUCCESS = "success"
|
||||
ERROR = "error"
|
||||
UNKNOWN_CONCEPT = "unknown concept" # the request concept is not recognized
|
||||
RETURN_VALUE = "return value" # a value is returned
|
||||
CONCEPT_TOO_LONG = "concept too long" # concept cannot be processed by exactConcept parser
|
||||
NEW_CONCEPT = "new concept" # when a new concept is added
|
||||
UNKNOWN_PROPERTY = "unknown property" # when requesting for a unknown property
|
||||
PARSER_RESULT = "parser result"
|
||||
TOO_MANY_SUCCESS = "too many success" # when expecting a limited number of successful return value
|
||||
TOO_MANY_ERRORS = "too many errors" # when expecting a limited number of successful return value
|
||||
NOT_FOR_ME = "not for me" # a parser recognize that the entry is not meant for it
|
||||
IS_EMPTY = "is empty" # when a set is empty
|
||||
INVALID_RETURN_VALUE = "invalid return value" # the return value of an evaluator is not correct
|
||||
CONCEPT_ALREADY_DEFINED = "concept already defined" # when you try to add the same concept twice
|
||||
NOP = "no operation" # no operation concept. Does nothing
|
||||
PROPERTY_EVAL_ERROR = "property evaluation error" # cannot evaluate a property of a concept
|
||||
ENUMERATION = "enum" # represents a list or a set
|
||||
LIST = "list" # represents a list
|
||||
CANNOT_RESOLVE_VALUE_ERROR = "value cannot be resolved" # don't know how to find concept value
|
||||
|
||||
NODE = "node"
|
||||
GENERIC_NODE = "generic node"
|
||||
IDENTIFIER_NODE = "identifier node"
|
||||
|
||||
def __repr__(self):
|
||||
return "__" + self.name
|
||||
|
||||
def __str__(self):
|
||||
return "__" + self.name
|
||||
|
||||
"""
|
||||
Some concepts have a specific implementation
|
||||
It's mainly to a have proper __repr__ implementation, or redefine the is_unique attribut
|
||||
It's mainly to a have proper __repr__ implementation, or because they are singleton (is_unique=True)
|
||||
"""
|
||||
|
||||
|
||||
class UserInputConcept(Concept):
|
||||
def __init__(self, text=None, user_name=None):
|
||||
super().__init__(BuiltinConcepts.USER_INPUT, True, False, BuiltinConcepts.USER_INPUT, text)
|
||||
self.set_prop("user_name", user_name)
|
||||
|
||||
@property
|
||||
def text(self):
|
||||
return self.body
|
||||
|
||||
@property
|
||||
def user_name(self):
|
||||
return self.props["user_name"].value
|
||||
|
||||
|
||||
class SuccessConcept(Concept):
|
||||
def __init__(self):
|
||||
super().__init__(BuiltinConcepts.SUCCESS, True, True, BuiltinConcepts.SUCCESS)
|
||||
|
||||
Reference in New Issue
Block a user