def parse_element(cls, indent_stack): """Set to the rule the description.""" doc_double = QuotedString(quoteChar='"""', multiline=True) doc_single = QuotedString(quoteChar="'''", multiline=True) doc_string = indentedBlock((doc_double | doc_single), indent_stack) description = (Keyword('description:').suppress() + doc_string) return (description | doc_double | doc_single)\ .setResultsName('description')
def parse_element(cls, indent_stack): """Set. to the rule the list of producers in ``producer`` attribute.""" producer_body = ( Word(alphanums + "_") + originalTextFor(nestedExpr()) + Suppress(',') + PYTHON_ALLOWED_EXPR).setParseAction(lambda toks: { 'code': toks[0], 'params': eval(toks[1]), 'rule': eval(toks[2]) }) return (Keyword('producer:').suppress() + indentedBlock( OneOrMore(producer_body), indent_stack)).setResultsName('producer')
def parse_element(cls, indent_stack): """Set. to the rule the list of producers in ``producer`` attribute.""" producer_body = (Word(alphanums + "_") + originalTextFor(nestedExpr()) + Suppress(',') + PYTHON_ALLOWED_EXPR ).setParseAction( lambda toks: {'code': toks[0], 'params': eval(toks[1]), 'rule': eval(toks[2])}) return (Keyword('producer:').suppress() + indentedBlock(OneOrMore(producer_body), indent_stack) ).setResultsName('producer')
def parse_element(cls, indent_stack): """Set ``json_ext`` in the rule.""" json_dumps = (Keyword('dumps').suppress() + Literal(',').suppress() + PYTHON_ALLOWED_EXPR ).setResultsName("dumps")\ .setParseAction(lambda toks: toks[0].strip()) json_loads = (Keyword("loads").suppress() + Literal(",").suppress() + PYTHON_ALLOWED_EXPR ).setResultsName("loads")\ .setParseAction(lambda toks: toks[0].strip()) return (Keyword('json:').suppress() + indentedBlock((json_dumps & json_loads), indent_stack) ).setResultsName('json_ext')
def parse_element(cls, indent_stack): """Set ``extensions`` attribute to the rule definition.""" import_line = quotedString.setParseAction(removeQuotes) + restOfLine return (Keyword('extensions:').suppress() + indentedBlock( OneOrMore(import_line), indent_stack)).setResultsName('extensions')
def parse_element(cls, indent_stack): """Set the ``schema`` attribute inside the rule.""" return (Keyword('schema:').suppress() + indentedBlock(DICT_DEF, indent_stack) ).setParseAction(lambda toks: toks[0]).setResultsName('schema')
def parse_element(cls, indent_stack): """Set ``extensions`` attribute to the rule definition.""" import_line = quotedString.setParseAction(removeQuotes) + restOfLine return (Keyword('extensions:').suppress() + indentedBlock(OneOrMore(import_line), indent_stack) ).setResultsName('extensions')