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


Python MeiElement.setId方法代码示例

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


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

示例1: processContigRange

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

#.........这里部分代码省略.........
                                                # must start before and end after
                                                # latest selected element with duration

                                                endid = (
                                                    event.getAttribute("endid")
                                                    .getValue()
                                                    .replace("#", "")
                                                )
                                                target2 = self.doc.getElementById(endid)
                                                if marked_as_selected.get(target2):
                                                    marked_as_selected.add(event)
                                                    marked_for_removal.discard(event)
                                                else:
                                                    pos2 = target2.getPositionInDocument()
                                                    for i in reversed(marked_as_selected.getElements()):
                                                        if i.hasAttribute("dur"):
                                                            if pos2 > i.getPositionInDocument():
                                                                marked_as_selected.add(event)
                                                                marked_for_removal.discard(event)
                                                            else:
                                                                marked_for_removal.add(event)
                                                            break

                    # Remove elements marked for removal
                    for el in marked_for_removal:
                        el.getParent().removeChild(el)

                    # Replace elements marked as spaces with actual spaces,
                    # unless completion = nospace, then remove the elements.
                    for el in marked_as_space:
                        parent = el.getParent()
                        if "nospace" not in self.ema_exp.completenessOptions:
                            space = MeiElement("space")
                            space.setId(el.id)
                            space.addAttribute(el.getAttribute("dur"))
                            if el.getAttribute("dots"):
                                space.addAttribute(el.getAttribute("dots"))
                            elif el.getChildrenByName("dot"):
                                dots = str(len(el.getChildrenByName("dot")))
                                space.addAttribute(MeiAttribute("dots", dots))
                            parent.addChildBefore(el, space)
                        el.getParent().removeChild(el)

                else:
                    # Remove this staff and its attached events
                    staff.getParent().removeChild(staff)

                    for el in list(events):
                        if self._isInStaff(el, s_no):
                            el.getParent().removeChild(el)

            # At the first measure, also add relevant multi-measure spanners
            # for each selected staff
            if is_first_m:
                for evs in spanners.values():
                    for event_id in evs:
                        ev = self.doc.getElementById(event_id)
                        # Spanners starting outside of beat ranges
                        # may be already gone
                        if ev:
                            # Determine staff of event for id changes
                            for ema_s in ema_m.staves:
                                staff_no = self._isInStaff(ev, ema_s.number)

                            if staff_no and staff_no in s_nos:
                                # If the event is attached to more than one staff, just
开发者ID:edsu,项目名称:ema,代码行数:70,代码来源:meislicer.py


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