29 lines
871 B
Python
29 lines
871 B
Python
from core.builtin_concepts import BuiltinConcepts
|
|
from parsers.BaseParser import BaseParser
|
|
|
|
|
|
class EmptyStringParser(BaseParser):
|
|
"""
|
|
To parse empty or blank strings
|
|
"""
|
|
|
|
def __init__(self, **kwargs):
|
|
BaseParser.__init__(self, "EmptyString", 90)
|
|
|
|
def parse(self, context, text):
|
|
sheerka = context.sheerka
|
|
|
|
if isinstance(text, str) and text.strip() == "" or \
|
|
isinstance(text, list) and text == [] or \
|
|
text is None:
|
|
ret = sheerka.ret(self.name, True, sheerka.new(
|
|
BuiltinConcepts.PARSER_RESULT,
|
|
parser=self,
|
|
source="",
|
|
body=sheerka.new(BuiltinConcepts.NOP)))
|
|
else:
|
|
ret = sheerka.ret(self.name, False, sheerka.new(BuiltinConcepts.NOT_FOR_ME))
|
|
|
|
self.log_result(context, text, ret)
|
|
return ret
|