First steps of ConceptLexer. Need to update DefaultParser before continuing
This commit is contained in:
+16
-10
@@ -23,7 +23,7 @@ class Sheerka(Concept):
|
||||
BUILTIN_CONCEPTS_KEYS = "Builtins_Concepts"
|
||||
USER_CONCEPTS_KEYS = "User_Concepts"
|
||||
|
||||
def __init__(self, debug=False):
|
||||
def __init__(self, debug=False, skip_builtins_in_db=False):
|
||||
log.debug("Starting Sheerka.")
|
||||
super().__init__(BuiltinConcepts.SHEERKA, True, True, BuiltinConcepts.SHEERKA)
|
||||
|
||||
@@ -53,6 +53,7 @@ class Sheerka(Concept):
|
||||
self.parsers_prefix = None
|
||||
|
||||
self.debug = debug
|
||||
self.skip_builtins_in_db = skip_builtins_in_db
|
||||
|
||||
def initialize(self, root_folder=None):
|
||||
"""
|
||||
@@ -109,14 +110,15 @@ class Sheerka(Concept):
|
||||
if not concept.is_unique and str(key) in builtins_classes:
|
||||
self.builtin_cache[key] = builtins_classes[str(key)]
|
||||
|
||||
from_db = self.sdp.get_safe(self.CONCEPTS_ENTRY, concept.key)
|
||||
if from_db is None:
|
||||
log.debug(f"'{concept.name}' concept is not found in db. Adding.")
|
||||
self.set_id_if_needed(concept, True)
|
||||
self.sdp.add("init", self.CONCEPTS_ENTRY, concept, use_ref=True)
|
||||
else:
|
||||
log.debug(f"Found concept '{from_db}' in db. Updating.")
|
||||
concept.update_from(from_db)
|
||||
if not self.skip_builtins_in_db:
|
||||
from_db = self.sdp.get_safe(self.CONCEPTS_ENTRY, concept.key)
|
||||
if from_db is None:
|
||||
log.debug(f"'{concept.name}' concept is not found in db. Adding.")
|
||||
self.set_id_if_needed(concept, True)
|
||||
self.sdp.add("init", self.CONCEPTS_ENTRY, concept, use_ref=True)
|
||||
else:
|
||||
log.debug(f"Found concept '{from_db}' in db. Updating.")
|
||||
concept.update_from(from_db)
|
||||
|
||||
self.add_in_cache(concept)
|
||||
|
||||
@@ -125,7 +127,11 @@ class Sheerka(Concept):
|
||||
Init the parsers
|
||||
:return:
|
||||
"""
|
||||
for parser in core.utils.get_sub_classes("parsers", "parsers.BaseParser.BaseParser"):
|
||||
base_class = core.utils.get_class("parsers.BaseParser.BaseParser")
|
||||
for parser in core.utils.get_sub_classes("parsers", base_class):
|
||||
if parser.__module__ == base_class.__module__:
|
||||
continue
|
||||
|
||||
log.debug(f"Adding builtin parser '{parser.__name__}'")
|
||||
self.parsers.append(parser)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user