Added bnf when adding a new concept + Started logging filtering
This commit is contained in:
+8
-8
@@ -3,6 +3,7 @@ from dataclasses import dataclass
|
||||
from enum import Enum
|
||||
import logging
|
||||
|
||||
import core.utils
|
||||
from core.tokenizer import Tokenizer, TokenKind
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
@@ -18,8 +19,7 @@ VARIABLE_PREFIX = "__var__"
|
||||
|
||||
class ConceptParts(Enum):
|
||||
"""
|
||||
Helper class, Note quite sure that is it that useful
|
||||
I guess, I was learning nums with Python...
|
||||
Lists metadata that can contains some code
|
||||
"""
|
||||
WHERE = "where"
|
||||
PRE = "pre"
|
||||
@@ -85,6 +85,7 @@ class Concept:
|
||||
self.metadata = metadata
|
||||
self.props = {} # list of Property for this concept
|
||||
self.cached_asts = {} # cached ast for the where, pre, post and body parts
|
||||
self.bnf = None
|
||||
|
||||
def __repr__(self):
|
||||
return f"({self.metadata.id}){self.metadata.name}"
|
||||
@@ -134,9 +135,9 @@ class Concept:
|
||||
return self
|
||||
|
||||
if tokens is None:
|
||||
tokens = iter(Tokenizer(self.metadata.name))
|
||||
tokens = list(Tokenizer(self.metadata.name))
|
||||
|
||||
variables = list(self.props.keys())
|
||||
variables = list(self.props.keys()) if len(core.utils.strip_tokens(tokens, True)) > 1 else []
|
||||
|
||||
key = ""
|
||||
first = True
|
||||
@@ -171,12 +172,11 @@ class Concept:
|
||||
:param codes:
|
||||
:return:
|
||||
"""
|
||||
possibles_codes = ConceptParts.get_parts()
|
||||
if codes is None:
|
||||
return
|
||||
|
||||
for key in codes:
|
||||
if key in possibles_codes:
|
||||
self.cached_asts[ConceptParts(key)] = codes[key]
|
||||
self.cached_asts[key] = codes[key]
|
||||
|
||||
return self
|
||||
|
||||
@@ -231,7 +231,7 @@ class Concept:
|
||||
return self
|
||||
|
||||
def set_prop(self, prop_name: str, prop_value=None):
|
||||
self.props[prop_name] = Property(prop_name, prop_value)
|
||||
self.props[prop_name] = Property(prop_name, prop_value) # Python 3.x order is kept in dictionaries
|
||||
return self
|
||||
|
||||
def set_prop_by_index(self, index: int, prop_value):
|
||||
|
||||
Reference in New Issue
Block a user