Skip to content

steps

steps #

cg.do / cg.do_optional — record a step for effect.

A node that returns Void (an instruction, a metronome) is already a step the moment it is constructed in a procedure body. cg.do exists to record a step whose result should be discarded on purpose: it wraps the node in a RequiredProcedure (or OptionalProcedure), which catches it and presents a Void effect. Both return the wrapper node.

do(step) #

Record step as a required side-effect step, discarding its result.

Source code in capturegraph-lib/capturegraph/procedures/procedure/authoring/steps.py
def do(step: Procedure[CGType]) -> RequiredProcedure:
    """Record ``step`` as a required side-effect step, discarding its result."""
    from capturegraph.procedures.nodes.process.structural import (
        RequiredProcedure,
    )

    return RequiredProcedure(procedure=step)

do_optional(step) #

Record step as an optional step (its failure never fails the procedure).

Source code in capturegraph-lib/capturegraph/procedures/procedure/authoring/steps.py
def do_optional(step: Procedure[CGType]) -> OptionalProcedure:
    """Record ``step`` as an optional step (its failure never fails the procedure)."""
    from capturegraph.procedures.nodes.process.structural import (
        OptionalProcedure,
    )

    return OptionalProcedure(procedure=step)