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 <tt>.ly</tt> source file, without any further touch
34 The pictures are 90 dpi anti-aliased snapshots of the printed output.
35 If you want a better impression of the appearance, do print out one of
36 the PDF or PostScript files; they use scalable fonts, and should look
37 good at any resolution.
41 headertext_nopics= r"""
42 <p>Nothing to be seen here, move along.
46 # FIXME breaks on multiple strings.
48 def read_lilypond_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)
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.
81 -h, --help print this help
82 -o, --output=FILE write output to file
83 -s, --subdirs=DIR add subdir
84 --suffix=SUF specify suffix
90 def gen_list (inputs, file_name):
91 sys.stderr.write ("generating HTML list %s" % file_name)
92 sys.stderr.write ('\n')
94 list = open (file_name, 'w')
97 list.write ('''<html><head><title>Rendered Examples</title>
98 <style type="text/css">
99 hr { border:0; height:1; color: #000000; background-color: #000000; }\n
101 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
104 list.write ('<body bgcolor=white>\n')
107 list.write (headertext)
109 list.write (headertext_nopics)
114 (base, ext) = os.path.splitext (ex)
115 (base, ext2) = os.path.splitext (base)
118 header = read_lilypond_header (ex)
119 def read_dict (s, default, h = header):
125 head = read_dict ('title', os.path.basename (base))
126 composer = read_dict ('composer', '')
127 desc = read_dict ('description', '')
128 list.write ('<hr>\n')
129 list.write ('<h1>%s</h1>\n' % head);
131 list.write ('<h2>%s</h2>\n' % composer)
133 list.write ('%s<p>' % desc)
134 list.write ('<ul>\n')
136 def list_item (file_name, desc, type, lst = list):
137 if os.path.isfile (file_name):
138 lst.write ('<li><a href="%s">%s</a>'
141 # FIXME: include warning if it uses \include
144 size = os.stat (file_name)[stat.ST_SIZE]
145 kB = (size + 512) / 1024
147 lst.write (' (%s %d kB)' % (type, kB))
149 lst.write (' (%s %d characters)'
151 pictures = ['jpeg', 'png', 'xpm']
154 print "can't find" , `file_name`
156 list_item (base + ext, 'The input', 'ASCII')
159 for page in range (1, 100):
160 f = base + '-page%d.png' % page
162 if not os.path.isfile (f):
165 list_item (f, 'See a picture of page %d' % page, 'png')
167 if pages_found == 0 and os.path.exists (base + '.png'):
168 list_item (base + ".png",
169 'See a picture', 'png')
172 list_item (base + '.pdf', 'Print', 'PDF')
173 list_item (base + '.midi', 'Listen', 'MIDI')
174 list.write ('</ul>\n');
176 list.write ('</body></html>\n');
179 (options, files) = getopt.getopt (sys.argv[1:],
180 'ho:', ['help', 'output='])
181 outfile = 'examples.html'
187 if o == '--help' or o == '-h':
189 elif o == '--output' or o == '-o':
194 dirs = dirs + find ('out-www', f)
202 allfiles = allfiles + find ('*.ly.txt', d)
204 gen_list (allfiles, outfile)