EditTransaction
A scoped, atomic edit of a Margrete chart.
Created by :meth:Margrete.open_edit and used as a context manager. Entering the
with block snapshots the chart (when snapshot is enabled) and installs the
chart's beat events as the active position context, so bare (bar, beat, offset)
positions passed to note constructors resolve to ticks. Mutate :attr:chart inside
the block; on clean exit the changes are diffed and sent to Margrete as one undoable
edit, and if the block raises, nothing is applied.
Attributes
attributetransportRpcTransportattributecurrent_tickintThe editor playhead tick captured when the transaction opened.
attributechartChartThe loaded :class:~margrete_rpc.chart.Chart; mutate its notes and
events to describe the edit.
attributesnapshot_enabledboolWhether a baseline snapshot was captured for diffing.
attributetracerTracer= field(default_factory=NoopTracer)attributetx_typestr= 'edit'attributereplace_all_notesbool= FalseReplace all notes on apply instead of sending a diff.
attribute_span_activeAbstractContextManager[None] | None= Noneattribute_snapshotEditSnapshot | None= Noneattribute_resolver_tokencontextvars.Token[TickResolver | None] | None= Noneattribute_beat_events_tokencontextvars.Token[Iterable[BeatEvent] | None] | None= NoneFunctions
func_resolve_position(self, pos) -> intparamselfparamposPositionLikeReturns
intfunc__enter__(self) -> EditTransactionparamselfReturns
margrete_rpc.transaction.EditTransactionfunc__exit__(self, exc_type, exc, tb) -> boolparamselfparamexc_typetype[BaseException] | NoneparamexcBaseException | NoneparamtbTracebackType | NoneReturns
boolfunc__init__(self, transport, current_tick, chart, snapshot_enabled, tracer=NoopTracer(), tx_type='edit', replace_all_notes=False, _span_active=None, _snapshot=None, _resolver_token=None, _beat_events_token=None) -> NoneparamselfparamtransportRpcTransportparamcurrent_tickintparamchartChartparamsnapshot_enabledboolparamtracerTracer= NoopTracer()paramtx_typestr= 'edit'paramreplace_all_notesbool= Falseparam_span_activeAbstractContextManager[None] | None= Noneparam_snapshotEditSnapshot | None= Noneparam_resolver_tokencontextvars.Token[TickResolver | None] | None= Noneparam_beat_events_tokencontextvars.Token[Iterable[BeatEvent] | None] | None= NoneReturns
None