Example #1
0
    def test_exporttostring(self):
        doc = MeiDocument()
        root = MeiElement("mei")
        root.id = "myid"
        doc.root = root

        expected = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<mei xml:id=\"myid\" xmlns=\"http://www.music-encoding.org/ns/mei\" meiversion=\"2013\" />\n"
        ret = documentToText(doc)
        self.assertEqual(expected, ret)
Example #2
0
    def test_exporttostring(self):
        doc = MeiDocument()
        root = MeiElement("mei")
        root.id = "myid"
        doc.root = root

        expected = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<mei xml:id=\"myid\" xmlns=\"http://www.music-encoding.org/ns/mei\" meiversion=\"2013\" />\n"
        ret = documentToText(doc)
        self.assertEqual(expected, ret)
Example #3
0
    def test_exportcomment(self):
        doc = MeiDocument()
        root = MeiElement("mei")
        root.id = "myid"

        doc.root = root

        comment = MeiElement("_comment")
        comment.value = "comment"
        comment.tail = "t"

        root.addChild(comment)
        expected = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<mei xml:id=\"myid\" xmlns=\"http://www.music-encoding.org/ns/mei\" meiversion=\"2013\">\n\t<!--comment-->t</mei>\n"
        ret = documentToText(doc)
        self.assertEqual(expected, ret)
Example #4
0
    def test_exportcomment(self):
        doc = MeiDocument()
        root = MeiElement("mei")
        root.id = "myid"

        doc.root = root

        comment = MeiElement("_comment")
        comment.value = "comment"
        comment.tail = "t"

        root.addChild(comment)
        expected = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<mei xml:id=\"myid\" xmlns=\"http://www.music-encoding.org/ns/mei\" meiversion=\"2013\">\n\t<!--comment-->t</mei>\n"
        ret = documentToText(doc)
        self.assertEqual(expected, ret)
Example #5
0
    def test_exportvalueandtail(self):
        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)

        expected = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<mei xml:id=\"myid\" xmlns=\"http://www.music-encoding.org/ns/mei\" meiversion=\"2013\">\n\t<note xml:id=\"noteid\">value</note>tail</mei>\n"
        ret = documentToText(doc)

        self.assertEqual(expected, ret)
Example #6
0
    def test_exportvalueandtail(self):
        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)

        expected = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<mei xml:id=\"myid\" xmlns=\"http://www.music-encoding.org/ns/mei\" meiversion=\"2013\">\n\t<note xml:id=\"noteid\">value</note>tail</mei>\n"
        ret = documentToText(doc)

        self.assertEqual(expected, ret)
Example #7
0
def process(jsomr, syls, classifier, width_mult, verbose=True):
    '''
    Runs the entire MEI encoding process given the three inputs to the rodan job and the
    width_multiplier parameter for merging neume components.
    '''
    glyphs = jsomr['glyphs']
    syl_boxes = syls['syl_boxes'] if syls is not None else None
    median_line_spacing = syls[
        'median_line_spacing'] if syls is not None else None

    glyphs = add_flags_to_glyphs(glyphs)
    pairs = neume_to_lyric_alignment(glyphs, syl_boxes, median_line_spacing)
    meiDoc = build_mei(pairs, classifier, jsomr['staves'], jsomr['page'])

    if width_mult > 0:
        meiDoc = merge_nearby_neume_components(meiDoc, width_mult=width_mult)

    return documentToText(meiDoc)
Example #8
0
    def test_documentrootnotset(self):
        doc = MeiDocument()
        with self.assertRaises(DocumentRootNotSetException) as cm:
            ret = documentToText(doc)

        self.assertTrue(isinstance(cm.exception, DocumentRootNotSetException))
Example #9
0
    def test_documentrootnotset(self):
        doc = MeiDocument()
        with self.assertRaises(DocumentRootNotSetException) as cm:
            ret = documentToText(doc)

        self.assertTrue(isinstance(cm.exception, DocumentRootNotSetException))