7 lilypath
= os
.environ
['LILYPOND_SOURCEDIR'] + '/'
9 print 'Please set LILYPOND_SOURCEDIR to the toplevel source, eg LILYPOND_SOURCEDIR=/home/foobar/lilypond-1.2.3/'
12 lilypath
= lilypath
+ '/bin/'
13 sys
.path
.append(lilypath
)
15 from lilypython
import *
19 def gen_list(inputs
, subdir
, filename
):
20 (pre
, subdirs
, post
)=subdir
21 print "generating HTML list %s\n" % filename
22 list = open(filename
, 'w')
23 list.write ('<html><TITLE>Rendered Examples</TITLE>\n')
26 list.write ('<h2>subdirectories</h2>')
29 print 'subdir %s ' % ex
30 list.write ('<li><a href=%s/index.html>Subdirectory: %s</a></li>\n' % (pre
+ ex
+ post
, ex
))
34 list.write('<h2>Contents of this directory</h2>\n');
35 list.write ('These example files are taken from the LilyPond distribution.\n'
36 'LilyPond currently only outputs TeX and MIDI. The pictures and\n'
37 'PostScript files were generated using TeX, Ghostscript and some\n'
38 'graphics tools. The papersize used for these examples is A4. The GIF\n'
39 'files have been scaled to eliminate aliasing.\n');
44 header
= read_mudela_header(ex
+ '.ly.txt')
46 def read_dict(s
, default
, h
=header
):
52 head
= read_dict('title', ex
)
53 composer
= read_dict('composer', '')
54 desc
= read_dict('description', '')
56 list.write('<h1>example file: %s</h1>' % head
);
58 list.write('<h2>%s</h2>\n' % composer
)
60 list.write('%s<p>' % desc
)
62 def list_item(filename
, desc
, l
= list):
63 if file_exist_b(filename
):
64 l
.write ('<li><a href=%s>%s</a>\n' % (filename
, desc
))
66 list_item(ex
+ '.ly.txt', 'The input')
67 for pageno
in range(1,10):
68 f
= ex
+ '-page%d.gif' % pageno
69 if not file_exist_b (f
):
71 list_item(f
, 'The output (picture, page %d)' % pageno
)
72 list_item(ex
+ '.ps.gz', 'The output (gzipped PostScript)')
73 list_item(ex
+ '.midi', 'The output (MIDI)')
76 list.write( "</BODY></HTML>");
79 allfiles
= multiple_find (['*.ly.txt'], '.')
83 (cl_options
, files
) = getopt
.getopt(sys
.argv
[1:],
84 'hs:', ['help', 'subdirs=', 'suffix=', 'prefix='])
89 for opt
in cl_options
:
92 if o
== '--subdirs' or o
== '-s':
99 gen_list (files
, (subdir_pre
, subdirs
, subdir_suf
), 'index.html')