Skip to content

Commit 3aecbd5

Browse files
authored
Merge pull request #189 from frescobaldi/fixtests
Fix tests
2 parents 11609c4 + 9af97c7 commit 3aecbd5

File tree

5 files changed

+569
-8
lines changed

5 files changed

+569
-8
lines changed

ly/musicxml/create_musicxml.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ def add_grace(self, slash):
391391
etree.SubElement(self.current_note, "grace")
392392

393393
def add_notations(self):
394-
if not self.current_notation:
394+
if self.current_notation is None:
395395
self.current_notation = etree.SubElement(self.current_note, "notations")
396396

397397
def add_tied(self, tie_type):
@@ -458,15 +458,15 @@ def add_named_notation(self, notate):
458458

459459
def add_articulations(self):
460460
"""Common function for creating all types of articulations. """
461-
if not self.current_artic:
461+
if self.current_artic is None:
462462
self.current_artic = etree.SubElement(self.current_notation, "articulations")
463463

464464
def add_named_artic(self, artic):
465465
"""Add articulation with specified name. """
466466
etree.SubElement(self.current_artic, artic)
467467

468468
def add_ornaments(self):
469-
if not self.current_ornament:
469+
if self.current_ornament is None:
470470
self.add_notations()
471471
self.current_ornament = etree.SubElement(self.current_notation, "ornaments")
472472

@@ -497,7 +497,7 @@ def add_gliss(self, linetype, endtype, nr):
497497
etree.SubElement(self.current_notation, "glissando", nodedict)
498498

499499
def add_technical(self):
500-
if not self.current_tech:
500+
if self.current_tech is None:
501501
self.add_notations()
502502
self.current_tech = etree.SubElement(self.current_notation, "technical")
503503

@@ -624,15 +624,15 @@ def add_octave_shift(self, plac, octdir, size):
624624

625625
def add_dirwords(self, words):
626626
"""Add words in direction, e. g. a tempo mark."""
627-
if self.current_bar.find('direction') == None:
627+
if self.current_bar.find('direction') is None:
628628
self.add_direction()
629629
dirtypenode = etree.SubElement(self.direction, "direction-type")
630630
wordsnode = etree.SubElement(dirtypenode, "words")
631631
wordsnode.text = words
632632

633633
def add_mark(self, mark):
634634
"""Add rehearsal mark in direction"""
635-
if self.current_bar.find('direction') == None:
635+
if self.current_bar.find('direction') is None:
636636
self.add_direction()
637637
dirtypenode = etree.SubElement(self.direction, "direction-type")
638638
rehearsalnode = etree.SubElement(dirtypenode, "rehearsal")

ly/musicxml/lymus2musxml.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -426,11 +426,11 @@ def Slur(self, slur):
426426

427427
def PhrasingSlur(self, phrslur):
428428
r"""A \( or \)."""
429-
if phrslur.token == '\(':
429+
if phrslur.token == r'\(':
430430
self.slurcount += 1
431431
self.phrslurnr = self.slurcount
432432
self.mediator.set_slur(self.phrslurnr, "start", phrasing=True)
433-
elif phrslur.token == '\)':
433+
elif phrslur.token == r'\)':
434434
self.mediator.set_slur(self.phrslurnr, "stop", phrasing=True)
435435
self.slurcount -= 1
436436

tests/musicxml.xsd

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xlink="http://www.w3.org/1999/xlink" elementFormDefault="qualified" attributeFormDefault="unqualified">
3+
<xs:import namespace="http://www.w3.org/XML/1998/namespace"
4+
schemaLocation="xml.xsd"/>
5+
<xs:import namespace="http://www.w3.org/1999/xlink"
6+
schemaLocation="xlink.xsd"/>
37
<xs:annotation>
48
<xs:documentation>MusicXML™ W3C XML schema (XSD)
59

tests/xlink.xsd

Lines changed: 270 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,270 @@
1+
<?xml version='1.0' encoding='UTF-8'?>
2+
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.w3.org/1999/xlink" xmlns:xlink="http://www.w3.org/1999/xlink">
3+
4+
<xs:annotation>
5+
<xs:documentation>This schema document provides attribute declarations and
6+
attribute group, complex type and simple type definitions which can be used in
7+
the construction of user schemas to define the structure of particular linking
8+
constructs, e.g.
9+
<![CDATA[
10+
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
11+
xmlns:xl="http://www.w3.org/1999/xlink">
12+
13+
<xs:import namespace="http://www.w3.org/1999/xlink"
14+
location="http://www.w3.org/1999/xlink.xsd">
15+
16+
<xs:element name="mySimple">
17+
<xs:complexType>
18+
...
19+
<xs:attributeGroup ref="xl:simpleAttrs"/>
20+
...
21+
</xs:complexType>
22+
</xs:element>
23+
...
24+
</xs:schema>]]></xs:documentation>
25+
</xs:annotation>
26+
27+
<xs:import namespace="http://www.w3.org/XML/1998/namespace" schemaLocation="http://www.w3.org/2001/xml.xsd"/>
28+
29+
<xs:attribute name="type" type="xlink:typeType"/>
30+
31+
<xs:simpleType name="typeType">
32+
<xs:restriction base="xs:token">
33+
<xs:enumeration value="simple"/>
34+
<xs:enumeration value="extended"/>
35+
<xs:enumeration value="title"/>
36+
<xs:enumeration value="resource"/>
37+
<xs:enumeration value="locator"/>
38+
<xs:enumeration value="arc"/>
39+
</xs:restriction>
40+
</xs:simpleType>
41+
42+
<xs:attribute name="href" type="xlink:hrefType"/>
43+
44+
<xs:simpleType name="hrefType">
45+
<xs:restriction base="xs:anyURI"/>
46+
</xs:simpleType>
47+
48+
<xs:attribute name="role" type="xlink:roleType"/>
49+
50+
<xs:simpleType name="roleType">
51+
<xs:restriction base="xs:anyURI">
52+
<xs:minLength value="1"/>
53+
</xs:restriction>
54+
</xs:simpleType>
55+
56+
<xs:attribute name="arcrole" type="xlink:arcroleType"/>
57+
58+
<xs:simpleType name="arcroleType">
59+
<xs:restriction base="xs:anyURI">
60+
<xs:minLength value="1"/>
61+
</xs:restriction>
62+
</xs:simpleType>
63+
64+
<xs:attribute name="title" type="xlink:titleAttrType"/>
65+
66+
<xs:simpleType name="titleAttrType">
67+
<xs:restriction base="xs:string"/>
68+
</xs:simpleType>
69+
70+
<xs:attribute name="show" type="xlink:showType"/>
71+
72+
<xs:simpleType name="showType">
73+
<xs:restriction base="xs:token">
74+
<xs:enumeration value="new"/>
75+
<xs:enumeration value="replace"/>
76+
<xs:enumeration value="embed"/>
77+
<xs:enumeration value="other"/>
78+
<xs:enumeration value="none"/>
79+
</xs:restriction>
80+
</xs:simpleType>
81+
82+
<xs:attribute name="actuate" type="xlink:actuateType"/>
83+
84+
<xs:simpleType name="actuateType">
85+
<xs:restriction base="xs:token">
86+
<xs:enumeration value="onLoad"/>
87+
<xs:enumeration value="onRequest"/>
88+
<xs:enumeration value="other"/>
89+
<xs:enumeration value="none"/>
90+
</xs:restriction>
91+
</xs:simpleType>
92+
93+
<xs:attribute name="label" type="xlink:labelType"/>
94+
95+
<xs:simpleType name="labelType">
96+
<xs:restriction base="xs:NCName"/>
97+
</xs:simpleType>
98+
99+
<xs:attribute name="from" type="xlink:fromType"/>
100+
101+
<xs:simpleType name="fromType">
102+
<xs:restriction base="xs:NCName"/>
103+
</xs:simpleType>
104+
105+
<xs:attribute name="to" type="xlink:toType"/>
106+
107+
<xs:simpleType name="toType">
108+
<xs:restriction base="xs:NCName"/>
109+
</xs:simpleType>
110+
111+
<xs:attributeGroup name="simpleAttrs">
112+
<xs:attribute ref="xlink:type" fixed="simple"/>
113+
<xs:attribute ref="xlink:href"/>
114+
<xs:attribute ref="xlink:role"/>
115+
<xs:attribute ref="xlink:arcrole"/>
116+
<xs:attribute ref="xlink:title"/>
117+
<xs:attribute ref="xlink:show"/>
118+
<xs:attribute ref="xlink:actuate"/>
119+
</xs:attributeGroup>
120+
121+
<xs:group name="simpleModel">
122+
<xs:sequence>
123+
<xs:any processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
124+
</xs:sequence>
125+
</xs:group>
126+
127+
<xs:complexType mixed="true" name="simple">
128+
<xs:annotation>
129+
<xs:documentation>
130+
Intended for use as the type of user-declared elements to make them
131+
simple links.
132+
</xs:documentation>
133+
</xs:annotation>
134+
<xs:group ref="xlink:simpleModel"/>
135+
<xs:attributeGroup ref="xlink:simpleAttrs"/>
136+
</xs:complexType>
137+
138+
<xs:attributeGroup name="extendedAttrs">
139+
<xs:attribute ref="xlink:type" fixed="extended" use="required"/>
140+
<xs:attribute ref="xlink:role"/>
141+
<xs:attribute ref="xlink:title"/>
142+
</xs:attributeGroup>
143+
144+
<xs:group name="extendedModel">
145+
<xs:choice>
146+
<xs:element ref="xlink:title"/>
147+
<xs:element ref="xlink:resource"/>
148+
<xs:element ref="xlink:locator"/>
149+
<xs:element ref="xlink:arc"/>
150+
</xs:choice>
151+
</xs:group>
152+
153+
<xs:complexType name="extended">
154+
<xs:annotation>
155+
<xs:documentation>
156+
Intended for use as the type of user-declared elements to make them
157+
extended links.
158+
Note that the elements referenced in the content model are all abstract.
159+
The intention is that by simply declaring elements with these as their
160+
substitutionGroup, all the right things will happen.
161+
</xs:documentation>
162+
</xs:annotation>
163+
<xs:group ref="xlink:extendedModel" minOccurs="0" maxOccurs="unbounded"/>
164+
<xs:attributeGroup ref="xlink:extendedAttrs"/>
165+
</xs:complexType>
166+
167+
<xs:element name="title" type="xlink:titleEltType" abstract="true"/>
168+
169+
<xs:attributeGroup name="titleAttrs">
170+
<xs:attribute ref="xlink:type" fixed="title" use="required"/>
171+
<xs:attribute ref="xml:lang">
172+
<xs:annotation>
173+
<xs:documentation>
174+
xml:lang is not required, but provides much of the
175+
motivation for title elements in addition to attributes, and so
176+
is provided here for convenience.
177+
</xs:documentation>
178+
</xs:annotation>
179+
</xs:attribute>
180+
</xs:attributeGroup>
181+
182+
<xs:group name="titleModel">
183+
<xs:sequence>
184+
<xs:any processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
185+
</xs:sequence>
186+
</xs:group>
187+
188+
<xs:complexType mixed="true" name="titleEltType">
189+
<xs:group ref="xlink:titleModel"/>
190+
<xs:attributeGroup ref="xlink:titleAttrs"/>
191+
</xs:complexType>
192+
193+
<xs:element name="resource" type="xlink:resourceType" abstract="true"/>
194+
195+
<xs:attributeGroup name="resourceAttrs">
196+
<xs:attribute ref="xlink:type" fixed="resource" use="required"/>
197+
<xs:attribute ref="xlink:role"/>
198+
<xs:attribute ref="xlink:title"/>
199+
<xs:attribute ref="xlink:label"/>
200+
</xs:attributeGroup>
201+
202+
<xs:group name="resourceModel">
203+
<xs:sequence>
204+
<xs:any processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
205+
</xs:sequence>
206+
</xs:group>
207+
208+
<xs:complexType mixed="true" name="resourceType">
209+
<xs:group ref="xlink:resourceModel"/>
210+
<xs:attributeGroup ref="xlink:resourceAttrs"/>
211+
</xs:complexType>
212+
213+
<xs:element name="locator" type="xlink:locatorType" abstract="true"/>
214+
215+
<xs:attributeGroup name="locatorAttrs">
216+
<xs:attribute ref="xlink:type" fixed="locator" use="required"/>
217+
<xs:attribute ref="xlink:href" use="required"/>
218+
<xs:attribute ref="xlink:role"/>
219+
<xs:attribute ref="xlink:title"/>
220+
<xs:attribute ref="xlink:label">
221+
<xs:annotation>
222+
<xs:documentation>
223+
label is not required, but locators have no particular
224+
XLink function if they are not labeled.
225+
</xs:documentation>
226+
</xs:annotation>
227+
</xs:attribute>
228+
</xs:attributeGroup>
229+
230+
<xs:group name="locatorModel">
231+
<xs:sequence>
232+
<xs:element ref="xlink:title" minOccurs="0" maxOccurs="unbounded"/>
233+
</xs:sequence>
234+
</xs:group>
235+
236+
<xs:complexType name="locatorType">
237+
<xs:group ref="xlink:locatorModel"/>
238+
<xs:attributeGroup ref="xlink:locatorAttrs"/>
239+
</xs:complexType>
240+
241+
<xs:element name="arc" type="xlink:arcType" abstract="true"/>
242+
243+
<xs:attributeGroup name="arcAttrs">
244+
<xs:attribute ref="xlink:type" fixed="arc" use="required"/>
245+
<xs:attribute ref="xlink:arcrole"/>
246+
<xs:attribute ref="xlink:title"/>
247+
<xs:attribute ref="xlink:show"/>
248+
<xs:attribute ref="xlink:actuate"/>
249+
<xs:attribute ref="xlink:from"/>
250+
<xs:attribute ref="xlink:to">
251+
<xs:annotation>
252+
<xs:documentation>
253+
from and to have default behavior when values are missing
254+
</xs:documentation>
255+
</xs:annotation>
256+
</xs:attribute>
257+
</xs:attributeGroup>
258+
259+
<xs:group name="arcModel">
260+
<xs:sequence>
261+
<xs:element ref="xlink:title" minOccurs="0" maxOccurs="unbounded"/>
262+
</xs:sequence>
263+
</xs:group>
264+
265+
<xs:complexType name="arcType">
266+
<xs:group ref="xlink:arcModel"/>
267+
<xs:attributeGroup ref="xlink:arcAttrs"/>
268+
</xs:complexType>
269+
270+
</xs:schema>

0 commit comments

Comments
 (0)