16 raise 'not there' , fn
19 def file_exist_b (fn):
28 These example files are taken from the LilyPond distribution.
29 LilyPond currently only outputs TeX and MIDI. The pictures and
30 PostScript files were generated using TeX, Ghostscript and some
31 graphics tools. The papersize used for these examples is A4.
32 The images are in PNG format, and should be viewable with any current browser.
33 We don't use GIFS due to <a href="http://www.gnu.org/philosophy/gif.html">patent problems</a>.
35 If you want an accurate impression of the output quality please <em>print
36 out</em> the samples first.
39 headertext_nopics = r"""This is a subdirectory of the LilyPond example
40 set. We decided not to show any examples from this directory. If you
41 want to view them, then you have to download LilyPond and compile them
46 # FIXME breaks on multiple strings.
48 def read_mudela_header (fn):
50 s = re.sub('%.*$', '', s)
51 s = re.sub('\n', ' ', s)
54 m = re.search (r"""\\header\s*{([^}]*)}""", s)
62 m = re.search (r"""\s*(\S+)\s*=\s*([^;]+)\s*;""", s)
70 left = re.sub ('"', '', left)
71 right = re.sub ('"', '', right)
77 sys.stdout.write (r"""Usage: mutopia-index [options] INFILE OUTFILE
78 Generate index for mutopia\n
80 -h, --help print this help
81 -o,-output=FILE write output to file.
82 -s, --subdirs=DIR add subdir
83 --suffix=SUF specify suffix"""
88 def gen_list(inputs, filename):
89 print "generating HTML list %s\n" % filename
91 list = open(filename, 'w')
94 list.write ('<html><TITLE>Rendered Examples</TITLE>\n')
95 list.write ('<body bgcolor=white>')
98 list.write (headertext)
100 list.write (headertext_nopics)
104 (base, ext) = os.path.splitext (ex)
105 (base, ext2) = os.path.splitext (base)
109 header = read_mudela_header(ex)
111 def read_dict(s, default, h =header):
117 head = read_dict('title', os.path.basename (base))
118 composer = read_dict('composer', '')
119 desc = read_dict('description', '')
121 list.write('<h1>example file: %s</h1>' % head);
123 list.write('<h2>%s</h2>\n' % composer)
125 list.write('%s<p>' % desc)
127 def list_item(filename, desc, type, l = list):
128 if file_exist_b(filename):
129 l.write ('<li><a href=%s>%s</a>' % (filename, desc))
130 size=os.stat(filename)[stat.ST_SIZE]
131 l.write (' (%s %dk)' % (type, (size + 512) / 1024))
132 pictures = ['jpeg', 'png', 'xpm']
135 list_item(base + ext, 'The input', 'ASCII')
136 for pageno in range(1,100):
137 f = base + '-page%d.png' % pageno
138 if not file_exist_b (f):
140 list_item(f, 'The output, page %d' % pageno, 'png')
141 list_item(base + '.ps.gz', 'The output', 'gzipped PostScript')
142 list_item(base + '.midi', 'The output', 'MIDI')
143 list.write ("</ul>");
145 list.write( "</BODY></HTML>");
150 (options, files) = getopt.getopt(sys.argv[1:],
151 'ho:', ['help', 'output='])
152 outfile = 'examples.html'
158 if o == '--help' or o == '-h':
160 elif o == '--output' or o == '-o':
165 dirs = dirs + find.find ('out-www', f);
173 allfiles = allfiles + find.find ('*.ly.txt', d)
177 gen_list (allfiles, outfile)