Reimplemented explain feature
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
import ast
|
||||
import copy
|
||||
import traceback
|
||||
from functools import partial, update_wrapper
|
||||
|
||||
import core.ast.nodes
|
||||
from core.sheerka.services.SheerkaFilter import Pipe
|
||||
import core.utils
|
||||
from core.ast.visitors import UnreferencedNamesVisitor
|
||||
from core.builtin_concepts import BuiltinConcepts, ParserResultConcept
|
||||
@@ -86,22 +88,22 @@ class PythonEvaluator(OneReturnValueEvaluator):
|
||||
return sheerka.ret(self.name, False, error, parents=[return_value])
|
||||
|
||||
def get_globals(self, context, node):
|
||||
my_locals = {
|
||||
my_globals = {
|
||||
"Concept": core.concept.Concept,
|
||||
"BuiltinConcepts": core.builtin_concepts.BuiltinConcepts,
|
||||
}
|
||||
|
||||
# has to tbe the first, to allow override
|
||||
method_from_sheerka = self.update_globals_with_sheerka_methods(my_locals, context)
|
||||
# has to be the first, to allow override
|
||||
method_from_sheerka = self.update_globals_with_sheerka_methods(my_globals, context)
|
||||
|
||||
self.update_globals_with_context(my_locals, context)
|
||||
self.update_globals_with_node(my_locals, context, node)
|
||||
self.update_globals_with_context(my_globals, context)
|
||||
self.update_globals_with_node(my_globals, context, node)
|
||||
|
||||
if self.locals: # when exta values are given. Add them
|
||||
my_locals.update(self.locals)
|
||||
if self.locals: # when extra values are given. Add them
|
||||
my_globals.update(self.locals)
|
||||
|
||||
my_locals["sheerka"] = Expando(method_from_sheerka) # it's the last, so I cannot be overridden
|
||||
return my_locals
|
||||
my_globals["sheerka"] = Expando(method_from_sheerka) # it's the last, so I cannot be overridden
|
||||
return my_globals
|
||||
|
||||
@staticmethod
|
||||
def update_globals_with_sheerka_methods(my_locals, context):
|
||||
@@ -118,6 +120,10 @@ class PythonEvaluator(OneReturnValueEvaluator):
|
||||
for method_name, method in methods_from_sheerka.items():
|
||||
my_locals[method_name] = method
|
||||
|
||||
# Add pipeable functions
|
||||
for func_name, function in context.sheerka.sheerka_pipeables.items():
|
||||
my_locals[func_name] = Pipe(function, context)
|
||||
|
||||
return methods_from_sheerka # to allow access using prefix "sheerka."
|
||||
|
||||
def update_globals_with_context(self, my_locals, context):
|
||||
|
||||
Reference in New Issue
Block a user