timetoshare.ids#

IDs in a manifest file and in memory.

A manifest file writes every ID with a leading #: an element’s own ID ("id": "#clt_1") as well as every reference to one (a group’s members, the keys of graphical.order, a named timestamp’s timeline, an elision’s timeline, an alignment anchor’s timestamps, a resource’s timelines, an address’s id, a selector’s within, a declaration’s flow, the to of a jump’s destination, the jump and to of an after, a FlowMap’s timeline and the IDs among its chunks, a virtual timeline’s map, timeline and through, a measure view’s measure_map). The IDs of MatchClaims a MatchStamp lists name rows of a MatchClaim table, not elements, and are no ID position. In memory an ID is bare: clt_1. Exactly one # is stripped, so the file text ##x is the bare ID #x.

One position holds an ID or something else: the values of a group’s entry in graphical.order are member IDs, while a timeline’s entry holds band words, which stay bare. The IRIs of statements and provenance, a reference to an element ({"id": "#clt_1"}) among them, are no ID position: they are written the same in a file and in memory.

with_file_ids and with_bare_ids convert a whole manifest between the two forms. Both are pure: they return a new value, keep unknown keys and the order of every object’s keys (an order key renamed in place keeps its position) and leave every number as it is. Both are driven by one table of the positions of IDs, ID_POSITIONS, by schema definition and member, and one table of where each definition occurs, CONTAINERS.

timetoshare.ids.HASH = '#'#

The character that marks an ID in a manifest file.

timetoshare.ids.NOMATCH_SENTINEL = 'NOMATCH_SENTINEL'#

The event ID of a NOMATCH side in a MatchClaim table: a MatchClaim that is not synchronous states that the event of its other side has no counterpart on this timeline. It is no event, holds no anchor and is never an element’s ID.

timetoshare.ids.CHUNK_SENTINEL = 'CHUNK_SENTINEL'#

The event ID of a CHUNK side in a MatchClaim table: a synchronous MatchClaim states a coordinate on this timeline, which holds no event for it; the coordinate is the anchor’s on this side. It is no event and never an element’s ID.

timetoshare.ids.SENTINELS = ('NOMATCH_SENTINEL', 'CHUNK_SENTINEL')#

The two reserved strings: an event ID column holds them besides event IDs, and no element, event or Projection takes either as its ID.

timetoshare.ids.Shape#

How a member holds IDs.

id the member is one ID; ref one ID too, in a member named id that names another element rather than the object’s own (an address’s id); ids a list of IDs, an item that is no string (a FlowMap’s gap) kept as it is; order an object keyed by IDs whose value, where the key names a group, is a list of member IDs (a timeline’s value holds band words).

alias of Literal[‘id’, ‘ref’, ‘ids’, ‘order’]

timetoshare.ids.ID_POSITIONS: tuple[tuple[str, str, Literal['id', 'ref', 'ids', 'order']], ...] = (('Manifest', 'id', 'id'), ('Timeline', 'id', 'id'), ('Group', 'id', 'id'), ('Group', 'members', 'ids'), ('Graphical', 'order', 'order'), ('Timestamp', 'id', 'id'), ('Timestamp', 'timeline', 'id'), ('Elision', 'id', 'id'), ('Elision', 'timeline', 'id'), ('MatchStamp', 'id', 'id'), ('AlignmentAnchor', 'id', 'id'), ('AlignmentAnchor', 'timestamps', 'ids'), ('Resource', 'id', 'id'), ('Resource', 'timelines', 'ids'), ('Address', 'id', 'ref'), ('MeasureMap', 'id', 'id'), ('Region', 'id', 'id'), ('FlowControlElement', 'id', 'id'), ('JumpDestination', 'to', 'id'), ('DestinationReference', 'jump', 'id'), ('DestinationReference', 'to', 'id'), ('FlowMap', 'id', 'id'), ('FlowMap', 'timeline', 'id'), ('FlowMap', 'chunks', 'ids'), ('VirtualTimeline', 'id', 'id'), ('VirtualTimeline', 'map', 'id'), ('VirtualTimeline', 'timeline', 'id'), ('VirtualTimeline', 'through', 'id'), ('Selector', 'within', 'id'), ('Declaration', 'flow', 'id'), ('MapBase', 'id', 'id'), ('MeasureView', 'measure_map', 'id'))#

Every member of a schema definition that holds IDs, and how it holds them.

timetoshare.ids.Holding#

How a member holds a definition: one object, a list, or an object’s values.

alias of Literal[‘one’, ‘list’, ‘values’]

timetoshare.ids.CONTAINERS: tuple[tuple[str, str, Literal['one', 'list', 'values'], str], ...] = (('Manifest', 'timelines', 'list', 'Timeline'), ('Manifest', 'groups', 'list', 'Group'), ('Manifest', 'measure_maps', 'list', 'MeasureMap'), ('Manifest', 'resources', 'list', 'Resource'), ('Manifest', 'graphical', 'one', 'Graphical'), ('Manifest', 'flow_maps', 'list', 'FlowMap'), ('Manifest', 'virtual_timelines', 'list', 'VirtualTimeline'), ('Timeline', 'children', 'list', 'Timeline'), ('Timeline', 'conversion_maps', 'list', 'ConversionMap'), ('Timeline', 'regions', 'list', 'Region'), ('Timeline', 'flow_control', 'list', 'FlowControlElement'), ('FlowControlElement', 'targets', 'list', 'JumpDestination'), ('FlowControlElement', 'ends', 'one', 'BreakCondition'), ('JumpDestination', 'after', 'one', 'DestinationReference'), ('BreakCondition', 'after', 'one', 'DestinationReference'), ('Graphical', 'styles', 'values', 'Declaration'), ('Graphical', 'rules', 'list', 'Rule'), ('Graphical', 'timestamps', 'list', 'Timestamp'), ('Graphical', 'elisions', 'list', 'Elision'), ('Graphical', 'matchstamps', 'list', 'MatchStamp'), ('MatchStamp', 'alignment_anchors', 'list', 'AlignmentAnchor'), ('Rule', 'select', 'one', 'Selector'), ('Rule', 'set', 'one', 'Declaration'), ('Selector', 'addresses', 'list', 'Address'), ('ChainMap', 'maps', 'list', 'ConversionMap'), ('PiecewiseMap', 'maps', 'list', 'ConversionMap'), ('CombinationMap', 'maps', 'values', 'ConversionMap'))#

Every member through which a definition holds another that holds IDs.

timetoshare.ids.MEASURE_VIEWS: tuple[str, ...] = ('FloatingMeasureMap', 'MeasureBeatMap', 'MeasureNumberMap', 'MeasureRecordMap')#

The conversion-map types built on MeasureView; every other one on MapBase.

exception timetoshare.ids.FileIdError(message, path=())[source]#

Bases: ValueError

Raised for a text that is not an ID in the file form.

path#

Where the text stands in the manifest; empty for a lone text.

timetoshare.ids.to_file_id(id)[source]#

Return the file form of a bare ID: # followed by the ID.

timetoshare.ids.from_file_id(text)[source]#

Return the bare ID that a file’s #id text writes.

Exactly one leading # is stripped: #x is x and ##x is #x.

Raises:

FileIdError – A ValueError, if the text does not start with # or nothing follows it.

timetoshare.ids.definitions_of(definition, value)[source]#

The definitions whose members value, held as definition, carries.

A conversion map is its type’s definition and that definition’s bases; every other value is its definition alone.

timetoshare.ids.with_file_ids(manifest)[source]#

Return the manifest with every ID in the file form, # + the bare ID.

A value of graphical.order gains the # where its key names a group.

timetoshare.ids.with_bare_ids(manifest)[source]#

Return the manifest with every ID bare, read from its file form #id.

A timeline’s entry in graphical.order holds band words, which stay as they are.

Raises:

FileIdError – A ValueError, with the path of the first text that is not an ID in the file form.

timetoshare.ids.leniently_bare_ids(manifest)[source]#

with_bare_ids that keeps every text not in the file form as it is.

For a check of one part of a manifest, which must not refuse an ID outside that part.