X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=scripts%2Flilypond-book.py;h=c0ca09a5537a3aab397da096459f3d33a3d50219;hb=1b91955adaf3c89540c8ffff7228f0ec7a31dbe4;hp=e9560f36845a164ea83df3f38b6bfdfaef043530;hpb=9a7a808b7c7abcacd08f4c992f75394cc4543d2e;p=lilypond.git diff --git a/scripts/lilypond-book.py b/scripts/lilypond-book.py index e9560f3684..c0ca09a553 100644 --- a/scripts/lilypond-book.py +++ b/scripts/lilypond-book.py @@ -1,40 +1,54 @@ #!@PYTHON@ # vim: set noexpandtab: -# TODO: -# * junk --outdir for--output -# * Figure out clean set of options. -# * -# * texinfo: add support for @pagesize -# todo: dimension handling (all the x2y) is clumsy. (tca: Thats -# because the values are taken directly from texinfo.tex, -# geometry.sty and article.cls. Give me a hint, and I'll -# fix it.) +""" -# -# TODO: magnification support should also work for texinfo -> html: eg. add as option to dvips. -# + TODO: + * junk --outdir for--output + * Figure out clean set of options. + * + * texinfo: add support for @pagesize + todo: dimension handling (all the x2y) is clumsy. (tca: Thats + because the values are taken directly from texinfo.tex, + geometry.sty and article.cls. Give me a hint, and I'll + fix it.) -# -# This is a slightly hairy program. The general approach is as follows -# The input string is chopped up in chunks, i.e. , a list of tuples -# -# with the format (TAG_STR, MAIN_STR, OPTIONS, TODO, BASE) -# -# This list is build step by step: first ignore and verbatim commands are handled, -# delivering a list of chunks. -# -# then all chunks containing lilypnod commands are chopped up -# -# when all chunks have their final form, all bodies from lilypond blocks are -# extracted, and if applicable, written do disk and run through lilypond. -# + TODO: magnification support should also work for texinfo -> html: eg. add as option to dvips. + + + + This is a slightly hairy program. The general approach is as follows + The input string is chopped up in chunks, i.e. , a list of tuples + + with the format (TAG_STR, MAIN_STR, OPTIONS, TODO, BASE) + + This list is built step by step: first ignore and verbatim commands + are handled, delivering a list of chunks. + + then all chunks containing lilypond commands are chopped up + + when all chunks have their final form, all bodies from lilypond blocks are + extracted, and if applicable, written do disk and run through lilypond. + + +tags supported -# This is was the idea for handling of comments: + ignore + lilypond + input + verb + verbatim + multicols + numcols + + +""" + +# This is was the idea for handling of comments: # Multiline comments, @ignore .. @end ignore is scanned for # in read_doc_file, and the chunks are marked as 'ignore', so # lilypond-book will not touch them any more. The content of the @@ -54,7 +68,7 @@ # The the rest of the rexeces are searched for. They don't have to test # if they are on a commented out line. - +import glob import stat import string @@ -89,14 +103,13 @@ global _;_=ly._ global re;re = ly.re # lilylib globals +program_version = '@TOPLEVEL_VERSION@' program_name = 'lilypond-book' verbose_p = 0 pseudo_filter_p = 0 original_dir = os.getcwd () -#temp_dir = os.path.join (original_dir, '%s.dir' % program_name) -#urg -temp_dir = '/tmp' -keep_temp_dir_p = 0 + + preview_resolution = 90 ## FIXME @@ -112,21 +125,20 @@ option_definitions = [ (_ ("DIM"), '', 'default-music-fontsize', _ ("default fontsize for music. DIM is assumed to be in points")), (_ ("DIM"), '', 'default-lilypond-fontsize', _ ("deprecated, use --default-music-fontsize")), (_ ("OPT"), '', 'extra-options', _ ("pass OPT quoted to the lilypond command line")), - (_ ("DIM"), '', 'force-music-fontsize', _ ("force fontsize for all inline lilypond. DIM is assumed be to in points")), + (_ ("DIM"), '', 'force-music-fontsize', _ ("force fontsize for all inline lilypond. DIM is assumed to be in points")), (_ ("DIM"), '', 'force-lilypond-fontsize', _ ("deprecated, use --force-music-fontsize")), - ('', 'h', 'help', _ ("this help")), + ('', 'h', 'help', _ ("print this help")), (_ ("DIR"), 'I', 'include', _ ("include path")), ('', 'M', 'dependencies', _ ("write dependencies")), (_ ("PREF"), '', 'dep-prefix', _ ("prepend PREF before each -M dependency")), ('', 'n', 'no-lily', _ ("don't run lilypond")), ('', '', 'no-pictures', _ ("don't generate pictures")), ('', '', 'no-music', _ ("strip all lilypond blocks from output")), - ('', '', 'read-lys', _ ("don't write ly files.")), (_ ("FILE"), 'o', 'outname', _ ("filename main output file")), (_ ("FILE"), '', 'outdir', _ ("where to place generated files")), (_ ('RES'), '', 'preview-resolution', _ ("set the resolution of the preview to RES")), - ('', 'V', 'verbose', _ ("verbose")), + ('', 'V', 'verbose', _ ("be verbose")), ('', 'v', 'version', _ ("print version information")), ('', 'w', 'warranty', _ ("show warranty and copyright")), ] @@ -137,14 +149,13 @@ option_definitions = [ include_path = [os.getcwd ()] - #lilypond_binary = 'valgrind --suppressions=/home/hanwen/usr/src/guile-1.6.supp --num-callers=10 /home/hanwen/usr/src/lilypond/lily/out/lilypond' -lilypond_binary = os.path.join ('@bindir@', 'lilypond') +lilypond_binary = os.path.join ('@bindir@', 'lilypond-bin') # only use installed binary when we're installed too. if '@bindir@' == ('@' + 'bindir@') or not os.path.exists (lilypond_binary): - lilypond_binary = 'lilypond' + lilypond_binary = 'lilypond-bin' @@ -152,7 +163,7 @@ ly2dvi_binary = os.path.join ('@bindir@', 'ly2dvi') # only use installed binary when we're installed too. if '@bindir@' == ('@' + 'bindir@') or not os.path.exists (lilypond_binary): - lilypond_binary = 'ly2dvi' + ly2dvi_binary = 'ly2dvi' @@ -161,7 +172,6 @@ g_here_dir = os.getcwd () g_dep_prefix = '' g_outdir = '' g_force_music_fontsize = 0 -g_read_lys = 0 g_do_pictures = 1 g_do_music = 1 g_make_html = 0 @@ -209,7 +219,7 @@ class LatexPaper: cmd = "latex '\\nonstopmode \input %s'" % fname # Ugh. (La)TeX writes progress and error messages on stdout # Redirect to stderr - cmd += ' 1>/dev/stderr' + cmd = '(( %s >&2 ) >&- )' % cmd status = ly.system (cmd, ignore_error = 1) signal = 0xf & status exit_status = status >> 8 @@ -341,9 +351,6 @@ output_dict= { 'html' : { - 'output-lilypond': ''' -%s -''', 'output-filename' : r'''