本文整理汇总了Python中pymei.MeiElement.id方法的典型用法代码示例。如果您正苦于以下问题:Python MeiElement.id方法的具体用法?Python MeiElement.id怎么用?Python MeiElement.id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pymei.MeiElement
的用法示例。
在下文中一共展示了MeiElement.id方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_exportvalueandtail
# 需要导入模块: from pymei import MeiElement [as 别名]
# 或者: from pymei.MeiElement import id [as 别名]
def test_exportvalueandtail(self):
doc = MeiDocument()
root = MeiElement("mei")
root.id = "myid"
doc.root = root
note = MeiElement("note")
note.id = "noteid"
note.value = "value"
note.tail = "tail"
root.addChild(note)
expected = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<mei xml:id=\"myid\" xmlns=\"http://www.music-encoding.org/ns/mei\" meiversion=\"2013\">\n\t<note xml:id=\"noteid\">value</note>tail</mei>\n"
ret = documentToText(doc)
self.assertEqual(expected, ret)
示例2: add_source
# 需要导入模块: from pymei import MeiElement [as 别名]
# 或者: from pymei.MeiElement import id [as 别名]
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)
示例3: getMEIContent
# 需要导入模块: from pymei import MeiElement [as 别名]
# 或者: from pymei.MeiElement import id [as 别名]
def getMEIContent(self, dumpVisualization=False):
"""Extract zones and neumes from the source file"""
neumeElements = []
zones = []
for elem in etree.parse(self.xmlFile).xpath('/gamera-database/glyphs/glyph'):
# Get the relevant attributes from the glyph element
startX = int(elem.get('ulx'))
endX = startX + int(elem.get('ncols'))
startY = int(elem.get('uly'))
endY = startY + int(elem.get('nrows'))
curNeumeName = elem.xpath('string(./ids/id/@name)')
# Create the MEI neume element
newNeumeElement = MeiElement('neume')
neumeElements.append(newNeumeElement)
newNeumeElement.id = generate_MEI_ID()
splitName = curNeumeName[curNeumeName.find(".") + 1:]
if(splitName in self.neumeNames):
newNeumeElement.addAttribute(MeiAttribute('name', self.neumeNames[splitName]))
elif len(splitName) < 3:
newNeumeElement.addAttribute(MeiAttribute('name', "Letter " + splitName.upper()))
else:
newNeumeElement.addAttribute(MeiAttribute('name', splitName))
zoneID = generate_MEI_ID()
newNeumeElement.addAttribute(MeiAttribute('facs', zoneID))
zones.append(Zone(zoneID, startX, startY, endX, endY))
zoneElements = []
for zone in self._sortZones(zones, dumpVisualization=dumpVisualization):
newZoneElement = MeiElement('zone')
zoneElements.append(newZoneElement)
newZoneElement.id = zone.id
newZoneElement.addAttribute(MeiAttribute('ulx', str(zone.startX)))
newZoneElement.addAttribute(MeiAttribute('uly', str(zone.startY)))
newZoneElement.addAttribute(MeiAttribute('lrx', str(zone.endX)))
newZoneElement.addAttribute(MeiAttribute('lry', str(zone.endY)))
return zoneElements, neumeElements
示例4: test_segfaultdebug
# 需要导入模块: from pymei import MeiElement [as 别名]
# 或者: from pymei.MeiElement import id [as 别名]
def test_segfaultdebug(self):
variants_list = [
('3', 'VARIANT', '2', 'RISM1560-06'),
('6', 'VARIANT', '5', 'RISM1560-06')
]
res = documentFromFile(os.path.join("test", "testdocs", "DC1317E.mei"))
MEI_doc = res.getMeiDocument()
mei = MeiElement('mei')
# print(mei)
head_score = chain_elems(mei, ['meiHead', 'workDesc', 'work', 'incip', 'score'])
stg = chain_elems(mei, ['music', 'body', 'mdiv', 'score', 'scoreDef', 'staffGrp'])
sd1 = MeiElement('staffDef')
sd2 = MeiElement('staffDef')
sd3 = MeiElement('staffDef')
sd4 = MeiElement('staffDef')
sd5 = MeiElement('staffDef')
sd6 = MeiElement('staffDef')
sd1.addAttribute('n', '1')
sd2.addAttribute('n', '2')
sd3.addAttribute('n', '3')
sd4.addAttribute('n', '4')
sd5.addAttribute('n', '5')
sd6.addAttribute('n', '6')
stg.addChild(sd1)
stg.addChild(sd2)
stg.addChild(sd3)
stg.addChild(sd4)
stg.addChild(sd5)
stg.addChild(sd6)
MEI_tree = MEI_doc.getRootElement()
# MEI_tree2 = mei
# print(MEI_tree)
# print MEI_tree2
scoreDefs = MEI_tree.getDescendantsByName('scoreDef')
# print(scoreDefs)
mainScoreDef = MeiElement(scoreDefs[0])
mainScoreDef.id = "blahblahblah"
meiHead = MEI_tree.getDescendantsByName('meiHead')[0]
head_score = chain_elems(meiHead, ['workDesc', 'work', 'incip', 'score'])
head_score.addChild(mainScoreDef)
for variants_list_item in variants_list:
stDefs = mainScoreDef.getDescendantsByName('staffDef')
for staffDef in stDefs:
if staffDef.hasAttribute('n') and staffDef.getAttribute('n').value == variants_list_item[0]:
print("Removing staffDef n=" + staffDef.getAttribute('n').getValue())
staffDef.parent.removeChild(staffDef)
# head_score.addChild(mainScoreDef)
self.assertEqual(8, len(head_score.getDescendantsByName('staffDef')))
示例5: add_editor
# 需要导入模块: from pymei import MeiElement [as 别名]
# 或者: from pymei.MeiElement import id [as 别名]
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)
示例6: test_documentwritefailure
# 需要导入模块: from pymei import MeiElement [as 别名]
# 或者: from pymei.MeiElement import id [as 别名]
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))
示例7: test_exporttostring
# 需要导入模块: from pymei import MeiElement [as 别名]
# 或者: from pymei.MeiElement import id [as 别名]
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)
示例8: _create_alteration_element
# 需要导入模块: from pymei import MeiElement [as 别名]
# 或者: from pymei.MeiElement import id [as 别名]
def _create_alteration_element(self):
# accid = mod.accid_()
accid = MeiElement("accid")
accid.id = self._idgen()
if self.glyph['form'] is "sharp":
accid.addAttribute("accid", "s")
elif self.glyph['form'] is "flat":
accid.addAttribute("accid", "f")
# zone = self._create_zone_element()
# note.facs = zone.id
return accid
示例9: test_exportnamespace2
# 需要导入模块: from pymei import MeiElement [as 别名]
# 或者: from pymei.MeiElement import id [as 别名]
def test_exportnamespace2(self):
doc = MeiDocument()
root = MeiElement("mei")
root.id = "myid"
doc.root = root
xlink = MeiNamespace("xlink", "http://www.w3.org/1999/xlink")
attr = MeiAttribute(xlink, "title", "my awesome thing")
music = MeiElement("music")
music.id = "musid"
music.addAttribute(attr)
music.value = "mus!"
root.addChild(music)
expected = "<?xml version=\"1.0\"?>\n<mei xmlns=\"http://www.music-encoding.org/ns/mei\" \
xmlns:xlink=\"http://www.w3.org/1999/xlink\" xml:id=\"myid\" meiversion=\"2013\">\n <music \
xml:id=\"musid\" xlink:title=\"my awesome thing\">mus!</music>\n</mei>\n"
ret = XmlExport.meiDocumentToText(doc)
self.assertEqual(expected, ret)
示例10: test_exportcomment
# 需要导入模块: from pymei import MeiElement [as 别名]
# 或者: from pymei.MeiElement import id [as 别名]
def test_exportcomment(self):
doc = MeiDocument()
root = MeiElement("mei")
root.id = "myid"
doc.root = root
comment = MeiElement("_comment")
comment.value = "comment"
comment.tail = "t"
root.addChild(comment)
expected = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<mei xml:id=\"myid\" xmlns=\"http://www.music-encoding.org/ns/mei\" meiversion=\"2013\">\n\t<!--comment-->t</mei>\n"
ret = documentToText(doc)
self.assertEqual(expected, ret)
示例11: test_exportProcessingInstructions
# 需要导入模块: from pymei import MeiElement [as 别名]
# 或者: from pymei.MeiElement import id [as 别名]
def test_exportProcessingInstructions(self):
procinst = XmlInstructions()
xpi1 = XmlProcessingInstruction("xml-model", "href=\"mei-2012.rng\" type=\"application/xml\" schematypens=\"http://purl.oclc.org/dsdl/schematron\"")
xpi2 = XmlProcessingInstruction("xml-stylesheet", "href=\"mei-2012.rng\" type=\"application/xml\" schematypens=\"http://purl.oclc.org/dsdl/schematron\"")
procinst.extend([xpi1, xpi2])
doc = MeiDocument()
root = MeiElement("mei")
root.id = "myid"
doc.root = root
ret = XmlExport.meiDocumentToText(doc, procinst)
expected = "<?xml version=\"1.0\"?>\n<?xml-model href=\"mei-2012.rng\" type=\"application/xml\" \
schematypens=\"http://purl.oclc.org/dsdl/schematron\"?>\n<?xml-stylesheet href=\"mei-2012.rng\" type=\"application/xml\" \
schematypens=\"http://purl.oclc.org/dsdl/schematron\"?>\n<mei xmlns=\"http://www.music-encoding.org/ns/mei\" \
xml:id=\"myid\" meiversion=\"2013\"/>\n"
self.assertEqual(expected, ret)
示例12: _initMEI
# 需要导入模块: from pymei import MeiElement [as 别名]
# 或者: from pymei.MeiElement import id [as 别名]
def _initMEI(self):
"""Initialize a new MEI document
Sets the attributes meiDoc, surface, and initLayer
"""
self.meiDoc = MeiDocument()
root = MeiElement("mei")
root.id = generate_MEI_ID()
self.meiDoc.root = root
#needs meiHead here
meiHead = MeiElement('meiHead')
fileDesc = MeiElement('fileDesc')
titleStmt = MeiElement('titleStmt')
title = MeiElement('title')
pubStmt = MeiElement('pubStmt')
date = MeiElement('date')
encodingDesc = MeiElement('encodingDesc')
projectDesc = MeiElement('projectDesc')
p = MeiElement('p')
music = MeiElement('music')
facsimile = MeiElement('facsimile')
self.surface = MeiElement('surface')
# Label the surface with the name of the input file, which could help
# identify the original image
label = os.path.basename(os.path.splitext(self.xmlFile)[0])
self.surface.addAttribute(MeiAttribute('label', label))
#systems get added to page
#neumes get added to systems
body = MeiElement('body')
mdiv = MeiElement('mdiv')
pages = MeiElement('pages')
page = MeiElement('page')
page.id = generate_MEI_ID()
initSystem = MeiElement('system')
initSystem.id = generate_MEI_ID()
initStaff = MeiElement('staff')
initStaff.id = generate_MEI_ID()
self.initLayer = MeiElement('layer')
self.initLayer.id = generate_MEI_ID()
root.addChild(meiHead)
meiHead.addChild(fileDesc)
fileDesc.addChild(titleStmt)
titleStmt.addChild(title)
fileDesc.addChild(pubStmt)
pubStmt.addChild(date)
meiHead.addChild(encodingDesc)
encodingDesc.addChild(projectDesc)
projectDesc.addChild(p)
root.addChild(music)
music.addChild(facsimile)
facsimile.addChild(self.surface)
music.addChild(body)
body.addChild(mdiv)
mdiv.addChild(pages)
pages.addChild(page)
page.addChild(initSystem)
initSystem.addChild(initStaff)
initStaff.addChild(self.initLayer)
示例13: add_editor
# 需要导入模块: from pymei import MeiElement [as 别名]
# 或者: from pymei.MeiElement import id [as 别名]
def add_editor(titleStmt, ali):
existing = titleStmt.getDocument().getElementById(adi[3])
if not existing:
editor = MeiElement('editor')
editor.id = ali[3]
titleStmt.addChild(editor)