plainbox.impl.parsers – generic parser interface

This module offers high-level API for parsing text into hierarchical data structures, in particular, JSON. Parsers like this can be used to create abstract syntax trees of compatible inputs. For convenience and scriptability any parser is expected to be able to dump its AST as JSON.

class plainbox.impl.parsers.IParser[source]

Abstract interface for parsers.

The interface is meant to be suitable for the implementation of the plainbox dev parse command. It offers a simple API for parsing strings and getting JSON in result.

name[source]

name of the parser

parse_text_to_ast(text)[source]

Parse the specified text and return a parser-specific native Abstract Syntax Tree that represents the input.

Any exception gets logged and causes None to be returned.

parse_text_to_json(text)[source]

Parse the specified text and return a JSON string representing the result.

Returns:None in case of parse error
Returns:string representing JSON version of the parsed AST
summary[source]

one-line description of the parser

class plainbox.impl.parsers.ParserPlugIn(name, obj)[source]

PlugIn wrapping a parser function.

Useful for wrapping checkbox parser functions.

name[source]

name of the parser

parse_text_to_ast(text)[source]

Parse the specified text and return a parser-specific native Abstract Syntax Tree that represents the input.

Any exception gets logged and causes None to be returned.

parse_text_to_json(text)[source]

Parse the specified text and return a JSON string representing the result.

Returns:None in case of parse error
Returns:string representing JSON version of the parsed AST
parser_fn[source]

real parser function

summary[source]

one-line description of the parser

This value is computed from the docstring of the wrapped function. In fact, it is the fist line of the docstring.

Previous topic

plainbox.impl.logging – configuration for logging

Next topic

plainbox.impl.providers – providers package

This Page