tilie_server.routers.measure_maps#

The measure-maps route: a manifest’s measure maps, expanded by timetoalign.

A manifest holds each measure map as the compressed rows of the Measure Map standard. The editor reads measures (to evaluate the measure views) from the expanded rows, and the expansion is timetoalign’s alone: the editor asks this route once for each version of a manifest.

The editor posts a manifest file’s text, in any serialization timetoshare reads, with every ID written #id. The answer is the editor’s own interface and no manifest file: it names each map by its bare ID, the one the editor matches a measure view’s measure_map against.

The expansion and timetoshare’s reader (tilie_server.manifests) are imported when a request needs them, so a server whose installed timetoalign or timetoshare lacks them still starts and answers every other route; this route then answers 501.

tilie_server.routers.measure_maps.ROW_MEMBERS = ('ID', 'count', 'qstamp', 'number', 'name', 'time_signature', 'nominal_length', 'actual_length', 'start_repeat', 'end_repeat', 'next', 'volta', 'offset_within_measure')#

The members of an expanded row, in the order the answer writes them.

tilie_server.routers.measure_maps.QUARTER_MEMBERS = frozenset({'actual_length', 'nominal_length', 'offset_within_measure', 'qstamp'})#

The members holding a position or a length in quarters.

tilie_server.routers.measure_maps.measure_map_class()[source]#

Return timetoalign’s MeasureMap, which holds the expansion.

Raises:

Refusal – 501, if the installed timetoalign has no measure maps.

Return type:

Any

tilie_server.routers.measure_maps.fraction_pair(value)[source]#

Write an exact quarter-note value as a Fraction pair, None as null.

Parameters:

value (Fraction | int | None)

Return type:

list[int] | None

tilie_server.routers.measure_maps.answer_row(row)[source]#

Write one expanded row in the answer’s form.

The quarter-note values become Fraction pairs; the keys a row carries outside the row form are left out, as they are no member of a measure.

Parameters:

row (dict[str, Any])

Return type:

dict[str, Any]

tilie_server.routers.measure_maps.expanded_measure_maps(manifest, measure_map)[source]#

Expand every entry of a manifest’s measure_maps, in its order.

Parameters:
  • manifest (Any) – The manifest, an object with bare IDs.

  • measure_map (Any) – timetoalign’s MeasureMap (measure_map_class()).

Returns:

One {"id", "rows"} object per entry.

Raises:

Refusal – If its measure_maps is no list, or timetoalign refuses an entry.

Return type:

list[dict[str, Any]]

tilie_server.routers.measure_maps.measure_maps(body)[source]#

Answer the expanded rows of every measure map of the posted manifest.

The body is a manifest file’s text in any serialization. A body that cannot be read, is no object, writes an ID outside the file form or holds a measure map that timetoalign refuses is answered 422 with {"detail": {"path", "message"}}; a timetoalign that cannot expand measure maps, or a timetoshare that cannot read manifest files, 501.

Parameters:

body (Annotated[bytes, Depends(dependency=~tilie_server.manifests.posted_body, use_cache=True, scope=function)])

Return type:

JSONResponse