10 sys.path.append ('@abs-step-bindir@')
14 header_regex = regex.compile('\\header[ \t\n]*{\([^}]*\)}')
15 header_entry_regex = regex.compile('[\n\t ]*\([^\n\t ]+\)[\n\t ]*=[\n \t]*\([^;]+\)[\n \t]*;')
18 # FIXME breaks on multiple strings.
20 def read_mudela_header (fn):
22 s = regsub.gsub('%.*$', '', s)
23 s = regsub.gsub('\n', ' ', s)
26 if header_regex.search(s) <> -1:
27 h = header_regex.group(1)
31 while regex.search('=', h) <> -1:
33 if header_entry_regex.search (h) == -1:
37 h = regsub.sub(header_entry_regex, '', h)
38 left = header_entry_regex.group(1)
39 right = header_entry_regex.group(2)
41 right = regsub.gsub('\([^\\]\)\"', '\\1', right)
42 right = regsub.gsub('^"', '', right)
43 left = regsub.gsub('\([^\\]\)\"', '', left)
44 left = regsub.gsub('^"', '', left)
54 sys.stdout.write ("Usage: " + name + " [options] INFILE OUTFILE\n"
55 + "Generate index for mutopia\n\n"
57 + " -h, --help print this help\n"
58 + " -p, --package=DIR specify package\n"
59 + " --prefix=PRE specify prefix\n"
60 + " -s, --subdirs=DIR add subdir\n"
61 + " --suffix=SUF specify suffix\n"
65 def gen_list(inputs, subdir, filename):
66 (pre, subdirs, post)=subdir
67 print "generating HTML list %s\n" % filename
68 list = open(filename, 'w')
69 list.write ('<html><TITLE>Rendered Examples</TITLE>\n')
70 list.write ('<body bgcolor=white>')
72 list.write ('<h2>subdirectories</h2>')
75 print 'subdir %s ' % ex
76 list.write ('<li><a href=%s/index.html>Subdirectory: %s</a></li>\n' % (pre + ex + post , ex))
80 list.write('<h2>Contents of this directory</h2>\n');
82 These example files are taken from the LilyPond distribution.
83 LilyPond currently only outputs TeX and MIDI. The pictures and
84 PostScript files were generated using TeX, Ghostscript and some
85 graphics tools. The papersize used for these examples is A4.
86 As you know, <a href="http://www.gnu.org/philosophy/gif.html">no gifs due to patent problems</a>,
87 but the PNG images should be viewable with any current browser
89 If you want an accurate impression of the output quality please <em>print
90 out</em> the samples first.
98 header = read_mudela_header(ex + ex_ext + '.txt')
101 header = read_mudela_header(ex + ex_ext + '.txt')
103 def read_dict(s, default, h =header):
109 head = read_dict('title', ex)
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']
126 if 0 and type in pictures:
127 l.write (' <a href="http://www.gnu.org/philosophy/gif.html">no gifs due to patent problems</a>')
129 list_item(ex + ex_ext + '.txt', 'The input', 'ASCII')
130 for pageno in range(1,100):
131 f = ex + '-page%d.png' % pageno
132 if not file_exist_b (f):
134 list_item(f, 'The output, page %d' % pageno, 'png')
135 list_item(ex + '.ps.gz', 'The output', 'gzipped PostScript')
136 list_item(ex + '.midi', 'The output', 'MIDI')
137 list.write ("</ul>");
139 list.write( "</BODY></HTML>");
144 (options, files) = getopt.getopt(sys.argv[1:],
145 'hp:s:', ['help', 'subdirs=', 'suffix=', 'package=', 'prefix='])
153 if o == '--subdirs' or o == '-s':
155 elif o == '--prefix':
157 elif o == '-p' or o == '--package':
159 elif o == '--suffix':
162 sys.path.append (topdir + '/stepmake/bin')
163 from packagepython import *
164 package = Package (topdir)
165 packager = Packager ()
171 allfiles = multiple_find (['*.*ly.txt'], '.')
173 gen_list (files, (subdir_pre, subdirs, subdir_suf), 'index.html')