API

Top-level functions

joml.loads(string)

Parse journeys from a JOML document.

Parameters:

string – A JOML document.

Returns:

The journeys described by the document, in the order they appear.

Journeys

class joml.Journey(legs: list[Leg])

A sequence of legs, travelled in order.

Attr legs:

The legs of the journey, in the order they are travelled.

property origin: Stop

The first stop of the journey.

property destination: Stop

The final stop of the journey.

class joml.Leg(origin: Stop, destination: Stop, mode_of_transport: str)

A single mode of transport between two stops.

Attr origin:

The stop the leg starts from.

Attr destination:

The stop the leg ends at.

Attr mode_of_transport:

How the leg is travelled.

class joml.Stop(place_name: str, date: date, time: time | None = None)

A place at a point in time.

Attr place_name:

The name of the place.

Attr date:

The date the stop is reached.

Attr time:

The time the stop is reached, if specified.

Parser

joml.parse(tokens: list[Token]) → list[Journey]

Parse a list of JOML tokens into a list of journeys.

Parameters:

tokens – The tokens to parse.

Returns:

The journeys described by the tokens.

Raises:

ValueError – If the tokens do not describe valid journeys.

Tokeniser

joml.tokenise(s: str) → list[Token]

Split a JOML document into a list of tokens.

Comments, which begin with # and continue to the end of the line, are discarded.

Parameters:

s – A JOML document.

Returns:

The tokens in the document, in the order they appear.

class joml.tokeniser.Token(type: TokenType, value: str)

A low-level token from a JOML document.

Attr type:

The type of the token.

Attr value:

The value of the token.

type: TokenType

Alias for field number 0

value: str

Alias for field number 1

class joml.tokeniser.TokenType(*values)

The type of a token.

class joml.tokeniser.Keyword(*values)

A keyword that delimits parts of a JOML document.