]> git.donarmstrong.com Git - lilypond.git/blobdiff - scripts/lilypond-book.py
Merge branch 'master' of ssh://jomand@git.sv.gnu.org/srv/git/lilypond
[lilypond.git] / scripts / lilypond-book.py
index 1f925c13bde7094a954d579f3e64c35cc4bc0c08..b8c765d3fb0b74799d2269f922a4bcbf2e3f43a4 100644 (file)
@@ -45,6 +45,7 @@ import fontextract
 import langdefs
 global _;_=ly._
 
+ly.require_python_version ()
 
 # Lilylib globals.
 program_version = '@TOPLEVEL_VERSION@'
@@ -205,6 +206,12 @@ def get_option_parser ():
 
 lilypond_binary = os.path.join ('@bindir@', 'lilypond')
 
+# If we are called with full path, try to use lilypond binary
+# installed in the same path; this is needed in GUB binaries, where
+# @bindir is always different from the installed binary path.
+if 'bindir' in globals () and bindir:
+    lilypond_binary = os.path.join (bindir, 'lilypond')
+
 # Only use installed binary when we are installed too.
 if '@bindir@' == ('@' + 'bindir@') or not os.path.exists (lilypond_binary):
     lilypond_binary = 'lilypond'
@@ -833,6 +840,8 @@ def verbatim_html (s):
 
 ly_var_def_re = re.compile (r'^([a-zA-Z]+)[\t ]*=', re.M)
 ly_comment_re = re.compile (r'(%+[\t ]*)(.*)$', re.M)
+ly_context_id_re = re.compile ('\\\\(?:new|context)\\s+(?:[a-zA-Z]*?(?:Staff\
+(?:Group)?|Voice|FiguredBass|FretBoards|Names|Devnull))\\s+=\\s+"?([a-zA-Z]+)"?\\s+')
 
 def ly_comment_gettext (t, m):
     return m.group (1) + t (m.group (2))
@@ -851,6 +860,10 @@ def verb_ly_gettext (s):
         s = re.sub (r"(?m)(^|[' \\#])%s([^a-zA-Z])" % v,
                     "\\1" + t (v) + "\\2",
                     s)
+    for id in ly_context_id_re.findall (s):
+        s = re.sub (r'(\s+|")%s(\s+|")' % id,
+                    "\\1" + t (id) + "\\2",
+                    s)
     return s
 
 texinfo_lang_re = re.compile ('(?m)^@documentlanguage (.*?)( |$)')
@@ -1595,7 +1608,7 @@ def process_snippets (cmd, snippets,
                          'snippet-names-%d.ly' % checksum)
     file (name, 'wb').write (contents)
 
-    system_in_directory (' '.join ([cmd, name]),
+    system_in_directory (' '.join ([cmd, ly.mkarg (name)]),
                          lily_output_dir)