-def gen_list(inputs, filename):
- print "generating HTML list %s\n" % filename
- if filename:
- list = open(filename, 'w')
- else:
- list = sys.stdout
- list.write ('<html><title>Rendered Examples</title>\n')
- list.write ('<body bgcolor=white>\n')
-
- if inputs:
- list.write (headertext)
- else:
- list.write (headertext_nopics)
-
-
- for ex in inputs:
- (base, ext) = os.path.splitext (ex)
- (base, ext2) = os.path.splitext (base)
- ext = ext2 + ext
-
- print '%s, ' % ex
- header = read_lilypond_header(ex)
-
- def read_dict(s, default, h =header):
- try:
- ret = h[s]
- except KeyError:
- ret = default
- return ret
- head = read_dict('title', os.path.basename (base))
- composer = read_dict('composer', '')
- desc = read_dict('description', '')
- list.write('<hr>\n')
- list.write('<h1>example file: %s</h1>\n' % head);
- if composer <> '':
- list.write('<h2>%s</h2>\n' % composer)
- if desc <> '':
- list.write('%s<p>' % desc)
- list.write ('<ul>\n')
- def list_item(filename, desc, type, l = list):
- if file_exist_b(filename):
- l.write ('<li><a href="%s">%s</a>' % (filename, desc))
- size=os.stat(filename)[stat.ST_SIZE]
- kB=(size + 512) / 1024
- if kB:
- l.write (' (%s %dkB)' % (type, kB))
- else:
- l.write (' (%s %dcharacters)' % (type, size))
- pictures = ['jpeg', 'png', 'xpm']
- l.write ('\n')
-
- list_item(base + ext, 'The input', 'ASCII')
- for pageno in range(1,100):
- f = base + '-page%d.png' % pageno
- if not file_exist_b (f):
- break
- list_item(f, 'See a picture of page %d' % pageno, 'png')
- list_item(base + '.ps.gz', 'Print ', 'gzipped PostScript')
- list_item(base + '.midi', 'Listen', 'MIDI')
- list.write ("</ul>\n");
-
- list.write('</body></html>\n');
- list.close()
-
-import getopt
-
-(options, files) = getopt.getopt(sys.argv[1:],
- 'ho:', ['help', 'output='])
+def gen_list (inputs, file_name):
+ sys.stderr.write ("generating HTML list %s" % file_name)
+ sys.stderr.write ('\n')
+ if file_name:
+ list = open (file_name, 'w')
+ else:
+ list = sys.stdout
+ list.write ('''<html><head><title>Rendered Examples</title>
+<style type="text/css">
+hr { border:0; height:1; color: #000000; background-color: #000000; }\n
+</style>
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+</head>''')
+
+ list.write ('<body bgcolor=white>\n')
+
+ if inputs:
+ list.write (headertext)
+ else:
+ list.write (headertext_nopics)
+
+ for ex in inputs:
+ print ex
+
+ (base, ext) = os.path.splitext (ex)
+ (base, ext2) = os.path.splitext (base)
+ ext = ext2 + ext
+
+ header = read_lilypond_header (ex)
+ def read_dict (s, default, h = header):
+ try:
+ ret = h[s]
+ except KeyError:
+ ret = default
+ return ret
+ head = read_dict ('title', os.path.basename (base))
+ composer = read_dict ('composer', '')
+ desc = read_dict ('description', '')
+ list.write ('<hr>\n')
+ list.write ('<h1>%s</h1>\n' % head);
+ if composer:
+ list.write ('<h2>%s</h2>\n' % composer)
+ if desc:
+ list.write ('%s<p>' % desc)
+ list.write ('<ul>\n')
+
+ def list_item (file_name, desc, type, lst = list):
+ if os.path.isfile (file_name):
+ lst.write ('<li><a href="%s">%s</a>'
+ % (re.sub (junk_prefix, '', file_name), desc))
+
+ # FIXME: include warning if it uses \include
+ # files.
+
+ size = os.stat (file_name)[stat.ST_SIZE]
+ kB = (size + 512) / 1024
+ if kB:
+ lst.write (' (%s %d kB)' % (type, kB))
+ else:
+ lst.write (' (%s %d characters)'
+ % (type, size))
+ pictures = ['jpeg', 'png', 'xpm']
+ lst.write ('\n')
+ else:
+ print "cannot find" , `file_name`
+
+ list_item (base + ext, 'The input', 'ASCII')
+
+ pages_found = 0
+ for page in range (1, 100):
+ f = base + '-page%d.png' % page
+
+ if not os.path.isfile (f):
+ break
+ pages_found += 1
+ list_item (f, 'See a picture of page %d' % page, 'png')
+
+ if pages_found == 0 and os.path.exists (base + '.png'):
+ list_item (base + ".png",
+ 'See a picture', 'png')
+
+
+ list_item (base + '.pdf', 'Print', 'PDF')
+ list_item (base + '.midi', 'Listen', 'MIDI')
+ list.write ('</ul>\n');
+
+ list.write ('</body></html>\n');
+ list.close ()
+
+(options, files) = getopt.getopt (sys.argv[1:],
+ 'ho:', ['help', 'output='])