Added first version of DebugManager. Implemented draft of the rule engine
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import types
|
||||
|
||||
from core.builtin_concepts import BuiltinConcepts
|
||||
from core.concept import Concept
|
||||
from core.concept import Concept, NotInit
|
||||
from printer.FormatInstructions import FormatInstructions, FormatDetailType
|
||||
from printer.Formatter import Formatter
|
||||
|
||||
@@ -36,6 +36,7 @@ class SheerkaPrinter:
|
||||
self.custom_concepts_printers = {
|
||||
str(BuiltinConcepts.EXPLANATION): self.print_explanation,
|
||||
str(BuiltinConcepts.RETURN_VALUE): self.print_return_value,
|
||||
str(BuiltinConcepts.TO_LIST): self.print_to_list,
|
||||
}
|
||||
self.formatter.reset_formats()
|
||||
self.formatter.register_format_l(EXECUTION_CONTEXT_CLASS, "[{id:3}] %tab%{desc} ({status})")
|
||||
@@ -110,7 +111,7 @@ class SheerkaPrinter:
|
||||
|
||||
if instructions.recursive_props:
|
||||
for k, v in instructions.recursive_props.items():
|
||||
if hasattr(item, k) and v > 0 and (value := getattr(item, k)) != BuiltinConcepts.NOT_INITIALIZED:
|
||||
if hasattr(item, k) and v > 0 and (value := getattr(item, k)) != NotInit:
|
||||
self.fp(instructions.recurse(k), value)
|
||||
|
||||
@staticmethod
|
||||
@@ -137,11 +138,19 @@ class SheerkaPrinter:
|
||||
printer.fp(explanation_instructions, f"%blue%{item.digest}%reset% : {item.command}")
|
||||
printer.fp(explanation_instructions, item.body)
|
||||
|
||||
@staticmethod
|
||||
def print_to_list(printer, instructions, item):
|
||||
explanation_instructions = instructions.clone().merge(item.get_format_instructions())
|
||||
printer.fp(explanation_instructions, item.body)
|
||||
|
||||
@staticmethod
|
||||
def print_return_value(printer, instructions, item):
|
||||
if printer.sheerka.isinstance(item.body, BuiltinConcepts.EXPLANATION):
|
||||
return printer.fp(instructions, item.body)
|
||||
|
||||
if printer.sheerka.isinstance(item.body, BuiltinConcepts.TO_LIST):
|
||||
return printer.fp(instructions, item.body)
|
||||
|
||||
if isinstance(item.body, (list, tuple, types.GeneratorType)):
|
||||
return printer.fp(instructions, item.body)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user