def escape_ly_output_string (input_string):
return_string = input_string
- needs_quotes = re.search ("[0-9\" ,.]", return_string);
- return_string = string.replace (return_string, "\"", "\\\"")
+ needs_quotes = not re.match ("^[a-zA-ZäöüÜÄÖßñ]*$", return_string);
if needs_quotes:
- return_string = "\"" + return_string + "\""
+ return_string = "\"" + string.replace (return_string, "\"", "\\\"") + "\""
return return_string
self.instrument_name = ''
def get_duration_log (self):
- ch = self.get_maybe_exist_typed_child (get_class (u'type'))
+ ch = self.get_maybe_exist_typed_child (get_class (u'type'))
- if ch:
- log = ch.get_text ().strip()
- return {'eighth': 3,
+ if ch:
+ log = ch.get_text ().strip()
+ return {'256th': 8,
+ '128th': 7,
+ '64th': 6,
+ '32nd': 5,
+ '16th': 4,
+ 'eighth': 3,
'quarter': 2,
'half': 1,
- '16th': 4,
- '32nd': 5,
- 'breve': -1,
- 'long': -2,
- 'whole': 0}.get (log)
- else:
- return 0
+ 'whole': 0,
+ 'breve': -1,
+ 'long': -2}.get (log, 0)
+ else:
+ sys.stderr.write ("Encountered note without duration (no <type> element): %s\n" % self)
+ return 0
def get_factor (self):
- return 1
+ return 1
def get_pitches (self):
- return self.get_typed_children (get_class (u'pitch'))
+ return self.get_typed_children (get_class (u'pitch'))
class Part_list (Music_xml_node):
def __init__ (self):
and n.get_maybe_exist_typed_child (Chord)):
now = last_moment
measure_position = last_measure_position
-
- last_moment = now
- last_measure_position = measure_position
- n._when = now
+ n._when = now
n._measure_position = measure_position
- n._duration = dur
- now += dur
- measure_position += dur
+ n._duration = dur
+ if dur > Rational (0):
+ last_moment = now
+ last_measure_position = measure_position
+ now += dur
+ measure_position += dur
if n._name == 'note':
instrument = n.get_maybe_exist_named_child ('instrument')
if instrument:
else:
return 0
-class Tuplet(Music_xml_spanner):
+class Wedge (Music_xml_spanner):
+ pass
+
+class Tuplet (Music_xml_spanner):
pass
class Slur (Music_xml_spanner):
'pitch': Pitch,
'rest': Rest,
'slur': Slur,
+ 'staff': Staff,
'syllabic': Syllabic,
'text': Text,
'time-modification': Time_modification,
'tuplet': Tuplet,
'type': Type,
'wavy-line': Wavy_line,
+ 'wedge': Wedge,
'work': Work,
}