]> git.donarmstrong.com Git - lilypond.git/commitdiff
Build: fix for extra whitespace in makelsr.py
authorGraham Percival <graham@percival-music.ca>
Thu, 19 Aug 2010 17:57:16 +0000 (18:57 +0100)
committerGraham Percival <graham@percival-music.ca>
Fri, 20 Aug 2010 11:49:51 +0000 (12:49 +0100)
Yes, it's ugly, but I can't figure out these stupid regexes.

scripts/auxiliar/makelsr.py

index 1c671178d76b8c60c505a1d6f6d681512dd8a54a..d012f1faca4a1e9b4460036cea3909771dbf78d7 100755 (executable)
@@ -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: