ottr.parsers package

Module contents

Lexer and parser utilities for manipulating OTTR template definitions and instances.

ottr.parsers.parse_templates(text: str, format: str = 'stottr') → List[ottr.base.template.AbstractTemplate]

Parse a set of OTTR template definitions.

Args:
  • text: Set of OTTR template definitions in text format.

  • format: Format of the input template definitions. Defaults to sOTTR. Supported formats: sOTTR.

Returns:

The parsed OTTR template definitions.

Throws: TypeError if the input format is not supported.

ottr.parsers.parse_instances(text: str, format: str = 'stottr') → List[Dict[str, Union[rdflib.term.BNode, rdflib.term.Literal, rdflib.term.URIRef, rdflib.term.Variable, List[Tuple[int, Union[rdflib.term.BNode, rdflib.term.Literal, rdflib.term.URIRef, rdflib.term.Variable]]]]]]

Parse a set of OTTR template instances.

Args:
  • text: Set of OTTR instances in text format.

  • format: Format of the input instances. Defaults to sOTTR. Supported formats: sOTTR.

Returns:

The parsed OTTR template instances.

Throws: TypeError if the input format is not supported.