Answering to myself: Am Dienstag, den 17.12.2019, 19:58 +0100 schrieb Jonas Hahnfeld: > Am Samstag, den 16.11.2019, 21:52 +0100 schrieb David Kastrup: > > a77f387207 Fix musicxml2ly.py / Python 2.4.5 incompatibility > > I think it would be good to take this, but it requires > 78225bc1b3 Chord names clean-up; no more Banter, exceptionsPartial or > \powerChords. > because the \powerChords chordkind has a format in the middle (see > changes in ChordNameEvent).
There's actually an equivalent fix for ChordNameEvent by using the modulo operator. With the two patches attached, stable/2.20 is passing a full check with Python 2.4.6 on my system (the first one is actually the original commit a77f387207 without the changes for ChordNameEvent). Hope this helps, Jonas
From 7b7ce029c6aef9aa2665be862605afc0d72f40f0 Mon Sep 17 00:00:00 2001 From: Knut Petersen <[email protected]> Date: Fri, 19 Jul 2019 00:05:00 +0200 Subject: [PATCH 1/2] Fix musicxml2ly.py / Python 2.4.5 incompatibility In LilyPond 2.19.44 code was introduced that improved musicxml2ly. Unfortunately, the new code introduced a dependency on Python 2.7+, although our installers only provide the ancient Python 2.4.5. If our Python 2.4.5 was used to interpret musicxml2ly, some parts of the generated lilypond source file were ok, in other parts every character was paired with an additional NUL byte. This commit fixes that problem by adding '.encode('utf-8')' at some places. A 2nd problem was that str.format() was used. Unfortunately, str.format() is only available in python 2.6+. The patch replaces affected code with syntax compatible to our Python 2.4.5. This patch triggered the bug fixed in commit 39c9d91c46 "Fix relocate-preamble.py bug". Do not cherry-pick without 39c9d91c46! (cherry picked from commit a77f3872078ca38ca7c269a9195bb579737d0698, without the changes to chordkind_dict because not all values start with the format string unless we pick commit 78225bc1b3) Conflicts: python/musicexp.py scripts/musicxml2ly.py --- python/musicexp.py | 6 ++---- python/musicxml.py | 2 +- scripts/musicxml2ly.py | 5 ++--- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/python/musicexp.py b/python/musicexp.py index 6de0b71b1e..edb753d712 100644 --- a/python/musicexp.py +++ b/python/musicexp.py @@ -817,7 +817,7 @@ class Lyrics: for l in self.lyrics_syllables: lstr += l #lstr += "\n}" - return lstr + return lstr.encode('utf-8') class Header: @@ -2230,9 +2230,7 @@ class StaffGroup: escape_instrument_string (self.short_instrument_name))) printer.newline () if self.sound: - printer.dump( - r'\set {stafftype}.midiInstrument = #"{sound}"'.format( - stafftype=self.stafftype, sound=self.sound)) + printer.dump (r'\set %s.midiInstrument = #"%s"' % (self.stafftype, self.sound)) printer.newline () self.print_ly_contents (printer) printer.newline () diff --git a/python/musicxml.py b/python/musicxml.py index ae5ca80a59..6b70e02cc5 100644 --- a/python/musicxml.py +++ b/python/musicxml.py @@ -43,7 +43,7 @@ class Xml_node: if not self._children: return '' - return ''.join([c.get_text() for c in self._children]) + return ''.join([c.get_text() for c in self._children]).encode('utf-8') def message(self, msg): ly.warning(msg) diff --git a/scripts/musicxml2ly.py b/scripts/musicxml2ly.py index e89c61ba14..d09973afdc 100755 --- a/scripts/musicxml2ly.py +++ b/scripts/musicxml2ly.py @@ -97,8 +97,7 @@ def extract_paper_information(score_partwise): if 1 < staff_size < 100: paper.global_staff_size = staff_size else: - msg = "paper.global_staff_size {} is too large, using defaults=20".format( - staff_size) + msg = "paper.global_staff_size %s is too large, using defaults=20" % staff_size warnings.warn(msg) paper.global_staff_size = 20 @@ -1248,7 +1247,7 @@ def musicxml_dynamics_to_lily_event(dynentry): " = #(make-dynamic-script \"" + dynamicstext + "\")" needed_additional_definitions.append(dynamicsname) event = musicexp.DynamicsEvent() - event.type = dynamicsname + event.type = dynamicsname.encode('utf-8') return event # Convert single-color two-byte strings to numbers 0.0 - 1.0 -- 2.24.0
From dc814c70a75dc3f25e3b09e6601c52467ea09451 Mon Sep 17 00:00:00 2001 From: Jonas Hahnfeld <[email protected]> Date: Tue, 17 Dec 2019 21:55:50 +0100 Subject: [PATCH 2/2] Second fix for musicxml2ly with Python 2.4.5 Alternative approach to commit a77f387207 which uses the modulo operator available in Python 2.4 instead of just concatenating value and self.kind which doesn't work for 'power'. --- python/musicexp.py | 2 +- scripts/musicxml2ly.py | 54 +++++++++++++++++++++--------------------- 2 files changed, 28 insertions(+), 28 deletions(-) diff --git a/python/musicexp.py b/python/musicexp.py index edb753d712..509aff200c 100644 --- a/python/musicexp.py +++ b/python/musicexp.py @@ -1596,7 +1596,7 @@ class ChordNameEvent (Event): if self.duration: value += self.duration.ly_expression () if self.kind: - value = self.kind.format(value) + value = self.kind % value # First print all additions/changes, and only afterwards all subtractions for m in self.modifications: if m.type == 1: diff --git a/scripts/musicxml2ly.py b/scripts/musicxml2ly.py index d09973afdc..3ad7296309 100755 --- a/scripts/musicxml2ly.py +++ b/scripts/musicxml2ly.py @@ -1620,37 +1620,37 @@ def musicxml_chordpitch_to_lily(mxl_cpitch): return r chordkind_dict = { - 'major': r'{}:5', - 'minor': r'{}:m5', - 'augmented': r'{}:aug5', - 'diminished': r'{}:dim5', + 'major': r'%s:5', + 'minor': r'%s:m5', + 'augmented': r'%s:aug5', + 'diminished': r'%s:dim5', # Sevenths: - 'dominant': r'{}:7', - 'dominant-seventh': r'{}:7', - 'major-seventh': r'{}:maj7', - 'minor-seventh': r'{}:m7', - 'diminished-seventh': r'{}:dim7', - 'augmented-seventh': r'{}:aug7', - 'half-diminished': r'{}:dim5m7', - 'major-minor': r'{}:maj7m5', + 'dominant': r'%s:7', + 'dominant-seventh': r'%s:7', + 'major-seventh': r'%s:maj7', + 'minor-seventh': r'%s:m7', + 'diminished-seventh': r'%s:dim7', + 'augmented-seventh': r'%s:aug7', + 'half-diminished': r'%s:dim5m7', + 'major-minor': r'%s:maj7m5', # Sixths: - 'major-sixth': r'{}:6', - 'minor-sixth': r'{}:m6', + 'major-sixth': r'%s:6', + 'minor-sixth': r'%s:m6', # Ninths: - 'dominant-ninth': r'{}:9', - 'major-ninth': r'{}:maj9', - 'minor-ninth': r'{}:m9', + 'dominant-ninth': r'%s:9', + 'major-ninth': r'%s:maj9', + 'minor-ninth': r'%s:m9', # 11ths (usually as the basis for alteration): - 'dominant-11th': r'{}:11', - 'major-11th': r'{}:maj11', - 'minor-11th': r'{}:m11', + 'dominant-11th': r'%s:11', + 'major-11th': r'%s:maj11', + 'minor-11th': r'%s:m11', # 13ths (usually as the basis for alteration): - 'dominant-13th': r'{}:13.11', - 'major-13th': r'{}:maj13.11', - 'minor-13th': r'{}:m13', + 'dominant-13th': r'%s:13.11', + 'major-13th': r'%s:maj13.11', + 'minor-13th': r'%s:m13', # Suspended: - 'suspended-second': r'{}:sus2', - 'suspended-fourth': r'{}:sus4', + 'suspended-second': r'%s:sus2', + 'suspended-fourth': r'%s:sus4', # Functional sixths: # TODO #'Neapolitan': '???', @@ -1659,9 +1659,9 @@ chordkind_dict = { #'German': '???', # Other: #'pedal': '???',(pedal-point bass) - 'power': r'\powerChords {}:1.5', + 'power': r'\powerChords %s:1.5', #'Tristan': '???', - 'other': r'{}:1', + 'other': r'%s:1', 'none': None, } -- 2.24.0
signature.asc
Description: This is a digitally signed message part
