本文整理汇总了Python中pymei.MeiDocument.lookBack方法的典型用法代码示例。如果您正苦于以下问题:Python MeiDocument.lookBack方法的具体用法?Python MeiDocument.lookBack怎么用?Python MeiDocument.lookBack使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pymei.MeiDocument
的用法示例。
在下文中一共展示了MeiDocument.lookBack方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_flattenedtree
# 需要导入模块: from pymei import MeiDocument [as 别名]
# 或者: from pymei.MeiDocument import lookBack [as 别名]
def test_flattenedtree(self):
mei = MeiElement("mei")
mus = MeiElement("music")
body = MeiElement("body")
staff = MeiElement("staff")
staff2 = MeiElement("staff")
n1 = MeiElement("note")
n2 = MeiElement("note")
n3 = MeiElement("note")
doc = MeiDocument()
mei.addChild(mus)
doc.root = mei
mus.addChild(body)
body.addChild(staff)
body.addChild(staff2)
staff.addChild(n1)
staff.addChild(n2)
staff2.addChild(n3)
doc.lookBack(n2, "mei")
self.assertEqual(8, len(doc.getFlattenedTree()))
staff.removeChild(n2)
self.assertEqual(7, len(doc.getFlattenedTree()))
self.assertEqual(staff2, doc.getFlattenedTree()[5])
staff.removeChildrenWithName("note")
self.assertEqual(6, len(doc.getFlattenedTree()))
body.deleteAllChildren()
self.assertEqual(3, len(doc.getFlattenedTree()))
children = MeiElementList()
staff3 = MeiElement("staff")
staff4 = MeiElement("staff")
children.append(staff3)
children.append(staff4)
body.children = children
self.assertEqual(5, len(doc.getFlattenedTree()))
elements = [mei, mus, body, staff3, staff4]
for i,el in enumerate(doc.getFlattenedTree()):
self.assertEqual(elements[i], doc.getFlattenedTree()[i])
示例2: test_dur_in_semibreves_mRests
# 需要导入模块: from pymei import MeiDocument [as 别名]
# 或者: from pymei.MeiDocument import lookBack [as 别名]
def test_dur_in_semibreves_mRests(self):
music = MeiElement('music')
body = MeiElement('body')
mdiv = MeiElement('mdiv')
score = MeiElement('score')
sctn = MeiElement('section')
scD1 = MeiElement('scoreDef')
scD2 = MeiElement('scoreDef')
stG1 = MeiElement('staffGrp')
stG2 = MeiElement('staffGrp')
stD1 = MeiElement('staffDef')
stD2 = MeiElement('staffDef')
m1 = MeiElement('measure')
m2 = MeiElement('measure')
l1 = MeiElement('layer')
l2 = MeiElement('layer')
s1 = MeiElement('staff')
s2 = MeiElement('staff')
mR1 = MeiElement('mRest')
mR2 = MeiElement('mRest')
scD1.addAttribute('meter.unit', '2')
stD1.addAttribute('meter.count', '2')
stD2.addAttribute('meter.count', '3')
s1.addAttribute('n', '1')
music.addChild(body)
body.addChild(mdiv)
mdiv.addChild(score)
score.addChild(sctn)
sctn.addChild(scD1)
scD1.addChild(stG1)
stG1.addChild(stD1)
sctn.addChild(m1)
m1.addChild(l1)
l1.addChild(s1)
s1.addChild(mR1)
sctn.addChild(scD2)
scD2.addChild(stG2)
stG2.addChild(stD2)
sctn.addChild(m2)
m2.addChild(l2)
l2.addChild(s2)
s2.addChild(mR2)
doc = MeiDocument()
doc.setRootElement(music)
self.assertEqual(doc.lookBack(body, 'music'), music)
self.assertEqual(utilities.dur_in_semibreves(mR1), 1)
self.assertEqual(utilities.dur_in_semibreves(mR2), 1.5)