13 f
= os
.popen ('find %s -name "%s"'% (dir, pat
))
15 for a
in f
.readlines():
24 <h1>LilyPond samples</h1>
27 <p>You're looking at a page with some LilyPond samples. These files
28 are also included in the distribution. The output is completely
29 generated from the source file, without any further touch up.
33 The pictures are 90 dpi anti-aliased snapshots of the printed output.
34 For a good impression of the quality print out the PDF file.
37 headertext_nopics
= r
"""
38 <p>Nothing to be seen here, move along.
42 # FIXME breaks on multiple strings.
44 def read_lilypond_header (fn
):
46 s
= re
.sub ('%.*$', '', s
)
47 s
= re
.sub ('\n', ' ', s
)
50 m
= re
.search (r
"""\\header\s*{([^}]*)}""", s
)
58 m
= re
.search (r
'''\s*(\S+)\s*=\s*"([^"]+)"''', s
)
66 left
= re
.sub ('"', '', left
)
67 right
= re
.sub ('"', '', right
)
73 sys
.stdout
.write (r
'''Usage: mutopia-index [OPTIONS] INFILE OUTFILE
74 Generate index for mutopia.
77 -h, --help print this help
78 -o, --output=FILE write output to file
79 -s, --subdirs=DIR add subdir
80 --suffix=SUF specify suffix
86 def gen_list (inputs
, file_name
):
87 sys
.stderr
.write ("generating HTML list %s" % file_name
)
88 sys
.stderr
.write ('\n')
90 list = open (file_name
, 'w')
93 list.write ('''<html><head><title>Rendered Examples</title>
94 <style type="text/css">
95 hr { border:0; height:1; color: #000000; background-color: #000000; }\n
97 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
100 list.write ('<body bgcolor=white>\n')
103 list.write (headertext
)
105 list.write (headertext_nopics
)
110 (base
, ext
) = os
.path
.splitext (ex
)
111 (base
, ext2
) = os
.path
.splitext (base
)
114 header
= read_lilypond_header (ex
)
115 def read_dict (s
, default
, h
= header
):
121 head
= read_dict ('title', os
.path
.basename (base
))
122 composer
= read_dict ('composer', '')
123 desc
= read_dict ('description', '')
124 list.write ('<hr>\n')
125 list.write ('<h1>%s</h1>\n' % head
);
127 list.write ('<h2>%s</h2>\n' % composer
)
129 list.write ('%s<p>' % desc
)
130 list.write ('<ul>\n')
132 def list_item (file_name
, desc
, type, lst
= list):
133 if os
.path
.isfile (file_name
):
134 lst
.write ('<li><a href="%s">%s</a>'
137 # FIXME: include warning if it uses \include
140 size
= os
.stat (file_name
)[stat
.ST_SIZE
]
141 kB
= (size
+ 512) / 1024
143 lst
.write (' (%s %d kB)' % (type, kB
))
145 lst
.write (' (%s %d characters)'
147 pictures
= ['jpeg', 'png', 'xpm']
150 print "can't find" , `file_name`
152 list_item (base
+ ext
, 'The input', 'ASCII')
155 for page
in range (1, 100):
156 f
= base
+ '-page%d.png' % page
158 if not os
.path
.isfile (f
):
161 list_item (f
, 'See a picture of page %d' % page
, 'png')
163 if pages_found
== 0 and os
.path
.exists (base
+ '.png'):
164 list_item (base
+ ".png",
165 'See a picture', 'png')
168 list_item (base
+ '.pdf', 'Print', 'PDF')
169 list_item (base
+ '.midi', 'Listen', 'MIDI')
170 list.write ('</ul>\n');
172 list.write ('</body></html>\n');
175 (options
, files
) = getopt
.getopt (sys
.argv
[1:],
176 'ho:', ['help', 'output='])
177 outfile
= 'examples.html'
183 if o
== '--help' or o
== '-h':
185 elif o
== '--output' or o
== '-o':
190 dirs
= dirs
+ find ('out-www', f
)
198 allfiles
= allfiles
+ find ('*.ly.txt', d
)
200 gen_list (allfiles
, outfile
)