]> git.donarmstrong.com Git - lilypond.git/blob - bin/mutopia-index.py
release: 0.1.59
[lilypond.git] / bin / mutopia-index.py
1
2 import sys
3 import os
4
5 lilypath =''
6 try:
7     lilypath = os.environ['LILYPOND_SOURCEDIR'] + '/'
8 except KeyError:
9     print 'Please set LILYPOND_SOURCEDIR to the toplevel source, eg LILYPOND_SOURCEDIR=/home/foobar/lilypond-1.2.3/'
10     sys.exit(1)
11
12 lilypath = lilypath + '/bin/'
13 sys.path.append(lilypath)
14  
15 from lilypython import *
16
17
18
19 def gen_list(inputs, filename):
20     print "generating HTML list %s\n" % filename
21     list = open(filename, 'w')
22     list.write ('<html><TITLE>Rendered Examples</TITLE>\n'
23      '<body>These example files are taken from the LilyPond distribution.\n'
24      'LilyPond currently only outputs TeX and MIDI. The pictures and\n'
25      'PostScript files were generated using TeX, Ghostscript and some\n'
26      'graphics tools.  The papersize used for these examples is A4.  The GIF\n'
27      'files have been scaled to eliminate aliasing.\n');
28
29     for ex in inputs:
30         print '%s, ' % ex
31         header  = read_mudela_header(ex + '.ly.txt')
32         
33         def read_dict(s, default, h =header):
34                 try:
35                     ret = h[s]
36                 except KeyError:
37                     ret = default
38                 return ret
39         head = read_dict('title', ex)
40         composer = read_dict('composer', '')
41         desc = read_dict('description', '')
42         list.write('<hr>')
43         list.write('<h1>example file: %s</h1>' % head);
44         if composer <> '':
45             list.write('<h2>%s</h2>\n' % composer)
46         if desc <> '':
47             list.write('%s<p>' % desc)
48         list.write ('<ul>')
49         def list_item(filename, desc, l = list):
50             if file_exist_b(filename):
51                 l.write ('<li><a href=%s>%s</a>\n' % (filename, desc))
52             
53         list_item(ex + '.ly.txt', 'The input')
54         for pageno in range(1,10):
55             f  = ex + '-page%d.gif' % pageno
56             if not file_exist_b (f):
57                 break
58             list_item(f, 'The output (picture, page %d)' % pageno)
59         list_item(ex + '.ps.gz', 'The output (gzipped PostScript)')
60         list_item(ex + '.midi', 'The output (MIDI)')
61         list.write ("</ul>");
62
63     list.write( "</BODY></HTML>");
64     list.close()
65
66 allfiles = multiple_find (['*.ly.txt'], '.')
67
68 gen_list (sys.argv[1:], 'index.html')