#
# TODO:
#
-# * should have a sane default --process setting
-#
# * use --png --ps --pdf for making images?
#
# lilylib globals
program_version = '@TOPLEVEL_VERSION@'
-program_name = 'lilypond-book'
+program_name = sys.argv[0]
verbose_p = 0
pseudo_filter_p = 0
original_dir = os.getcwd ()
output_name = 0
latex_filter_cmd = 'latex "\\nonstopmode \input /dev/stdin"'
filter_cmd = 0
-process_cmd = lilypond_binary
+process_cmd = ''
default_ly_options = {}
#
#(set! toplevel-score-handler ly:parser-print-score)
#(set! toplevel-music-handler (lambda (p m)
(ly:parser-print-score
- p (ly:music-scorify m))
+ p (ly:music-scorify m p))
))
%(preamble_string)s
\bookpaper {%(bookpaper_string)s
return self.replacement_text ()
- def is_outdated (self):
+ def ly_is_outdated (self):
+ return 0
+
+ def png_is_outdated (self):
return 0
class Substring (Chunk):
open (self.basename() + '.txt', 'w').write("image of music")
- def is_outdated (self):
+ def ly_is_outdated (self):
base = self.basename ()
tex_file = '%s.tex' % base
and os.stat (tex_file)[stat.ST_SIZE] \
and open (tex_file).readlines ()[-1][1:-1] \
== 'lilypondend'
-
- if format == HTML or format == TEXINFO:
- ok = ok and (os.path.exists (base + '.png')
- or glob.glob (base + '-page*.png'))
if ok and (use_hash_p or self.ly () == open (ly_file).read ()):
# TODO: something smart with target formats
return None
return self
+ def png_is_outdated (self):
+ base = self.basename ()
+ ok = self.ly_is_outdated ()
+ if format == HTML or format == TEXINFO:
+ ok = ok and (os.path.exists (base + '.png')
+ or glob.glob (base + '-page*.png'))
+ return not ok
+
def filter_text (self):
code = self.substring ('code')
s = run_filter (code)
class Lilypond_file_snippet (Lilypond_snippet):
def ly (self):
name = self.substring ('filename')
- return open (find_file (name)).read ()
+ return '\\renameinput \"%s\"\n%s' % (name, open (find_file (name)).read ())
snippet_type_to_class = {
'lilypond_file' : Lilypond_file_snippet,
return 0
-def process_snippets (cmd, snippets):
- names = filter (lambda x: x, map (Lilypond_snippet.basename, snippets))
- if names:
- ly.system (string.join ([cmd] + names))
+def process_snippets (cmd, ly_snippets, png_snippets):
+ ly_names = filter (lambda x: x, map (Lilypond_snippet.basename, ly_snippets))
+ png_names = filter (lambda x: x, map (Lilypond_snippet.basename, png_snippets))
+
+ if ly_names:
+ ly.system (string.join ([cmd] + ly_names), progress_p = 1)
if format == HTML or format == TEXINFO:
- for i in names:
+ for i in png_names:
if not os.path.exists (i + '.eps') and os.path.exists (i + '.tex'):
to_eps (i)
ly.make_ps_images (i + '.eps', resolution=110)
elif process_cmd:
- outdated = filter (lambda x: is_derived_class (x.__class__, Lilypond_snippet) \
- and x.is_outdated (), chunks)
+ ly_outdated = filter (lambda x: is_derived_class (x.__class__, Lilypond_snippet) \
+ and x.ly_is_outdated (), chunks)
+ png_outdated = filter (lambda x: is_derived_class (x.__class__, Lilypond_snippet) \
+ and x.png_is_outdated (), chunks)
+
ly.progress (_ ("Writing snippets..."))
- map (Lilypond_snippet.write_ly, outdated)
+ map (Lilypond_snippet.write_ly, ly_outdated)
ly.progress ('\n')
- if outdated:
+ if ly_outdated:
ly.progress (_ ("Processing..."))
- process_snippets (process_cmd, outdated)
+ process_snippets (process_cmd, ly_outdated, png_outdated)
else:
ly.progress (_ ("All snippets are up to date..."))
ly.progress ('\n')
def main ():
files = do_options ()
global process_cmd
+ if process_cmd == '':
+ process_cmd = lilypond_binary + " -f tex "
+
if process_cmd:
process_cmd += string.join ([(' -I %s' % p)
for p in include_path])