Margrete RPC

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

attributetransportRpcTransport
attributecurrent_tickint

The editor playhead tick captured when the transaction opened.

attributechartChart

The loaded :class:~margrete_rpc.chart.Chart; mutate its notes and events to describe the edit.

attributesnapshot_enabledbool

Whether a baseline snapshot was captured for diffing.

attributetracerTracer
= field(default_factory=NoopTracer)
attributetx_typestr
= 'edit'
attributereplace_all_notesbool
= False

Replace all notes on apply instead of sending a diff.

attribute_span_activeAbstractContextManager[None] | None
= None
attribute_snapshotEditSnapshot | None
= None
attribute_resolver_tokencontextvars.Token[TickResolver | None] | None
= None
attribute_beat_events_tokencontextvars.Token[Iterable[BeatEvent] | None] | None
= None

Functions

func_resolve_position(self, pos) -> int
paramself
paramposPositionLike

Returns

int
func__enter__(self) -> EditTransaction
paramself

Returns

margrete_rpc.transaction.EditTransaction
func__exit__(self, exc_type, exc, tb) -> bool
paramself
paramexc_typetype[BaseException] | None
paramexcBaseException | None
paramtbTracebackType | None

Returns

bool
func__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) -> None
paramself
paramtransportRpcTransport
paramcurrent_tickint
paramchartChart
paramsnapshot_enabledbool
paramtracerTracer
= NoopTracer()
paramtx_typestr
= 'edit'
paramreplace_all_notesbool
= False
param_span_activeAbstractContextManager[None] | None
= None
param_snapshotEditSnapshot | None
= None
param_resolver_tokencontextvars.Token[TickResolver | None] | None
= None
param_beat_events_tokencontextvars.Token[Iterable[BeatEvent] | None] | None
= None

Returns

None

On this page