httk.serve.optimade.filter

Re-exports of the OPTIMADE filter-language parser.

The parser is implemented in httk.core.optimade, beside the vendored OPTIMADE property definitions, and is also exposed through this package.

Exceptions

ParserError

Common base class for all non-exit exceptions.

ParserSyntaxError

Common base class for all non-exit exceptions.

Functions

parse_optimade_filter(filter_string[, verbosity])

Parse an OPTIMADE filter into the public abstract syntax tree format.

parse_optimade_filter_raw(filter_string[, verbosity])

Parse an OPTIMADE filter and return its raw grammar parse tree.

Package Contents

exception httk.serve.optimade.filter.ParserError[source]

Bases: Exception

Common base class for all non-exit exceptions.

exception httk.serve.optimade.filter.ParserSyntaxError(*args)[source]

Bases: ParserError

Common base class for all non-exit exceptions.

info
line
pos
linestr
httk.serve.optimade.filter.parse_optimade_filter(filter_string, verbosity=0)[source]

Parse an OPTIMADE filter into the public abstract syntax tree format.

Parameters:
  • filter_string (str) – OPTIMADE filter expression to parse.

  • verbosity (int | Any) – Diagnostic verbosity setting passed to the parser.

Returns:

Nested tuple abstract syntax tree in ojf format.

Raises:
  • ParserSyntaxError – If the filter cannot be parsed, or is too long or too deeply nested to parse within the interpreter’s recursion limit.

  • ParserError – If the filter cannot be parsed.

Return type:

FilterAst

httk.serve.optimade.filter.parse_optimade_filter_raw(filter_string, verbosity=0)[source]

Parse an OPTIMADE filter and return its raw grammar parse tree.

Parameters:
  • filter_string (str) – OPTIMADE filter expression to parse.

  • verbosity (int | Any) – Diagnostic verbosity setting passed to the parser.

Returns:

Raw nested tuple parse tree before ojf conversion.

Raises:
  • ParserSyntaxError – If the filter cannot be parsed, or is too long or too deeply nested to parse within the interpreter’s recursion limit.

  • ParserError – If the filter cannot be parsed.

Return type:

tuple[Any, …]