From 1c15e46208343b4e40bc4e7bf7ef8d707f752b20 Mon Sep 17 00:00:00 2001 From: DrTechDaddy Date: Mon, 16 Jan 2017 15:46:38 -0500 Subject: [PATCH] midi2ly: replace unprintables with ~ --- scripts/midi2ly.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/scripts/midi2ly.py b/scripts/midi2ly.py index d1fd1ab916..9c490a5f2c 100644 --- a/scripts/midi2ly.py +++ b/scripts/midi2ly.py @@ -386,10 +386,17 @@ class Text: 'PROGRAM_NAME', 'DEVICE_NAME', ) + @staticmethod + def _text_only(chr): + if ((' ' <= chr <= '~') or chr in ['\n','\r']): + return chr + else: + return '~' + def __init__ (self, type, text): self.clocks = 0 self.type = type - self.text = text + self.text =''.join(map(self._text_only, text)) def dump (self): # urg, we should be sure that we're in a lyrics staff -- 2.39.2