本文整理汇总了Python中pymei.MeiElement.getAttribute方法的典型用法代码示例。如果您正苦于以下问题:Python MeiElement.getAttribute方法的具体用法?Python MeiElement.getAttribute怎么用?Python MeiElement.getAttribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pymei.MeiElement
的用法示例。
在下文中一共展示了MeiElement.getAttribute方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_changeattr
# 需要导入模块: from pymei import MeiElement [as 别名]
# 或者: from pymei.MeiElement import getAttribute [as 别名]
def test_changeattr(self):
el = MeiElement("mei")
el.addAttribute("meiversion", "2011-05")
self.assertTrue(el.hasAttribute("meiversion"))
self.assertEqual("2011-05", el.getAttribute("meiversion").value)
at = el.getAttribute("meiversion")
at.value = "2012"
self.assertEqual("2012", el.getAttribute("meiversion").value)
示例2: test_copy_constructor
# 需要导入模块: from pymei import MeiElement [as 别名]
# 或者: from pymei.MeiElement import getAttribute [as 别名]
def test_copy_constructor(self):
note = MeiElement("note")
note2 = note
# check that regular pointer referencing in Python works on MeiElements
self.assertEqual(note2, note)
note.addAttribute('pname', 'c')
note3 = MeiElement(note)
# check that they have been properly copied
self.assertNotEqual(note3, note)
# check that the attributes copied are not the same
self.assertNotEqual(note3.getAttribute('pname'), note.getAttribute('pname'))
# check that the attribute values copied are the same
self.assertEqual(note3.getAttribute('pname').value, note.getAttribute('pname').value)
示例3: test_changechildvalue
# 需要导入模块: from pymei import MeiElement [as 别名]
# 或者: from pymei.MeiElement import getAttribute [as 别名]
def test_changechildvalue(self):
""" Check if we can replace an attribute value in-place"""
p = MeiElement("layer")
el1 = MeiElement("note")
el2 = MeiElement("note")
p.addChild(el1)
p.addChild(el2)
el1.addAttribute("pname", "c")
self.assertEqual("c", p.children[0].getAttribute("pname").value)
el1.getAttribute("pname").value = "d"
self.assertEqual("d", p.children[0].getAttribute("pname").value)