-
Notifications
You must be signed in to change notification settings - Fork 23
Code examples (Python)
William Bain edited this page Jun 22, 2015
·
3 revisions
Some code examples to illustrate how to use the Libmei Python bindings:
import pymei
# An optional boolean second argument to documentFromFile controls
# validation strictness. The default is True.
doc = pymei.documentFromFile("beethoven.mei").getMeiDocument()
from pymei import MeiDocument, MeiElement, documentToFile
# create a very basic document structure
doc = MeiDocument()
root = MeiElement("mei")
root.id = "myid"
doc.root = root
note = MeiElement("note")
note.id = "noteid"
note.value = "value"
note.tail = "tail"
root.addChild(note)
# This will return True if it was successful
status = documentToFile(doc, 'testdoc.mei')
You can also look at the Python unit tests code for more examples.