spreadflow_core.dsl.stream module

Generic functions to manipulate and inspect token operation streams.

class spreadflow_core.dsl.stream.AddTokenOp(token)

Bases: tuple

__getnewargs__()

Return self as a plain tuple. Used by copy and pickle.

__getstate__()

Exclude the OrderedDict from pickling

__repr__()

Return a nicely formatted representation string

token

Alias for field number 0

exception spreadflow_core.dsl.stream.DuplicateTokenError

Bases: spreadflow_core.dsl.stream.StreamError

Raised when applying a token operation would result in duplicate tokens.

exception spreadflow_core.dsl.stream.NoSuchTokenError

Bases: spreadflow_core.dsl.stream.StreamError

Raised when an operation is attempted on a token which does not exist.

class spreadflow_core.dsl.stream.RemoveTokenOp(token)

Bases: tuple

__getnewargs__()

Return self as a plain tuple. Used by copy and pickle.

__getstate__()

Exclude the OrderedDict from pickling

__repr__()

Return a nicely formatted representation string

token

Alias for field number 0

class spreadflow_core.dsl.stream.SetDefaultTokenOp(token)

Bases: tuple

__getnewargs__()

Return self as a plain tuple. Used by copy and pickle.

__getstate__()

Exclude the OrderedDict from pickling

__repr__()

Return a nicely formatted representation string

token

Alias for field number 0

class spreadflow_core.dsl.stream.StreamBranch

Bases: object

Abstract base class for parsers operating on selected tokens.

consume(stream)

Divides a stream into selected and rejected substreams.

Parameters:stream (-) – A stream consisting of token operations.
divert(stream)

Processes a stream and returns an iterator over rejected operations.

extract(stream)

Processes a stream and returns an iterator over all operations.

original = None
predicate(operation)

Abstract filter method. Must be implemented in subclass.

Returns:True if the operation should be added to the selected stream, False if it should be added to the rejected stream.
Return type:bool
rejected = None
selected = None
exception spreadflow_core.dsl.stream.StreamError

Bases: exceptions.Exception

Token operation stream base error.

spreadflow_core.dsl.stream.token_attr_map(stream, keyattr, valueattr=None)

Apply all token operations in order and construct a mapping.

spreadflow_core.dsl.stream.token_map(stream, keyfunc=<function <lambda>>, valuefunc=<function <lambda>>)

Apply all token operations in order and construct a mapping.