• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python pymei.MeiElement类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: add_source

 def add_source(sourceDesc, adi):
     existing = sourceDesc.getDocument().getElementById(adi[3])
     if not existing:
         source = MeiElement('source')
         source.id = adi[3]
         source.addAttribute('type', adi[1])
         sourceDesc.addChild(source)
开发者ID:DuChemin,项目名称:MEIMassaging,代码行数:7,代码来源:sources.py


示例2: test_getattributeval

    def test_getattributeval(self):
        measure = MeiElement("measure")
        staff = MeiElement("staff")
        measure.addAttribute("n", "2")

        self.assertEqual(utilities.get_attribute_val(measure, "n"), "2")
        self.assertEqual(utilities.get_attribute_val(staff, "n", "1"), "1")
开发者ID:RichardFreedman,项目名称:MEIMassaging,代码行数:7,代码来源:unit_test.py


示例3: test_getattributeval

 def test_getattributeval(self):
     measure = MeiElement('measure')
     staff = MeiElement('staff')
     measure.addAttribute('n', '2')
     
     self.assertEqual(utilities.get_attribute_val(measure, 'n'), '2')
     self.assertEqual(utilities.get_attribute_val(staff, 'n', '1'), '1')
开发者ID:zolaemil,项目名称:MEIMassaging,代码行数:7,代码来源:unit_test.py


示例4: test_object_equality

    def test_object_equality(self):
        el1 = MeiElement("note")
        el2 = MeiElement("accid")

        el1.addChild(el2)

        self.assertEqual(el1, el2.parent)
开发者ID:lpugin,项目名称:libmei,代码行数:7,代码来源:meielement_test.py


示例5: make_invisible_space

def make_invisible_space(MEI_tree, handle_mRest=False):
    """Turns all invisible notes, rests and mRests into
    <space> elements.
    """

    all_note_rest = MEI_tree.getDescendantsByName('note rest')
    all_mRest = MEI_tree.getDescendantsByName('mRest')

    # Replace notes and rests with spaces
    for item in all_note_rest:
        try:
            if item.getAttribute('visible').getValue() == 'false':
                space = MeiElement('space')
                attributes = item.getAttributes()
                for attr in attributes:
                    # Don't add octave or pitch attributes to space
                    if attr.getName() not in ['oct', 'pname']:
                        space.addAttribute(attr)
                # If mRest, calculate duration here?
                parent = item.getParent()
                parent.addChildBefore(item, space)
                parent.removeChild(item)
        except:  # doesn't have attribute `visible`
            pass
    # Replace mRests with nothing -- just remove them
    # Not currently supported by MEItoVexFlow
    if handle_mRest:
        for item in all_mRest:
            try:
                if item.getAttribute('visible').getValue() == 'false':
                    item.getParent().removeChild(item)
            except:  # doesn't have attribute `visible`
                pass
开发者ID:DuChemin,项目名称:MEIMassaging,代码行数:33,代码来源:invisible.py


示例6: _create_staff_group

    def _create_staff_group(self, sg_list, staff_grp, n):
        '''
        Recursively create the staff group element from the parsed
        user input of the staff groupings
        '''
        if not sg_list:
            return staff_grp, n
        else:
            if type(sg_list[0]) is list:
                new_staff_grp, n = self._create_staff_group(sg_list[0], MeiElement('staffGrp'), n)
                staff_grp.addChild(new_staff_grp)
            else:
                # check for barthrough character
                if sg_list[0][-1] == '|':
                    # the barlines go through all the staves in the staff group
                    staff_grp.addAttribute('barthru', 'true')
                    # remove the barthrough character, should now only be an integer
                    sg_list[0] = sg_list[0][:-1]

                n_staff_defs = int(sg_list[0])
                # get current staffDef number
                for i in range(n_staff_defs):
                    staff_def = MeiElement('staffDef')
                    staff_def.addAttribute('n', str(n + i + 1))
                    staff_grp.addChild(staff_def)
                n += n_staff_defs

            return self._create_staff_group(sg_list[1:], staff_grp, n)
开发者ID:lexpar,项目名称:Rodan,代码行数:28,代码来源:barfinder.py


示例7: post

    def post(self, file):
        '''
        Add a dot ornament to a given element.
        '''

        neumeid = str(self.get_argument("id", ""))
        dot_form = str(self.get_argument("dotform", ""))

        # Bounding box
        ulx = str(self.get_argument("ulx", None))
        uly = str(self.get_argument("uly", None))
        lrx = str(self.get_argument("lrx", None))
        lry = str(self.get_argument("lry", None))

        mei_directory = os.path.abspath(conf.MEI_DIRECTORY)
        fname = os.path.join(mei_directory, file)
        self.mei = XmlImport.read(fname)

        punctum = self.mei.getElementById(neumeid)
        # check that a punctum element was provided
        if punctum.getName() == "neume" and punctum.getAttribute("name").getValue() == "punctum":
            note = punctum.getDescendantsByName("note")
            if len(note):
                # if a dot does not already exist on the note
                if len(note[0].getChildrenByName("dot")) == 0:
                    dot = MeiElement("dot")
                    dot.addAttribute("form", dot_form)
                    note[0].addChild(dot)

            self.update_or_add_zone(punctum, ulx, uly, lrx, lry)

        XmlExport.write(self.mei, fname)

        self.set_status(200)
开发者ID:sequoiar,项目名称:Neon.js,代码行数:34,代码来源:api.py


示例8: _create_graphic_element

 def _create_graphic_element(self, imgfile):
     graphic = MeiElement("graphic")
     # xlink = MeiNamespace("xlink", "http://www.w3.org/1999/xlink")
     # ns_attr = MeiAttribute("xlink")
     graphic.addAttribute("xmlns:xlink", "http://www.w3.org/1999/xlink")
     graphic.addAttribute("xlink:href", imgfile)
     return graphic
开发者ID:lexpar,项目名称:Rodan,代码行数:7,代码来源:AomrMeiOutput.py


示例9: parse_token

        def parse_token(token):
            def parse_attrs(token):
                def parse_attrs_str(attrs_str):
                    res = []
                    attr_pairs = attrs_str.split(",")
                    for attr_pair in attr_pairs:
                        if attr_pair == '':
                            continue
                        name_val = attr_pair.split("=")
                        if len(name_val) > 1:
                            attr = MeiAttribute(name_val[0], name_val[1])
                            res.append(attr)
                        else:
                            logging.warning("get_descendants(): invalid attribute specifier in expression: " + expr)
                    return res
                m = re.search("\[(.*)\]", token)
                attrs_str = ""
                if m is not None:
                    attrs_str = m.group(1)
                return parse_attrs_str(attrs_str)

            m = re.search("^([^\[]+)", token)
            elem = MeiElement(m.group(1))
            attrs = parse_attrs(token)
            for attr in attrs:
                elem.addAttribute(attr)
            return elem
开发者ID:DuChemin,项目名称:MEIMassaging,代码行数:27,代码来源:utilities.py


示例10: create_zone

    def create_zone(self, ulx, uly, lrx, lry):
        zone = MeiElement("zone")
        zone.addAttribute("ulx", ulx)
        zone.addAttribute("uly", uly)
        zone.addAttribute("lrx", lrx)
        zone.addAttribute("lry", lry)

        return zone
开发者ID:sequoiar,项目名称:Neon.js,代码行数:8,代码来源:api.py


示例11: test_documentwritefailure

 def test_documentwritefailure(self):
     doc = MeiDocument()
     root = MeiElement("mei")
     root.id = "myid"
     doc.root = root
     with self.assertRaises(FileWriteFailureException) as cm:
         ret = XmlExport.meiDocumentToFile(doc, "C:/StupidPath")
     self.assertTrue(isinstance(cm.exception, FileWriteFailureException))
开发者ID:lpugin,项目名称:libmei,代码行数:8,代码来源:xmlexport_test.py


示例12: add_editor

 def add_editor(titleStmt, ali):
     existing = titleStmt.getDocument().getElementById(adi[3])
     if not existing:
         editor = MeiElement('editor')
         editor.id = ali[3]
         # Using 'replace' simply to have more natural name for a person
         editor.addAttribute('type', adi[1].replace('ction', 'ctor'))
         titleStmt.addChild(editor)
开发者ID:DuChemin,项目名称:MEIMassaging,代码行数:8,代码来源:sources.py


示例13: get_new_zone

    def get_new_zone(self, ulx, uly, lrx, lry):
        zone = MeiElement("zone")
        zone.addAttribute("ulx", str(ulx))
        zone.addAttribute("uly", str(uly))
        zone.addAttribute("lrx", str(lrx))
        zone.addAttribute("lry", str(lry))

        return zone
开发者ID:sequoiar,项目名称:Neon.js,代码行数:8,代码来源:api.py


示例14: test_exporttostring

    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)
开发者ID:AFFogarty,项目名称:libmei,代码行数:9,代码来源:xmlexport_test.py


示例15: test_setdocument

    def test_setdocument(self):
        m = MeiElement("mei")
        doc = MeiDocument()

        with self.assertRaises(DocumentRootNotSetException) as cm:
            m.setDocument(doc)
        self.assertTrue(isinstance(cm.exception, DocumentRootNotSetException))
        doc.setRootElement(m)

        self.assertEqual(doc.root, m)
开发者ID:lpugin,项目名称:libmei,代码行数:10,代码来源:meielement_test.py


示例16: test_parent

    def test_parent(self):
        el1 = MeiElement("mei")
        el2 = MeiElement("meiHead")
        el3 = MeiElement("music")

        el2.parent = el1
        el3.parent = el1

        self.assertEqual("mei", el2.parent.name)
        self.assertEqual("mei", el3.parent.name)
开发者ID:lpugin,项目名称:libmei,代码行数:10,代码来源:meielement_test.py


示例17: _create_staff

    def _create_staff(self, n, zone):
        '''
        Create a staff element, and attach a zone reference to it
        '''

        staff = MeiElement('staff')
        staff.addAttribute('n', str(n))
        staff.addAttribute('facs', '#'+zone.getId())

        return staff
开发者ID:DDMAL,项目名称:barlineFinder,代码行数:10,代码来源:meicreate.py


示例18: create_new_division

    def create_new_division(self, type):
        '''
        Make a new division and return the MEI element.
        Attach the facs data to the division element
        '''

        division = MeiElement("division")
        division.addAttribute("form", type)

        return division
开发者ID:sequoiar,项目名称:Neon.js,代码行数:10,代码来源:api.py


示例19: wrap_whole_measure

def wrap_whole_measure(staff, ALT_TYPE):
    """Enclose the entire contents of a staff in a measure
    inside the <app> element. Will be done if variants overlap
    in illegal ways.
    """
    rich_wrapper_name = 'app'
    rich_default_name = 'lem'
    if ALT_TYPE == EMENDATION:
        rich_wrapper_name = 'choice'
        rich_default_name = 'sic'
    old_layers = staff.getChildrenByName('layer')
    notelist = []
    if len(old_layers) > 0:
        old_layer = staff.getChildrenByName('layer')[0]
        notelist.extend(get_descendants(old_layer, 'note rest space mRest'))
        staff.removeChild(old_layer)
    new_layer = MeiElement('layer')
    rich_wrapper = MeiElement(rich_wrapper_name)
    rich_default_elem = MeiElement(rich_default_name)
    for note in notelist:
        rich_default_elem.addChild(note)
    rich_wrapper.addChild(rich_default_elem)
    new_layer.addChild(rich_wrapper)
    staff.addChild(new_layer)
    return rich_wrapper
开发者ID:DuChemin,项目名称:MEIMassaging,代码行数:25,代码来源:alt.py


示例20: test_documentpointers

    def test_documentpointers(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")

        self.assertEqual(None, mei.document)
        mei.addChild(mus)
        self.assertEqual(None, mus.document)

        doc = MeiDocument()
        mus.addChild(body)
        doc.root = mei

        self.assertEqual(doc, mei.document)
        self.assertEqual(doc, mus.document)
        self.assertEqual(doc, body.document)

        self.assertEqual(None, staff.document)
        body.addChild(staff)
        self.assertEqual(doc, staff.document)
开发者ID:Breakend,项目名称:libmei,代码行数:25,代码来源:meidocument_test.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python pymei.XmlImport类代码示例发布时间:2022-05-27
下一篇:
Python pymei.MeiDocument类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap