conditional
conditional
#
cg.when(condition) — collect a block into the true branch of an IfThenElse.
The block runs only when condition is true; the else branch does nothing. The
condition node is built by the caller (before the with), so it is recorded
in the enclosing context and caught by the IfThenElse. A path cached inside the
block stays assigned and readable for the rest of the procedure.
ConditionalContext
#
Bases: ProcedureContext
Reduce a block's roots to the true branch of an IfThenElse.
Source code in capturegraph-lib/capturegraph/procedures/procedure/authoring/contexts/conditional.py
__init__(condition)
#
Reduce the block into the true branch guarded by condition.
when(condition)
#
Run the with block only when condition is true (else do nothing).
Pairs naturally with path.exists() to guard a block on a value's presence:
with cg.when(root.gps_bounds.exists()):.