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.
34 These images are generated at approximately 180dpi. If you want a better impression of the appearance do print out one the postscript version of the samples."""
38 # FIXME breaks on multiple strings.
40 def read_mudela_header (fn):
42 s = re.sub('%.*$', '', s)
43 s = re.sub('\n', ' ', s)
46 m = re.search (r"""\\header\s*{([^}]*)}""", s)
54 m = re.search (r"""\s*(\S+)\s*=\s*([^;]+)\s*;""", s)
62 left = re.sub ('"', '', left)
63 right = re.sub ('"', '', right)
69 sys.stdout.write (r"""Usage: mutopia-index [options] INFILE OUTFILE
70 Generate index for mutopia\n
72 -h, --help print this help
73 -o,-output=FILE write output to file.
74 -s, --subdirs=DIR add subdir
75 --suffix=SUF specify suffix"""
80 def gen_list(inputs, filename):
81 print "generating HTML list %s\n" % filename
83 list = open(filename, 'w')
86 list.write ('<html><TITLE>Rendered Examples</TITLE>\n')
87 list.write ('<body bgcolor=white>')
90 list.write (headertext)
92 list.write (headertext_nopics)
96 (base, ext) = os.path.splitext (ex)
97 (base, ext2) = os.path.splitext (base)
101 header = read_mudela_header(ex)
103 def read_dict(s, default, h =header):
109 head = read_dict('title', os.path.basename (base))
110 composer = read_dict('composer', '')
111 desc = read_dict('description', '')
113 list.write('<h1>example file: %s</h1>' % head);
115 list.write('<h2>%s</h2>\n' % composer)
117 list.write('%s<p>' % desc)
119 def list_item(filename, desc, type, l = list):
120 if file_exist_b(filename):
121 l.write ('<li><a href=%s>%s</a>' % (filename, desc))
122 size=os.stat(filename)[stat.ST_SIZE]
123 l.write (' (%s %dk)' % (type, (size + 512) / 1024))
124 pictures = ['jpeg', 'png', 'xpm']
127 list_item(base + ext, 'The input', 'ASCII')
128 for pageno in range(1,100):
129 f = base + '-page%d.png' % pageno
130 if not file_exist_b (f):
132 list_item(f, 'The output, page %d' % pageno, 'png')
133 list_item(base + '.ps.gz', 'The output', 'gzipped PostScript')
134 list_item(base + '.midi', 'The output', 'MIDI')
135 list.write ("</ul>");
137 list.write( "</BODY></HTML>");
142 (options, files) = getopt.getopt(sys.argv[1:],
143 'ho:', ['help', 'output='])
144 outfile = 'examples.html'
150 if o == '--help' or o == '-h':
152 elif o == '--output' or o == '-o':
157 dirs = dirs + find.find ('out-www', f);
165 allfiles = allfiles + find.find ('*.ly.txt', d)
169 gen_list (allfiles, outfile)