Fixed memory() and RET usage
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
from core.builtin_concepts import BuiltinConcepts
|
||||
from evaluators.BaseEvaluator import OneReturnValueEvaluator
|
||||
|
||||
|
||||
class AddToMemoryEvaluator(OneReturnValueEvaluator):
|
||||
"""
|
||||
Last chance to alter the return_value
|
||||
This evaluator is supposed to be a generic evaluator for all rules that must be executed just before
|
||||
the aggregations
|
||||
"""
|
||||
|
||||
NAME = "AddToMemory"
|
||||
|
||||
def __init__(self):
|
||||
super().__init__(self.NAME, [BuiltinConcepts.AFTER_EVALUATION], 10)
|
||||
|
||||
def matches(self, context, return_value):
|
||||
evaluation_parents = context.get_parents(lambda c: c.action == BuiltinConcepts.PROCESSING)
|
||||
if len(evaluation_parents) > 1:
|
||||
return False # It must be executed only when the top level context
|
||||
|
||||
from core.sheerka.services.SheerkaMemory import SheerkaMemory
|
||||
return len(context.sheerka.services[SheerkaMemory.NAME].registration) > 0
|
||||
|
||||
def eval(self, context, return_value):
|
||||
context.sheerka.add_registered_objects(context)
|
||||
return None # no need to have a second pass
|
||||
Reference in New Issue
Block a user