]> git.donarmstrong.com Git - lilypond.git/blobdiff - buildscripts/mutopia-index.py
* input/test/ambitus-mixed.ly (texidoc): new file.
[lilypond.git] / buildscripts / mutopia-index.py
old mode 100755 (executable)
new mode 100644 (file)
index bfa093e..399ee21
@@ -3,7 +3,6 @@
 
 name = 'mutopia-index'
 
-# find.py -- deprecated in python 2.0
 import fnmatch
 import os
 
@@ -52,22 +51,25 @@ def file_exist_b (fn):
                return 0
 
 
-headertext= r"""You're looking at a page with some LilyPond samples.
-These files are also included in the distribution. The output is
-completely generated by LilyPond, without any touch up by humans.
+headertext= r"""
 
+<p>You're looking at a page with some LilyPond samples.  These files
+are also included in the distribution. The output is completely
+generated from the <tt>.ly</tt> source file, without any further touch
+up.
 
-<p>
+<p>The PostScript files were generated using TeX and dvips at 600 dpi.
+The pictures are 90 dpi anti-aliased snapshots of the printed output.
+The images are in PNG format, and should be viewable with any current
+browser.
 
-The PostScript files were generated using TeX and dvips. The pictures
-are 90dpi anti-aliased snapshots of the printed output.  The images
-are in PNG format, and should be viewable with any current browser.
-
-<p>
-
-If you want a better impression of the appearance, do print out one of
-the postscript files."""
+<p>If you want a better impression of the appearance, do print out one of
+the postscript files.
+"""
 
+headertext_nopics= r"""
+<p>Nothing to be seen here, move along.
+"""
 
 #
 # FIXME breaks on multiple strings.
@@ -86,7 +88,7 @@ def read_lilypond_header (fn):
                        return dict
 
        while s:
-               m = re.search (r"""\s*(\S+)\s*=\s*([^;]+)\s*;""", s)
+               m = re.search (r'''\s*(\S+)\s*=\s*"([^"]+)"''', s)
                if m == None:
                        s = ''
                else:
@@ -101,13 +103,16 @@ def read_lilypond_header (fn):
        return dict
 
 def help ():
-       sys.stdout.write (r"""Usage: mutopia-index [options] INFILE OUTFILE
-Generate index for mutopia\n
+       sys.stdout.write (r"""Usage: mutopia-index [OPTIONS] INFILE OUTFILE
+Generate index for mutopia.
+
 Options:
   -h, --help                 print this help
-  -o,-output=FILE            write output to file.
+  -o, --output=FILE          write output to file
   -s, --subdirs=DIR         add subdir
-  --suffix=SUF                  specify suffix"""
+      --suffix=SUF          specify suffix
+      
+"""
                                          )
        sys.exit (0)
 
@@ -118,8 +123,8 @@ def gen_list(inputs, filename):
                list = open(filename, 'w')
        else:
                list = sys.stdout
-       list.write ('<html><TITLE>Rendered Examples</TITLE>\n')
-       list.write ('<body bgcolor=white>')
+       list.write ('<html><title>Rendered Examples</title>\n')
+       list.write ('<body bgcolor=white>\n')
        
        if inputs:
                        list.write (headertext)
@@ -132,9 +137,7 @@ def gen_list(inputs, filename):
                (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]
@@ -144,18 +147,27 @@ def gen_list(inputs, filename):
                head = read_dict('title', os.path.basename (base))
                composer = read_dict('composer', '')
                desc = read_dict('description', '')
-               list.write('<hr>')
-               list.write('<h1>example file: %s</h1>' % head);
-               if composer <> '':
+               list.write('<hr>\n')
+               list.write('<h1>%s</h1>\n' % head);
+               if composer:
                        list.write('<h2>%s</h2>\n' % composer)
-               if desc <> '':
+               if desc:
                        list.write('%s<p>' % desc)
-               list.write ('<ul>')
+               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))
+                               
+                               l.write ('<li><a href="%s">%s</a>' % (filename, desc))
+
+                               # todo: include warning if it uses \include
+                               # files.
+                               
                                size=os.stat(filename)[stat.ST_SIZE]
-                               l.write (' (%s %dk)' % (type, (size + 512) / 1024))
+                               kB=(size + 512) / 1024
+                               if kB:
+                                       l.write (' (%s %d kB)' % (type, kB))
+                               else:
+                                       l.write (' (%s %d characters)' % (type, size))
                                pictures = ['jpeg', 'png', 'xpm']
                                l.write ('\n')
 
@@ -165,11 +177,12 @@ def gen_list(inputs, filename):
                        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 + '.pdf', 'Print', 'PDF')
+               list_item(base + '.ps.gz', 'Print', 'gzipped PostScript')
                list_item(base + '.midi', 'Listen', 'MIDI')
-               list.write ("</ul>");
+               list.write ("</ul>\n");
 
-       list.write( "</BODY></HTML>");
+       list.write('</body></html>\n');
        list.close()
 
 import getopt
@@ -199,7 +212,5 @@ allfiles = []
 for d in dirs:
        allfiles = allfiles + find ('*.ly.txt', d)
 
-print allfiles
-
 gen_list (allfiles, outfile)