]> git.donarmstrong.com Git - lilypond.git/commitdiff
MusicXML: Get rid of trailing spaces
authorReinhold Kainhofer <reinhold@kainhofer.com>
Thu, 22 Oct 2009 14:14:16 +0000 (16:14 +0200)
committerReinhold Kainhofer <reinhold@kainhofer.com>
Fri, 23 Oct 2009 08:00:23 +0000 (10:00 +0200)
python/musicexp.py
scripts/musicxml2ly.py

index b13c9ac2015c28260f073e6740cce5d0f0d04deb..6ef352b18941e09aa50dd892e31e1990be1d7cd6 100644 (file)
@@ -42,9 +42,9 @@ class Output_printer:
 
     """A class that takes care of formatting (eg.: indenting) a
     Music expression as a .ly file.
-    
+
     """
-    
+
     def __init__ (self):
         self._line = ''
         self._indent = 4
@@ -57,19 +57,19 @@ class Output_printer:
 
     def set_file (self, file):
         self._file = file
-        
+
     def dump_version (self):
         self.newline ()
         self.print_verbatim ('\\version "@TOPLEVEL_VERSION@"')
         self.newline ()
-        
+
     def get_indent (self):
         return self._nesting * self._indent
-    
+
     def override (self):
         last = self._output_state_stack[-1]
         self._output_state_stack.append (last.copy())
-        
+
     def add_factor (self, factor):
         self.override()
         self._output_state_stack[-1].factor *=  factor
@@ -87,21 +87,21 @@ class Output_printer:
 
     def unformatted_output (self, str):
         # don't indent on \< and indent only once on <<
-        self._nesting += ( str.count ('<') 
-                         - str.count ('\<') - str.count ('<<') 
+        self._nesting += ( str.count ('<')
+                         - str.count ('\<') - str.count ('<<')
                          + str.count ('{') )
         self._nesting -= ( str.count ('>') - str.count ('\>') - str.count ('>>')
                                            - str.count ('->') - str.count ('_>')
                                            - str.count ('^>')
                          + str.count ('}') )
         self.print_verbatim (str)
-        
+
     def print_duration_string (self, str):
         if self._last_duration == str:
             return
-        
+
         self.unformatted_output (str)
-                  
+
     def add_word (self, str):
         if (len (str) + 1 + len (self._line) > self._line_len):
             self.newline()
@@ -111,7 +111,7 @@ class Output_printer:
             self._line += ' '
         self.unformatted_output (str)
         self._skipspace = False
-        
+
     def newline (self):
         self._file.write (self._line + '\n')
         self._line = ' ' * self._indent * self._nesting
@@ -119,10 +119,10 @@ class Output_printer:
 
     def skipspace (self):
         self._skipspace = True
-        
+
     def __call__(self, arg):
         self.dump (arg)
-    
+
     def dump (self, str):
         if self._skipspace:
             self._skipspace = False
@@ -144,7 +144,7 @@ class Duration:
         self.duration_log = 0
         self.dots = 0
         self.factor = Rational (1)
-        
+
     def lisp_expression (self):
         return '(ly:make-duration %d %d %d %d)' % (self.duration_log,
                              self.dots,
@@ -173,14 +173,14 @@ class Duration:
                 str += '*%d' % factor.numerator ()
 
         return str
-    
+
     def print_ly (self, outputter):
         str = self.ly_expression (self.factor / outputter.duration_factor ())
         outputter.print_duration_string (str)
-        
+
     def __repr__(self):
         return self.ly_expression()
-        
+
     def copy (self):
         d = Duration ()
         d.dots = self.dots
@@ -282,7 +282,7 @@ class Pitch:
         self.step = 0
         self.octave = 0
         self._force_absolute_pitch = False
-        
+
     def __repr__(self):
         return self.ly_expression()
 
@@ -292,7 +292,7 @@ class Pitch:
         c.step += interval.step
         c.octave += interval.octave
         c.normalize ()
-        
+
         target_st = self.semitones()  + interval.semitones()
         c.alteration += target_st - c.semitones()
         return c
@@ -313,7 +313,7 @@ class Pitch:
         p = Pitch ()
         p.alteration = self.alteration
         p.step = self.step
-        p.octave = self.octave 
+        p.octave = self.octave
         return p
 
     def steps (self):
@@ -321,8 +321,8 @@ class Pitch:
 
     def semitones (self):
         return self.octave * 12 + [0,2,4,5,7,9,11][self.step] + self.alteration
-    
-    def ly_step_expression (self): 
+
+    def ly_step_expression (self):
         return pitch_generating_function (self)
 
     def absolute_pitch (self):
@@ -357,26 +357,26 @@ class Pitch:
             str += self.absolute_pitch ()
 
         return str
-    
+
     def print_ly (self, outputter):
         outputter (self.ly_expression())
-    
+
 class Music:
     def __init__ (self):
         self.parent = None
         self.start = Rational (0)
         self.comment = ''
         self.identifier = None
-        
+
     def get_length(self):
         return Rational (0)
-    
+
     def get_properties (self):
         return ''
-    
+
     def has_children (self):
         return False
-    
+
     def get_index (self):
         if self.parent:
             return self.parent.elements.index (self)
@@ -384,12 +384,12 @@ class Music:
             return None
     def name (self):
         return self.__class__.__name__
-    
+
     def lisp_expression (self):
         name = self.name()
 
         props = self.get_properties ()
-        
+
         return "(make-music '%s %s)" % (name,  props)
 
     def set_start (self, start):
@@ -406,20 +406,20 @@ class Music:
 
         if not text:
             return
-            
+
         if text == '\n':
             printer.newline ()
             return
-        
+
         lines = string.split (text, '\n')
         for l in lines:
             if l:
                 printer.unformatted_output ('% ' + l)
             printer.newline ()
-            
+
 
     def print_with_identifier (self, printer):
-        if self.identifier: 
+        if self.identifier:
             printer ("\\%s" % self.identifier)
         else:
             self.print_ly (printer)
@@ -456,7 +456,7 @@ class RelativeMusic (MusicWrapper):
         previous_pitch = self.basepitch
         if not previous_pitch:
             previous_pitch = Pitch ()
-        func ('\\relative %s%s' % (pitch_generating_function (previous_pitch), 
+        func ('\\relative %s%s' % (pitch_generating_function (previous_pitch),
                                    previous_pitch.absolute_pitch ()))
         MusicWrapper.print_ly (self, func)
         relative_pitches = prev_relative_pitches
@@ -484,8 +484,8 @@ class TimeScaledMusic (MusicWrapper):
             func ("\\once \\override TupletBracket #'stencil = #ly:slur::print")
             func.newline ()
 
-        base_number_function = {None: "#f", 
-             "actual": "tuplet-number::calc-denominator-text", 
+        base_number_function = {None: "#f",
+             "actual": "tuplet-number::calc-denominator-text",
              "both": "tuplet-number::calc-fraction-text"}.get (self.display_number, None)
         # If we have non-standard numerator/denominator, use our custom function
         if self.display_number == "actual" and self.display_denominator:
@@ -520,12 +520,12 @@ class TimeScaledMusic (MusicWrapper):
                 else:
                     num_duration = den_duration
                 if (self.display_denominator or self.display_numerator):
-                    func ("\\once \\override TupletNumber #'text = #(tuplet-number::non-default-fraction-with-notes %s \"%s\" %s \"%s\")" % 
+                    func ("\\once \\override TupletNumber #'text = #(tuplet-number::non-default-fraction-with-notes %s \"%s\" %s \"%s\")" %
                                 (self.display_denominator, den_duration,
                                  self.display_numerator, num_duration))
                     func.newline ()
                 else:
-                    func ("\\once \\override TupletNumber #'text = #(tuplet-number::fraction-with-notes \"%s\" \"%s\")" % 
+                    func ("\\once \\override TupletNumber #'text = #(tuplet-number::fraction-with-notes \"%s\" \"%s\")" %
                                 (den_duration, num_duration))
                     func.newline ()
         else:
@@ -550,7 +550,7 @@ class NestedMusic(Music):
     def append (self, what):
         if what:
             self.elements.append (what)
-            
+
     def has_children (self):
         return self.elements
 
@@ -558,7 +558,7 @@ class NestedMusic(Music):
         assert elt.parent == None
         assert succ == None or succ in self.elements
 
-        
+
         idx = 0
         if succ:
             idx = self.elements.index (succ)
@@ -572,7 +572,7 @@ class NestedMusic(Music):
 
         self.elements.insert (idx, elt)
         elt.parent = self
-        
+
     def get_properties (self):
         return ("'elements (list %s)"
             % string.join (map (lambda x: x.lisp_expression(),
@@ -593,10 +593,10 @@ class NestedMusic(Music):
 
     def delete_element (self, element):
         assert element in self.elements
-        
+
         self.elements.remove (element)
         element.parent = None
-        
+
     def set_start (self, start):
         self.start = start
         for e in self.elements:
@@ -606,13 +606,13 @@ class NestedMusic(Music):
         r = Music.find_first (self, predicate)
         if r:
             return r
-        
+
         for e in self.elements:
             r = e.find_first (predicate)
             if r:
                 return r
         return None
-        
+
 class SequentialMusic (NestedMusic):
     def get_last_event_chord (self):
         value = None
@@ -639,15 +639,15 @@ class SequentialMusic (NestedMusic):
         printer ('}')
         if newline:
             printer.newline()
-            
+
     def lisp_sub_expression (self, pred):
         name = self.name()
 
 
         props = self.get_subset_properties (pred)
-        
+
         return "(make-music '%s %s)" % (name,  props)
-    
+
     def set_start (self, start):
         for e in self.elements:
             e.set_start (start)
@@ -830,7 +830,7 @@ class ChordEvent (NestedMusic):
         rest_events = [e for e in self.elements if
                isinstance (e, RhythmicEvent)
                and not isinstance (e, NoteEvent)]
-        
+
         other_events = [e for e in self.elements if
                 not isinstance (e, RhythmicEvent)]
 
@@ -853,7 +853,7 @@ class ChordEvent (NestedMusic):
             self.grace_elements.print_ly (printer, False)
             printer ('{}')
 
-        # Print all overrides and other settings needed by the 
+        # Print all overrides and other settings needed by the
         # articulations/ornaments before the note
         for e in other_events:
             e.print_before_note (printer)
@@ -877,7 +877,7 @@ class ChordEvent (NestedMusic):
                 duration.print_ly (printer)
         else:
             pass
-        
+
         for e in other_events:
             e.print_ly (printer)
 
@@ -889,7 +889,7 @@ class ChordEvent (NestedMusic):
             self.after_grace_elements.print_ly (printer, False)
 
         self.print_comment (printer)
-            
+
 class Partial (Music):
     def __init__ (self):
         Music.__init__ (self)
@@ -903,7 +903,7 @@ class BarLine (Music):
         Music.__init__ (self)
         self.bar_number = 0
         self.type = None
-        
+
     def print_ly (self, printer):
         bar_symbol = { 'regular': "|", 'dotted': ":", 'dashed': "dashed",
                        'heavy': "|", 'light-light': "||", 'light-heavy': "|.",
@@ -955,13 +955,13 @@ class SpanEvent (Event):
 
 class SlurEvent (SpanEvent):
     def print_before_note (self, printer):
-        command = {'dotted': '\\slurDotted', 
+        command = {'dotted': '\\slurDotted',
                   'dashed' : '\\slurDashed'}.get (self.line_type, '')
         if command and self.span_direction == -1:
             printer.dump (command)
     def print_after_note (self, printer):
         # reset non-solid slur types!
-        command = {'dotted': '\\slurSolid', 
+        command = {'dotted': '\\slurSolid',
                   'dashed' : '\\slurSolid'}.get (self.line_type, '')
         if command and self.span_direction == -1:
             printer.dump (command)
@@ -1017,7 +1017,7 @@ class OctaveShiftEvent (SpanEvent):
         value = ''
         if dir:
             value = '\ottava #%s' % dir
-        return { 
+        return {
             -1: value,
             1: '\ottava #0'}.get (self.span_direction, '')
 
@@ -1033,7 +1033,7 @@ class GlissandoEvent (SpanEvent):
             style= {
                 "dashed" : "dashed-line",
                 "dotted" : "dotted-line",
-                "wavy"   : "zigzag" 
+                "wavy"   : "zigzag"
             }. get (self.line_type, None)
             if style:
                 printer.dump ("\once \override Glissando #'style = #'%s" % style)
@@ -1075,10 +1075,10 @@ class HairpinEvent (SpanEvent):
             return '\!'
         else:
             return {1: '\<', -1: '\>'}.get (self.span_type, '')
-    
+
     def ly_expression (self):
         return self.hairpin_to_ly ()
-    
+
     def print_ly (self, printer):
         val = self.hairpin_to_ly ()
         if val:
@@ -1261,7 +1261,7 @@ class ChordPitch:
         self.step = 0
     def __repr__(self):
         return self.ly_expression()
-    def ly_expression (self): 
+    def ly_expression (self):
         return pitch_generating_function (self)
 
 class ChordModification:
@@ -1354,11 +1354,11 @@ class RhythmicEvent(Event):
 
     def get_length (self):
         return self.duration.get_length()
-        
+
     def get_properties (self):
         return ("'duration %s"
                 % self.duration.lisp_expression ())
-    
+
 class RestEvent (RhythmicEvent):
     def __init__ (self):
         RhythmicEvent.__init__ (self)
@@ -1370,7 +1370,7 @@ class RestEvent (RhythmicEvent):
             return res + "%s%s\\rest" % (self.pitch.ly_expression (), self.duration.ly_expression ())
         else:
             return 'r%s' % self.duration.ly_expression ()
-    
+
     def print_ly (self, printer):
         for ev in self.associated_events:
             ev.print_ly (printer)
@@ -1384,7 +1384,7 @@ class RestEvent (RhythmicEvent):
 
 class SkipEvent (RhythmicEvent):
     def ly_expression (self):
-        return 's%s' % self.duration.ly_expression () 
+        return 's%s' % self.duration.ly_expression ()
 
 class NoteEvent(RhythmicEvent):
     def  __init__ (self):
@@ -1396,14 +1396,14 @@ class NoteEvent(RhythmicEvent):
 
     def get_properties (self):
         str = RhythmicEvent.get_properties (self)
-        
+
         if self.pitch:
             str += self.pitch.lisp_expression ()
         elif self.drum_type:
             str += "'drum-type '%s" % self.drum_type
 
         return str
-    
+
     def pitch_mods (self):
         excl_question = ''
         if self.cautionary:
@@ -1499,8 +1499,8 @@ class TimeSignatureChange (Music):
 
     def ly_expression (self):
         st = ''
-        # Print out the style if we have ome, but the '() should only be 
-        # forced for 2/2 or 4/4, since in all other cases we'll get numeric 
+        # Print out the style if we have ome, but the '() should only be
+        # forced for 2/2 or 4/4, since in all other cases we'll get numeric
         # signatures anyway despite the default 'C signature style!
         is_common_signature = self.fractions in ([2,2], [4,4], [4,2])
         if self.style:
@@ -1518,7 +1518,7 @@ class TimeSignatureChange (Music):
             return st + "\\compoundMeter #'%s" % self.format_fraction (self.fractions)
         else:
             return st + ''
-    
+
 class ClefChange (Music):
     def __init__ (self):
         Music.__init__ (self)
@@ -1551,7 +1551,7 @@ class ClefChange (Music):
         "C": ("clefs.C", 0, 0),
         "F": ("clefs.F", 2, 6),
         }
-    
+
     def lisp_expression (self):
         try:
             (glyph, pos, c0) = self.clef_dict[self.type]
@@ -1607,7 +1607,7 @@ class TempoMark (Music):
         return False
     def duration_to_markup (self, dur):
         if dur:
-            # Generate the markup to print the note, use scheme mode for 
+            # Generate the markup to print the note, use scheme mode for
             # ly_expression to get longa and not \longa (which causes an error)
             return "\\general-align #Y #DOWN \\smaller \\note #\"%s\" #UP" % dur.ly_expression(None, True)
         else:
@@ -1774,7 +1774,7 @@ class StaffGroup:
         printer.dump ("<<")
         printer.newline ()
         if self.stafftype and self.instrument_name:
-            printer.dump ("\\set %s.instrumentName = %s" % (self.stafftype, 
+            printer.dump ("\\set %s.instrumentName = %s" % (self.stafftype,
                     escape_instrument_string (self.instrument_name)))
             printer.newline ()
         if self.stafftype and self.short_instrument_name:
@@ -1874,7 +1874,7 @@ class DrumStaff (Staff):
 class RhythmicStaff (Staff):
     def __init__ (self, command = "RhythmicStaff"):
         Staff.__init__ (self, command)
-        
+
 class Score:
     def __init__ (self):
         self.contents = None
@@ -1882,7 +1882,7 @@ class Score:
 
     def set_contents (self, contents):
         self.contents = contents
-    
+
     def set_part_information (self, part_id, staves_info):
         if self.contents:
           self.contents.set_part_information (part_id, staves_info)
@@ -1914,8 +1914,8 @@ def test_pitch ():
     down = Pitch ()
     down.step = -4
     down.normalize ()
-    
-    
+
+
     print bflat.semitones()
     print bflat.transposed (fifth),  bflat.transposed (fifth).transposed (fifth)
     print bflat.transposed (fifth).transposed (fifth).transposed (fifth)
@@ -1940,7 +1940,7 @@ def test_printer ():
         m.append (make_note ())
         m.append (make_note ())
 
-        
+
         t = TimeScaledMusic ()
         t.numerator = 2
         t.denominator = 3
@@ -1951,14 +1951,14 @@ def test_printer ():
     m.append (make_tup ())
     m.append (make_tup ())
     m.append (make_tup ())
-    
+
     printer = Output_printer()
     m.print_ly (printer)
     printer.newline ()
-    
+
 def test_expr ():
     m = SequentialMusic()
-    l = 2  
+    l = 2
     evc = ChordEvent()
     n = NoteEvent()
     n.duration.duration_log = l
@@ -1976,7 +1976,7 @@ def test_expr ():
     evc = ChordEvent()
     n = NoteEvent()
     n.duration.duration_log = l
-    n.pitch.step = 2 
+    n.pitch.step = 2
     evc.insert_around (None, n, 0)
     m.insert_around (None, evc, 0)
 
@@ -1991,7 +1991,7 @@ def test_expr ():
     n = KeySignatureChange()
     n.tonic=tonic.copy()
     n.scale = [0, 0, -2, 0, 0,-2,-2]
-    
+
     evc.insert_around (None, n, 0)
     m.insert_around (None, evc, 0)
 
@@ -2002,7 +2002,7 @@ if __name__ == '__main__':
     test_printer ()
     raise 'bla'
     test_pitch()
-    
+
     expr = test_expr()
     expr.set_start (Rational (0))
     print expr.ly_expression()
@@ -2011,6 +2011,6 @@ if __name__ == '__main__':
     def sub(x, start=start, stop=stop):
         ok = x.start >= start and x.start +x.get_length() <= stop
         return ok
-    
+
     print expr.lisp_sub_expression(sub)
 
index ba7be37a65f025d71dd24164803af20af35aab52..aa91e9fc6857373799bfb02a63e5a7ccc1a17202 100644 (file)
@@ -30,7 +30,7 @@ class Conversion_Settings:
 
 conversion_settings = Conversion_Settings ()
 # Use a global variable to store the setting needed inside a \layout block.
-# whenever we need to change a setting or add/remove an engraver, we can access 
+# whenever we need to change a setting or add/remove an engraver, we can access
 # this layout and add the corresponding settings
 layout_information = musicexp.Layout ()
 
@@ -45,12 +45,12 @@ def error_message (str):
 needed_additional_definitions = []
 additional_definitions = {
 
-  "tuplet-note-wrapper": """      % a formatter function, which is simply a wrapper around an existing 
+  "tuplet-note-wrapper": """      % a formatter function, which is simply a wrapper around an existing
       % tuplet formatter function. It takes the value returned by the given
-      % function and appends a note of given length. 
+      % function and appends a note of given length.
   #(define-public ((tuplet-number::append-note-wrapper function note) grob)
     (let* ((txt (if function (function grob) #f)))
-      (if txt 
+      (if txt
         (markup txt #:fontsize -5 #:note note UP)
         (markup #:fontsize -5 #:note note UP)
       )
@@ -58,8 +58,8 @@ additional_definitions = {
   )""",
 
   "tuplet-non-default-denominator": """#(define ((tuplet-number::non-default-tuplet-denominator-text denominator) grob)
-  (number->string (if denominator 
-                      denominator 
+  (number->string (if denominator
+                      denominator
                       (ly:event-property (event-cause grob) 'denominator))))
 """,
 
@@ -82,15 +82,15 @@ additional_definitions = {
         (join-markups (cons (car remaining) (cons m markups)) (cdr remaining))
         markups))))
 
-% Use a centered-column inside a left-column, because the centered column 
-% moves its reference point to the center, which the left-column undoes. 
+% Use a centered-column inside a left-column, because the centered column
+% moves its reference point to the center, which the left-column undoes.
 % The center-column also aligns its contented centered, which is not undone...
 #(define-public (format-time-fraction time-sig-fraction)
   (let* ((revargs (reverse (map number->string time-sig-fraction)))
          (den (car revargs))
          (nums (reverse (cdr revargs))))
     (make-override-markup '(baseline-skip . 0)
-      (make-number-markup 
+      (make-number-markup
         (make-left-column-markup (list
           (make-center-column-markup (list
             (make-line-markup (insert-markups nums "+"))
@@ -100,7 +100,7 @@ additional_definitions = {
   (let* ((sigs (map format-time-fraction time-sig)))
     (make-override-markup '(baseline-skip . 0)
       (make-number-markup
-        (make-line-markup 
+        (make-line-markup
           (insert-markups sigs (make-vcenter-markup "+")))))))
 
 #(define-public (format-compound-time time-sig)
@@ -282,7 +282,7 @@ def extract_score_information (tree):
         set_if_exists ('title', work.get_work_title ())
         set_if_exists ('worknumber', work.get_work_number ())
         set_if_exists ('opus', work.get_opus ())
-    
+
     identifications = tree.get_named_children ('identification')
     for ids in identifications:
         set_if_exists ('copyright', ids.get_rights ())
@@ -290,17 +290,17 @@ def extract_score_information (tree):
         set_if_exists ('arranger', ids.get_arranger ())
         set_if_exists ('editor', ids.get_editor ())
         set_if_exists ('poet', ids.get_poet ())
-            
+
         set_if_exists ('tagline', ids.get_encoding_software ())
         set_if_exists ('encodingsoftware', ids.get_encoding_software ())
         set_if_exists ('encodingdate', ids.get_encoding_date ())
         set_if_exists ('encoder', ids.get_encoding_person ())
         set_if_exists ('encodingdescription', ids.get_encoding_description ())
-        
+
         set_if_exists ('texidoc', ids.get_file_description ());
 
         # Finally, apply the required compatibility modes
-        # Some applications created wrong MusicXML files, so we need to 
+        # Some applications created wrong MusicXML files, so we need to
         # apply some compatibility mode, e.g. ignoring some features/tags
         # in those files
         software = ids.get_encoding_software_list ()
@@ -422,7 +422,7 @@ def extract_score_structure (part_list, staffinfo):
     score = musicexp.Score ()
     structure = musicexp.StaffGroup (None)
     score.set_contents (structure)
-    
+
     if not part_list:
         return structure
 
@@ -559,7 +559,7 @@ def musicxml_duration_to_lily (mxl_note):
         d = musicexp.Duration ()
         d.duration_log = dur[0]
         d.dots = dur[1]
-        # Grace notes by specification have duration 0, so no time modification 
+        # Grace notes by specification have duration 0, so no time modification
         # factor is possible. It even messes up the output with *0/1
         if not mxl_note.get_maybe_exist_typed_child (musicxml.Grace):
             d.factor = mxl_note._duration / d.get_length ()
@@ -702,7 +702,7 @@ def group_repeats (music_list):
     return music_list
 
 
-# Extract the settings for tuplets from the <notations><tuplet> and the 
+# Extract the settings for tuplets from the <notations><tuplet> and the
 # <time-modification> elements of the note:
 def musicxml_tuplet_to_lily (tuplet_elt, time_modification):
     tsm = musicexp.TimeScaledMusic ()
@@ -760,7 +760,7 @@ def group_tuplets (music_list, events):
     MUSIC_LIST demarcated by EVENTS_LIST in TimeScaledMusic objects.
     """
 
-    
+
     indices = []
     brackets = {}
 
@@ -808,7 +808,7 @@ def musicxml_clef_to_lily (attributes):
     change = musicexp.ClefChange ()
     (change.type, change.position, change.octave) = attributes.get_clef_information ()
     return change
-    
+
 def musicxml_time_to_lily (attributes):
     sig = attributes.get_time_signature ()
     if not sig:
@@ -829,19 +829,19 @@ def musicxml_time_to_lily (attributes):
 
     # TODO: Handle senza-misura measures
     # TODO: Handle hidden time signatures (print-object="no")
-    # TODO: What shall we do if the symbol clashes with the sig? e.g. "cut" 
+    # TODO: What shall we do if the symbol clashes with the sig? e.g. "cut"
     #       with 3/8 or "single-number" with (2+3)/8 or 3/8+2/4?
 
     return change
 
 def musicxml_key_to_lily (attributes):
-    key_sig = attributes.get_key_signature () 
+    key_sig = attributes.get_key_signature ()
     if not key_sig or not (isinstance (key_sig, list) or isinstance (key_sig, tuple)):
         error_message (_ ("Unable to extract key signature!"))
         return None
-    
+
     change = musicexp.KeySignatureChange()
-    
+
     if len (key_sig) == 2 and not isinstance (key_sig[0], list):
         # standard key signature, (fifths, mode)
         (fifths, mode) = key_sig
@@ -894,10 +894,10 @@ def musicxml_transpose_to_lily (attributes):
     chromatic_shift = string.atoi (transpose.get_named_child ('chromatic').get_text ())
     chromatic_shift_normalized = chromatic_shift % 12;
     (shift.step, shift.alteration) = [
-        (0,0), (0,1), (1,0), (2,-1), (2,0), 
-        (3,0), (3,1), (4,0), (5,-1), (5,0), 
+        (0,0), (0,1), (1,0), (2,-1), (2,0),
+        (3,0), (3,1), (4,0), (5,-1), (5,0),
         (6,-1), (6,0)][chromatic_shift_normalized];
-    
+
     shift.octave += (chromatic_shift - chromatic_shift_normalized) / 12
 
     diatonic = transpose.get_maybe_exist_named_child ('diatonic')
@@ -929,20 +929,20 @@ def musicxml_attributes_to_lily (attrs):
             ev = func (attrs)
             if ev:
                 elts.append (ev)
-    
+
     return elts
-    
+
 def musicxml_print_to_lily (el):
     # TODO: Implement other print attributes
     #  <!ELEMENT print (page-layout?, system-layout?, staff-layout*,
-    #          measure-layout?, measure-numbering?, part-name-display?, 
+    #          measure-layout?, measure-numbering?, part-name-display?,
     #          part-abbreviation-display?)>
     #  <!ATTLIST print
     #      staff-spacing %tenths; #IMPLIED
     #      new-system %yes-no; #IMPLIED
     #      new-page %yes-no-number; #IMPLIED
     #      blank-page NMTOKEN #IMPLIED
-    #      page-number CDATA #IMPLIED 
+    #      page-number CDATA #IMPLIED
     #  >
     elts = []
     if (hasattr (el, "new-system") and conversion_settings.convert_page_layout):
@@ -1049,7 +1049,7 @@ spanner_type_dict = {
 
 def musicxml_spanner_to_lily_event (mxl_event):
     ev = None
-    
+
     name = mxl_event.get_name()
     func = spanner_event_dict.get (name)
     if func:
@@ -1251,7 +1251,7 @@ def musicxml_articulation_to_lily_event (mxl_event):
 
 def musicxml_dynamics_to_lily_event (dynentry):
     dynamics_available = (
-        "ppppp", "pppp", "ppp", "pp", "p", "mp", "mf", 
+        "ppppp", "pppp", "ppp", "pp", "p", "mp", "mf",
         "f", "ff", "fff", "ffff", "fp", "sf", "sff", "sp", "spp", "sfz", "rfz" )
     dynamicsname = dynentry.get_name ()
     if dynamicsname == "other-dynamics":
@@ -1360,7 +1360,7 @@ def musicxml_accordion_to_markup (mxl_event):
           """
     middle = mxl_event.get_maybe_exist_named_child ('accordion-middle')
     if middle:
-        # By default, use one dot (when no or invalid content is given). The 
+        # By default, use one dot (when no or invalid content is given). The
         # MusicXML spec is quiet about this case...
         txt = 1
         try:
@@ -1455,7 +1455,7 @@ def musicxml_metronome_to_ly (mxl_event):
 
     index = -1
     index = next_non_hash_index (children, index)
-    if isinstance (children[index], musicxml.BeatUnit): 
+    if isinstance (children[index], musicxml.BeatUnit):
         # first form of metronome-mark, using unit and beats/min or other unit
         ev = musicexp.TempoMark ()
         if hasattr (mxl_event, 'parentheses'):
@@ -1521,7 +1521,7 @@ def musicxml_direction_to_lily (n):
     if hasattr (n, 'placement') and options.convert_directions:
         dir = musicxml_direction_to_indicator (n.placement)
     dirtype_children = []
-    # TODO: The direction-type is used for grouping (e.g. dynamics with text), 
+    # TODO: The direction-type is used for grouping (e.g. dynamics with text),
     #       so we can't simply flatten them out!
     for dt in n.get_typed_children (musicxml.DirType):
         dirtype_children += dt.get_all_children ()
@@ -1713,12 +1713,12 @@ def musicxml_harmony_to_lily_chordname (n):
             # TODO: LilyPond does not support inversions, does it?
 
             # Mail from Carl Sorensen on lilypond-devel, June 11, 2008:
-            # 4. LilyPond supports the first inversion in the form of added 
-            # bass notes.  So the first inversion of C major would be c:/g.   
-            # To get the second inversion of C major, you would need to do 
-            # e:6-3-^5 or e:m6-^5.  However, both of these techniques 
-            # require you to know the chord and calculate either the fifth 
-            # pitch (for the first inversion) or the third pitch (for the 
+            # 4. LilyPond supports the first inversion in the form of added
+            # bass notes.  So the first inversion of C major would be c:/g.
+            # To get the second inversion of C major, you would need to do
+            # e:6-3-^5 or e:m6-^5.  However, both of these techniques
+            # require you to know the chord and calculate either the fifth
+            # pitch (for the first inversion) or the third pitch (for the
             # second inversion) so they may not be helpful for musicxml2ly.
             inversion_count = string.atoi (inversion.get_text ())
             if inversion_count == 1:
@@ -1731,7 +1731,7 @@ def musicxml_harmony_to_lily_chordname (n):
             d.step = deg.get_value ()
             d.alteration = deg.get_alter ()
             ev.add_modification (d)
-        #TODO: convert the user-symbols attribute: 
+        #TODO: convert the user-symbols attribute:
             #major: a triangle, like Unicode 25B3
             #minor: -, like Unicode 002D
             #augmented: +, like Unicode 002B
@@ -1744,12 +1744,12 @@ def musicxml_harmony_to_lily_chordname (n):
 
 def musicxml_figured_bass_note_to_lily (n):
     res = musicexp.FiguredBassNote ()
-    suffix_dict = { 'sharp' : "+", 
-                    'flat' : "-", 
-                    'natural' : "!", 
-                    'double-sharp' : "++", 
-                    'flat-flat' : "--", 
-                    'sharp-sharp' : "++", 
+    suffix_dict = { 'sharp' : "+",
+                    'flat' : "-",
+                    'natural' : "!",
+                    'double-sharp' : "++",
+                    'flat-flat' : "--",
+                    'sharp-sharp' : "++",
                     'slash' : "/" }
     prefix = n.get_maybe_exist_named_child ('prefix')
     if prefix:
@@ -1761,7 +1761,7 @@ def musicxml_figured_bass_note_to_lily (n):
     if suffix:
         res.set_suffix (suffix_dict.get (suffix.get_text (), ""))
     if n.get_maybe_exist_named_child ('extend'):
-        # TODO: Implement extender lines (unfortunately, in lilypond you have 
+        # TODO: Implement extender lines (unfortunately, in lilypond you have
         #       to use \set useBassFigureExtenders = ##t, which turns them on
         #       globally, while MusicXML has a property for each note...
         #       I'm not sure there is a proper way to implement this cleanly
@@ -1813,7 +1813,7 @@ def musicxml_note_to_lily_main_event (n):
 
         acc = n.get_maybe_exist_named_child ('accidental')
         if acc:
-            # let's not force accs everywhere. 
+            # let's not force accs everywhere.
             event.cautionary = acc.editorial
 
     elif n.get_maybe_exist_typed_child (musicxml.Unpitched):
@@ -1822,7 +1822,7 @@ def musicxml_note_to_lily_main_event (n):
        unpitched = n.get_maybe_exist_typed_child (musicxml.Unpitched)
        event = musicexp.NoteEvent ()
        event.pitch = musicxml_unpitched_to_lily (unpitched)
-        
+
     elif n.get_maybe_exist_typed_child (musicxml.Rest):
         # rests can have display-octave and display-step, which are
         # treated like an ordinary note pitch
@@ -1934,7 +1934,7 @@ class LilyPondVoiceBuilder:
         self.end_moment = self.begin_moment + duration
     def current_duration (self):
         return self.end_moment - self.begin_moment
-        
+
     def add_music (self, music, duration, relevant = True):
         assert isinstance (music, musicexp.Music)
         if self.pending_multibar > Rational (0):
@@ -1944,7 +1944,7 @@ class LilyPondVoiceBuilder:
         self.elements.append (music)
         self.begin_moment = self.end_moment
         self.set_duration (duration)
-        
+
         # Insert all pending dynamics right after the note/rest:
         if isinstance (music, musicexp.ChordEvent) and self.pending_dynamics:
             for d in self.pending_dynamics:
@@ -1962,8 +1962,8 @@ class LilyPondVoiceBuilder:
         # Insert only if we don't have a barline already
         # TODO: Implement proper merging of default barline and custom bar line
         has_relevant = self.has_relevant_elements
-        if (not (self.elements) or 
-            not (isinstance (self.elements[-1], musicexp.BarLine)) or 
+        if (not (self.elements) or
+            not (isinstance (self.elements[-1], musicexp.BarLine)) or
             (self.pending_multibar > Rational (0))):
             self.add_music (barline, Rational (0))
         self.has_relevant_elements = has_relevant or relevant
@@ -1988,9 +1988,9 @@ class LilyPondVoiceBuilder:
     def jumpto (self, moment):
         current_end = self.end_moment + self.pending_multibar
         diff = moment - current_end
-        
+
         if diff < Rational (0):
-            error_message (_ ('Negative skip %s (from position %s to %s)') % 
+            error_message (_ ('Negative skip %s (from position %s to %s)') %
                              (diff, current_end, moment))
             diff = Rational (0)
 
@@ -1999,7 +1999,7 @@ class LilyPondVoiceBuilder:
             duration_factor = 1
             duration_log = {1: 0, 2: 1, 4:2, 8:3, 16:4, 32:5, 64:6, 128:7, 256:8, 512:9}.get (diff.denominator (), -1)
             duration_dots = 0
-            # TODO: Use the time signature for skips, too. Problem: The skip 
+            # TODO: Use the time signature for skips, too. Problem: The skip
             #       might not start at a measure boundary!
             if duration_log > 0: # denominator is a power of 2...
                 if diff.numerator () == 3:
@@ -2042,7 +2042,7 @@ class LilyPondVoiceBuilder:
             self.jumpto (starting_at)
             value = None
         return value
-        
+
     def correct_negative_skip (self, goto):
         self.end_moment = goto
         self.begin_moment = goto
@@ -2078,7 +2078,7 @@ def musicxml_voice_to_lily_voice (voice):
     lyrics = {}
     return_value = VoiceData ()
     return_value.voicedata = voice
-    
+
     # First pitch needed for relative mode (if selected in command-line options)
     first_pitch = None
 
@@ -2090,7 +2090,7 @@ def musicxml_voice_to_lily_voice (voice):
     ignore_lyrics = False
 
     current_staff = None
-    
+
     pending_figured_bass = []
     pending_chordnames = []
 
@@ -2220,7 +2220,7 @@ def musicxml_voice_to_lily_voice (voice):
         if not n.__class__.__name__ == 'Note':
             n.message (_ ('unexpected %s; expected %s or %s or %s') % (n, 'Note', 'Attributes', 'Barline'))
             continue
-        
+
         main_event = musicxml_note_to_lily_main_event (n)
         if main_event and not first_pitch:
             first_pitch = main_event.pitch
@@ -2231,7 +2231,7 @@ def musicxml_voice_to_lily_voice (voice):
             modes_found['drummode'] = True
 
         ev_chord = voice_builder.last_event_chord (n._when)
-        if not ev_chord: 
+        if not ev_chord:
             ev_chord = musicexp.ChordEvent()
             voice_builder.add_music (ev_chord, n._duration)
 
@@ -2244,7 +2244,7 @@ def musicxml_voice_to_lily_voice (voice):
             grace_chord = None
 
             # after-graces and other graces use different lists; Depending on
-            # whether we have a chord or not, obtain either a new ChordEvent or 
+            # whether we have a chord or not, obtain either a new ChordEvent or
             # the previous one to create a chord
             if is_after_grace:
                 if ev_chord.after_grace_elements and n.get_maybe_exist_typed_child (musicxml.Chord):
@@ -2275,7 +2275,7 @@ def musicxml_voice_to_lily_voice (voice):
             # with duration 0. The following correct this when we hit the real note!
             if voice_builder.current_duration () == 0 and n._duration > 0:
                 voice_builder.set_duration (n._duration)
-        
+
         # if we have a figured bass, set its voice builder to the correct position
         # and insert the pending figures
         if pending_figured_bass:
@@ -2292,7 +2292,7 @@ def musicxml_voice_to_lily_voice (voice):
                     fb.duration = ev_chord.get_duration ()
                 figured_bass_builder.add_music (fb, dur)
             pending_figured_bass = []
-        
+
         if pending_chordnames:
             try:
                 chordnames_builder.jumpto (n._when)
@@ -2309,9 +2309,9 @@ def musicxml_voice_to_lily_voice (voice):
         span_events = []
 
         # The <notation> element can have the following children (+ means implemented, ~ partially, - not):
-        # +tied | +slur | +tuplet | glissando | slide | 
+        # +tied | +slur | +tuplet | glissando | slide |
         #    ornaments | technical | articulations | dynamics |
-        #    +fermata | arpeggiate | non-arpeggiate | 
+        #    +fermata | arpeggiate | non-arpeggiate |
         #    accidental-mark | other-notation
         for notations in notations_children:
             for tuplet_event in notations.get_tuplets():
@@ -2358,7 +2358,7 @@ def musicxml_voice_to_lily_voice (voice):
             fermatas = notations.get_named_children ('fermata')
             for a in fermatas:
                 ev = musicxml_fermata_to_lily_event (a)
-                if ev: 
+                if ev:
                     ev_chord.append (ev)
 
             arpeggiate = notations.get_named_children ('arpeggiate')
@@ -2389,7 +2389,7 @@ def musicxml_voice_to_lily_voice (voice):
             # Articulations can contain the following child elements:
             #         accent | strong-accent | staccato | tenuto |
             #         detached-legato | staccatissimo | spiccato |
-            #         scoop | plop | doit | falloff | breath-mark | 
+            #         scoop | plop | doit | falloff | breath-mark |
             #         caesura | stress | unstress
             # Technical can contain the following child elements:
             #         up-bow | down-bow | harmonic | open-string |
@@ -2399,7 +2399,7 @@ def musicxml_voice_to_lily_voice (voice):
             #         toe | fingernails | other-technical
             # Ornaments can contain the following child elements:
             #         trill-mark | turn | delayed-turn | inverted-turn |
-            #         shake | wavy-line | mordent | inverted-mordent | 
+            #         shake | wavy-line | mordent | inverted-mordent |
             #         schleifer | tremolo | other-ornament, accidental-mark
             ornaments = notations.get_named_children ('ornaments')
             ornaments += notations.get_named_children ('articulations')
@@ -2421,7 +2421,7 @@ def musicxml_voice_to_lily_voice (voice):
 
         mxl_beams = [b for b in n.get_named_children ('beam')
                      if (b.get_type () in ('begin', 'end')
-                         and b.is_primary ())] 
+                         and b.is_primary ())]
         if mxl_beams and not conversion_settings.ignore_beaming:
             beam_ev = musicxml_spanner_to_lily_event (mxl_beams[0])
             if beam_ev:
@@ -2455,7 +2455,7 @@ def musicxml_voice_to_lily_voice (voice):
 
     ## force trailing mm rests to be written out.
     voice_builder.add_music (musicexp.ChordEvent (), Rational (0))
-    
+
     ly_voice = group_tuplets (voice_builder.elements, tuplet_events)
     ly_voice = group_repeats (ly_voice)
 
@@ -2465,16 +2465,16 @@ def musicxml_voice_to_lily_voice (voice):
         ## \key <pitch> barfs in drummode.
         ly_voice = [e for e in ly_voice
                     if not isinstance(e, musicexp.KeySignatureChange)]
-    
+
     seq_music.elements = ly_voice
     for k in lyrics.keys ():
         return_value.lyrics_dict[k] = musicexp.Lyrics ()
         return_value.lyrics_dict[k].lyrics_syllables = lyrics[k]
-    
-    
+
+
     if len (modes_found) > 1:
        error_message (_ ('cannot simultaneously have more than one mode: %s') % modes_found.keys ())
-       
+
     if options.relative:
         v = musicexp.RelativeMusic ()
         v.element = seq_music
@@ -2487,7 +2487,7 @@ def musicxml_voice_to_lily_voice (voice):
         v.element = seq_music
         v.mode = mode
         return_value.ly_voice = v
-    
+
     # create \figuremode { figured bass elements }
     if figured_bass_builder.has_relevant_elements:
         fbass_music = musicexp.SequentialMusic ()
@@ -2496,7 +2496,7 @@ def musicxml_voice_to_lily_voice (voice):
         v.mode = 'figuremode'
         v.element = fbass_music
         return_value.figured_bass = v
-    
+
     # create \chordmode { chords }
     if chordnames_builder.has_relevant_elements:
         cname_music = musicexp.SequentialMusic ()
@@ -2505,13 +2505,13 @@ def musicxml_voice_to_lily_voice (voice):
         v.mode = 'chordmode'
         v.element = cname_music
         return_value.chordnames = v
-    
+
     return return_value
 
 def musicxml_id_to_lily (id):
     digits = ['Zero', 'One', 'Two', 'Three', 'Four', 'Five',
               'Six', 'Seven', 'Eight', 'Nine', 'Ten']
-    
+
     for digit in digits:
         d = digits.index (digit)
         id = re.sub ('%d' % d, digit, id)
@@ -2653,25 +2653,25 @@ information.""") % 'lilypond')
                   action = "store",
                   help = _ ("use a different language file 'LANG.ly' and corresponding pitch names, e.g. 'deutsch' for deutsch.ly"))
 
-    p.add_option ('--nd', '--no-articulation-directions', 
+    p.add_option ('--nd', '--no-articulation-directions',
                   action = "store_false",
                   default = True,
                   dest = "convert_directions",
                   help = _ ("do not convert directions (^, _ or -) for articulations, dynamics, etc."))
 
-    p.add_option ('--nrp', '--no-rest-positions', 
+    p.add_option ('--nrp', '--no-rest-positions',
                   action = "store_false",
                   default = True,
                   dest = "convert_rest_positions",
                   help = _ ("do not convert exact vertical positions of rests"))
 
-    p.add_option ('--npl', '--no-page-layout', 
+    p.add_option ('--npl', '--no-page-layout',
                   action = "store_false",
                   default = True,
                   dest = "convert_page_layout",
                   help = _ ("do not convert the exact page layout and breaks"))
 
-    p.add_option ('--no-beaming', 
+    p.add_option ('--no-beaming',
                   action = "store_false",
                   default = True,
                   dest = "convert_beaming",
@@ -2693,19 +2693,19 @@ information.""") % 'lilypond')
 
 def music_xml_voice_name_to_lily_name (part_id, name):
     str = "Part%sVoice%s" % (part_id, name)
-    return musicxml_id_to_lily (str) 
+    return musicxml_id_to_lily (str)
 
 def music_xml_lyrics_name_to_lily_name (part_id, name, lyricsnr):
     str = "Part%sVoice%sLyrics%s" % (part_id, name, lyricsnr)
-    return musicxml_id_to_lily (str) 
+    return musicxml_id_to_lily (str)
 
 def music_xml_figuredbass_name_to_lily_name (part_id, voicename):
     str = "Part%sVoice%sFiguredBass" % (part_id, voicename)
-    return musicxml_id_to_lily (str) 
+    return musicxml_id_to_lily (str)
 
 def music_xml_chordnames_name_to_lily_name (part_id, voicename):
     str = "Part%sVoice%sChords" % (part_id, voicename)
-    return musicxml_id_to_lily (str) 
+    return musicxml_id_to_lily (str)
 
 def print_voice_definitions (printer, part_list, voices):
     for part in part_list:
@@ -2736,7 +2736,7 @@ def print_voice_definitions (printer, part_list, voices):
 def uniq_list (l):
     return dict ([(elt,1) for elt in l]).keys ()
 
-# format the information about the staff in the form 
+# format the information about the staff in the form
 #     [staffid,
 #         [
 #            [voiceid1, [lyricsid11, lyricsid12,...], figuredbassid1],
@@ -2779,12 +2779,12 @@ def update_score_setup (score_structure, part_list, voices):
             staves = uniq_list (staves)
             staves.sort ()
             for s in staves:
-                thisstaff_raw_voices = [(voice_name, voice.lyrics_order, voice.figured_bass, voice.chordnames) 
+                thisstaff_raw_voices = [(voice_name, voice.lyrics_order, voice.figured_bass, voice.chordnames)
                     for (voice_name, voice) in nv_dict.items ()
                     if voice.voicedata._start_staff == s]
                 staves_info.append (format_staff_info (part_id, s, thisstaff_raw_voices))
         else:
-            thisstaff_raw_voices = [(voice_name, voice.lyrics_order, voice.figured_bass, voice.chordnames) 
+            thisstaff_raw_voices = [(voice_name, voice.lyrics_order, voice.figured_bass, voice.chordnames)
                 for (voice_name, voice) in nv_dict.items ()]
             staves_info.append (format_staff_info (part_id, None, thisstaff_raw_voices))
         score_structure.set_part_information (part_id, staves_info)
@@ -2808,7 +2808,7 @@ def print_ly_additional_definitions (printer, filename):
         printer.newline ()
     printer.newline ()
 
-# Read in the tree from the given I/O object (either file or string) and 
+# Read in the tree from the given I/O object (either file or string) and
 # demarshall it using the classes from the musicxml.py file
 def read_xml (io_object, use_lxml):
     if use_lxml:
@@ -2884,7 +2884,7 @@ def convert (filename, options):
     update_layout_information ()
 
     if not options.output_name:
-        options.output_name = os.path.basename (filename) 
+        options.output_name = os.path.basename (filename)
         options.output_name = os.path.splitext (options.output_name)[0]
     elif re.match (".*\.ly", options.output_name):
         options.output_name = os.path.splitext (options.output_name)[0]
@@ -2912,7 +2912,7 @@ def convert (filename, options):
     if layout_information:
         layout_information.print_ly (printer)
     print_voice_definitions (printer, part_list, voices)
-    
+
     printer.newline ()
     printer.dump ("% The score definition")
     printer.newline ()