From: Graham Percival Date: Thu, 19 Aug 2010 17:57:16 +0000 (+0100) Subject: Build: fix for extra whitespace in makelsr.py X-Git-Tag: release/2.13.31-1~20 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=3cfcb4922411493851bce1ad87252365dc82c4f4;p=lilypond.git Build: fix for extra whitespace in makelsr.py Yes, it's ugly, but I can't figure out these stupid regexes. --- diff --git a/scripts/auxiliar/makelsr.py b/scripts/auxiliar/makelsr.py index 1c671178d7..d012f1faca 100755 --- a/scripts/auxiliar/makelsr.py +++ b/scripts/auxiliar/makelsr.py @@ -210,6 +210,7 @@ def update_ly_in_place (snippet_path): snippet_path, visited_languages), contents) + need_line_break_workaround = False for language_code in langdefs.LANGDICT: if not language_code in visited_languages: base = os.path.splitext (os.path.basename (snippet_path))[0] @@ -219,7 +220,16 @@ def update_ly_in_place (snippet_path): texidoc_translation = open (texidoc_path).read () texidoc_translation = texidoc_translation.replace ('\\', '\\\\') contents = begin_header_re.sub ('\\g<0>\n' + texidoc_translation, contents, 1) + else: + need_line_break_workaround = True contents = doctitle_re.sub (doctitle_sub, contents) + # workaround for a bug in the regex's that I'm not smart + # enough to figure out. -gp + if need_line_break_workaround: + first_translated = contents.find('%% Translation of') + keep = contents[:first_translated+5] + contents = keep + contents[first_translated+5:].replace('%% Translation of', '\n%% Translation of') + open (snippet_path, 'w').write (contents) if in_dir: