当前位置: 首页>>代码示例>>Python>>正文


Python MeiElement.removeChild方法代码示例

本文整理汇总了Python中pymei.MeiElement.removeChild方法的典型用法代码示例。如果您正苦于以下问题:Python MeiElement.removeChild方法的具体用法?Python MeiElement.removeChild怎么用?Python MeiElement.removeChild使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pymei.MeiElement的用法示例。


在下文中一共展示了MeiElement.removeChild方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_removechild

# 需要导入模块: from pymei import MeiElement [as 别名]
# 或者: from pymei.MeiElement import removeChild [as 别名]
 def test_removechild(self):
     p = MeiElement("layer")
     el1 = MeiElement("note")
     el2 = MeiElement("note")
     
     p.addChild(el1)
     p.addChild(el2)
     
     self.assertEqual(2, len(p.children))
     p.removeChild(el1)
     self.assertEqual(1, len(p.children))
开发者ID:lpugin,项目名称:libmei,代码行数:13,代码来源:meielement_test.py

示例2: test_flattenedtree

# 需要导入模块: from pymei import MeiElement [as 别名]
# 或者: from pymei.MeiElement import removeChild [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])
开发者ID:lpugin,项目名称:libmei,代码行数:53,代码来源:meidocument_test.py

示例3: test_elementbyid

# 需要导入模块: from pymei import MeiElement [as 别名]
# 或者: from pymei.MeiElement import removeChild [as 别名]
    def test_elementbyid(self):
        mei = MeiElement("mei")
        mus = MeiElement("music")
        body = MeiElement("body")
        staff = MeiElement("staff")
        staff2 = MeiElement("staff")
        n1 = MeiElement("note")
        wantedId = n1.id
        n2 = MeiElement("note")
        n3 = MeiElement("note")
        n4 = MeiElement("note")

        mei.addChild(mus)
        mus.addChild(body)
        body.addChild(staff)
        body.addChild(staff2)
        staff.addChild(n1)
        staff.addChild(n2)
        staff.addChild(n3)
        staff2.addChild(n4)

        doc = MeiDocument()
        self.assertEqual(None, doc.getElementById(wantedId))

        doc.root = mei

        self.assertEqual(n1, doc.getElementById(wantedId))

        self.assertEqual(None, doc.getElementById("unknownID"))

        n5 = MeiElement("note")
        newid = n5.id
        staff2.addChild(n5)

        self.assertEqual(n5, doc.getElementById(newid))
        staff2.removeChild(n5)
        self.assertEqual(None, doc.getElementById(newid))
开发者ID:lpugin,项目名称:libmei,代码行数:39,代码来源:meidocument_test.py

示例4: AomrMeiOutput

# 需要导入模块: from pymei import MeiElement [as 别名]
# 或者: from pymei.MeiElement import removeChild [as 别名]

#.........这里部分代码省略.........
        self.layer.addAttribute("n", "1")

        self.staffel = self._create_staff_element()
        self.staffel.addAttribute("n", str(self.staff_num))   # trouble
        self.section.addChild(self.staffel)
        self.staffel.addChild(self.layer)

        for sysnum in sorted(self._recognition_results.keys()):
            syst = self._recognition_results[sysnum]
            lg.debug("sysnum:{0}".format(sysnum))
            self.system = syst
            self.systembreak = self._parse_system(sysnum, syst)
            # z = mod.zone_()
            z = MeiElement("zone")
            # z.id = self._idgen()
            # z.attributes = {'ulx': self.system['coord'][0], 'uly': self.system['coord'][1], \
            #                     'lrx': self.system['coord'][2], 'lry': self.system['coord'][3]}
            z.addAttribute("ulx", str(self.system['coord'][0]))
            z.addAttribute("uly", str(self.system['coord'][1]))
            z.addAttribute("lrx", str(self.system['coord'][2]))
            z.addAttribute("lry", str(self.system['coord'][3]))
            self.surface.addChild(z)
            # self.system.facs = z.id
            s = self._create_system_element()
            s.facs = z.id
            s.addAttribute("facs", s.facs)
            self.pg.addChild(s)
            self.systembreak.addAttribute("systemref", s.id)

        self.mei.addChild(self.music)

        # if not self.staffel.descendants_by_name('neume'):
        if not self.staffel.getDescendantsByName("neume"):
            self.staffgrp.removeChild(self.staffdef)
            self.section.removeChild(self.staffel)

        # self.md = MeiDocument.MeiDocument()
        # self.md.addelement(self.mei)
        self.md = MeiDocument()
        self.md.setRootElement(self.mei)
        print XmlExport.meiElementToText(self.md.getElementById(self.graphic.getId()))

    def _parse_system(self, sysnum, syst):
        sysbrk = self._create_sb_element()
        # sysbrk.attributes = {"n": sysnum + 1}
        sysnum = int(sysnum)
        sysbrk.addAttribute("n", "%d" % (sysnum+1))
        self.layer.addChild(sysbrk)
        # staffel = self._create_staff_element()
        # staffel.addAttribute("n", stfnum)

        for c in self.system['content']:
            # parse the glyphs per staff.
            self.glyph = c
            if c['type'] == 'neume':
                if not self.glyph['form']:
                    lg.debug("Skipping glyph: {0}".format(self.glyph))
                    continue
                if self.glyph['form'][0] not in self.NEUME_NOTES.keys():
                    continue
                else:
                    self.layer.addChild(self._create_neume_element())

            elif c['type'] == 'clef':
                self.layer.addChild(self._create_clef_element())
            elif c['type'] == 'division':
开发者ID:lexpar,项目名称:Rodan,代码行数:70,代码来源:AomrMeiOutput.py


注:本文中的pymei.MeiElement.removeChild方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。