io.omk_json.document
document
The OMK JSON document (format specification §5, §8, §10–11): a graph written as canonical text, and canonical text read back as a graph.
>>> from openmusickit.graph.graph import GraphMeta, OmkGraph
>>> from openmusickit.objects.note_event import NoteEvent
>>> from openmusickit.systems.wsmn.temporal.symbols import quarter
>>> from openmusickit.systems.wsmn.tonal.symbols import C
>>> graph = OmkGraph(GraphMeta(name="Sketch"))
>>> note = NoteEvent(tones={C}, duration=quarter)
>>> graph.add_node(note)
>>> text = dumps(graph)
>>> again = loads(text)
>>> again.get_node(note.id) == note, again.meta.name, dumps(again) == text
(True, 'Sketch', True)Attributes
| Name | Description |
|---|---|
| FORMAT | |
| DOCUMENT_KEYS | |
| NODE_KEYS | |
| EDGE_KEYS |
Functions
| Name | Description |
|---|---|
| vocabularies_with | The core and WSMN vocabularies, which are always given, followed by extra. |
| dumps | The canonical document of graph (§9). |
| write | Writes the canonical document of graph to a file, as UTF-8 with LF line endings. |
| loads | A new graph holding the document’s nodes and edges, with their ids, |
| read | The graph a document file holds (see loads). |
| decode | The document’s graph metadata, its nodes (with their ids and meta set), |