base
base
#
The shared base for every recording context.
A [ProcedureContext][] owns two things: the ordered list of nodes emitted
into it (every node constructed while it is active) and the set of node ids
caught by it (used as some node's child). The active context lives in a single
[ContextVar][contextvars.ContextVar]; a node registers itself through [_collect][]
from Procedure.__post_init__.
ProcedureContext
#
Collects the nodes a block constructs and reduces them to its roots.
Subclasses differ only in [_finish][] — how they wrap the leftover roots (a sequence, a set, an optional, a conditional) once the block exits.
Source code in capturegraph-lib/capturegraph/procedures/procedure/authoring/contexts/base.py
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 | |
__init__()
#
Start with no parent, nothing emitted, and nothing caught.
Source code in capturegraph-lib/capturegraph/procedures/procedure/authoring/contexts/base.py
collect()
#
Make this the active context for the block, then [_finish][] it.
_finish runs only on normal exit, after the active context is reset
to the parent — so a wrapper node built there is emitted into the parent.
Source code in capturegraph-lib/capturegraph/procedures/procedure/authoring/contexts/base.py
current()
classmethod
#
The active context, or raise if a node is built with none.