From 3e027eeb9e1052974372b390e08c0ce2e992bbbd Mon Sep 17 00:00:00 2001 From: Reinhold Kainhofer Date: Fri, 7 Sep 2007 16:55:44 +0200 Subject: [PATCH] MusicXML: No crash on note without , escape lyrics with parentheses If lyrics syllables contain parentheses ( or ), we also need to wrap that syllables in quotes. It seems that some scanning applications write out some notes without a child element. Work around this case and use a default value instead of crashing. The user has to adjust the .ly file anyway. --- python/musicxml.py | 2 +- scripts/musicxml2ly.py | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/python/musicxml.py b/python/musicxml.py index e4d06a2a0a..543e47786b 100644 --- a/python/musicxml.py +++ b/python/musicxml.py @@ -5,7 +5,7 @@ import re def escape_ly_output_string (input_string): return_string = input_string - needs_quotes = re.search ("[0-9\" ,._-]", return_string); + needs_quotes = re.search ("[-0-9\" ,._()]", return_string); return_string = string.replace (return_string, "\"", "\\\"") if needs_quotes: return_string = "\"" + return_string + "\"" diff --git a/scripts/musicxml2ly.py b/scripts/musicxml2ly.py index daf52ec43c..e3dd61dcd0 100644 --- a/scripts/musicxml2ly.py +++ b/scripts/musicxml2ly.py @@ -73,7 +73,11 @@ def print_ly_information (printer, score_information): def musicxml_duration_to_lily (mxl_note): d = musicexp.Duration () if mxl_note.get_maybe_exist_typed_child (musicxml.Type): - d.duration_log = mxl_note.get_duration_log () + duration_log = mxl_note.get_duration_log () + if duration_log: + d.duration_log = mxl_note.get_duration_log () + else: + d.duration_log = 0 else: d.duration_log = 0 -- 2.39.5