Skip to content

teff.flow.case

teff.flow.case

Branch case for conditional routing.

Classes:

Name Description
Case

A single branch case used with Flow.branch().

Case

A single branch case used with Flow.branch().

Methods:

Name Description
add

Add a node to this case branch.

Source code in teff/flow/case.py
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
class Case:
    """A single branch case used with ``Flow.branch()``."""

    def __init__(self, value: str):
        self.value = value
        self._nodes: list[Node] = []
        self._ids: list[str | None] = []

    def add(self, node: Node, id: str | None = None) -> "Case":
        """Add a node to this case branch.

        *id* optionally names the node in the compiled graph instead of
        the auto-generated ``{type}_{n}``.
        """
        self._nodes.append(node)
        self._ids.append(id)
        return self

add

add(node, id=None)

Add a node to this case branch.

id optionally names the node in the compiled graph instead of the auto-generated {type}_{n}.

Source code in teff/flow/case.py
14
15
16
17
18
19
20
21
22
def add(self, node: Node, id: str | None = None) -> "Case":
    """Add a node to this case branch.

    *id* optionally names the node in the compiled graph instead of
    the auto-generated ``{type}_{n}``.
    """
    self._nodes.append(node)
    self._ids.append(id)
    return self