]> git.donarmstrong.com Git - lilypond.git/blobdiff - buildscripts/mutopia-index.py
release: 1.5.43
[lilypond.git] / buildscripts / mutopia-index.py
index 9e05102b94005f7feb55b3af7850275761c3e865..2e5d3b5e35ce558d830ca22bfb8f91932c4c4442 100755 (executable)
@@ -3,7 +3,34 @@
 
 name = 'mutopia-index'
 
-import find
+import fnmatch
+import os
+
+_debug = 0
+
+_prune = ['(*)']
+
+def find(pattern, dir = os.curdir):
+        list = []
+        names = os.listdir(dir)
+        names.sort()
+        for name in names:
+                if name in (os.curdir, os.pardir):
+                        continue
+                fullname = os.path.join(dir, name)
+                if fnmatch.fnmatch(name, pattern):
+                        list.append(fullname)
+                if os.path.isdir(fullname) and not os.path.islink(fullname):
+                        for p in _prune:
+                                if fnmatch.fnmatch(name, p):
+                                        if _debug: print "skip", `fullname`
+                                        break
+                        else:
+                                if _debug: print "descend into", `fullname`
+                                list = list + find(pattern, fullname)
+        return list
+
+
 import re
 import os
 import sys
@@ -25,27 +52,24 @@ def file_exist_b (fn):
 
 
 headertext= r"""
-These example files are taken from the LilyPond distribution. 
-LilyPond currently only outputs TeX and MIDI.  The pictures and 
-PostScript files were generated using TeX, Ghostscript and some 
-graphics tools.         The papersize used for these examples is A4. 
-The  images are in PNG format, and should be viewable with any current browser.
-We don't use GIFS due to <a href="http://www.gnu.org/philosophy/gif.html">patent problems</a>.
-<p>
-If you want an accurate impression of the output quality please <em>print
-out</em> the samples first.
-"""
+<p>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.
+
+<p>The PostScript files were generated using TeX and dvips at 600 dpi.
+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.
 
-headertext_nopics = r"""This is a subdirectory of the LilyPond example
-set.  We decided not to show any examples from this directory. If you
-want to view them, then you have to download LilyPond and compile them
-yourself."""
+<p>If you want a better impression of the appearance, do print out one of
+the postscript files.
+"""
 
 
 #
 # FIXME breaks on multiple strings.
 #
-def read_mudela_header (fn):
+def read_lilypond_header (fn):
        s = open(fn).read ()
        s = re.sub('%.*$', '', s)
        s = re.sub('\n', ' ', s)                
@@ -91,8 +115,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)
@@ -106,7 +130,7 @@ def gen_list(inputs, filename):
                ext = ext2 + ext
                
                print '%s, ' % ex
-               header = read_mudela_header(ex)
+               header = read_lilypond_header(ex)
                
                def read_dict(s, default, h =header):
                                try:
@@ -117,18 +141,22 @@ 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);
+               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>')
+               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))
                                size=os.stat(filename)[stat.ST_SIZE]
-                               l.write (' (%s %dk)' % (type, (size + 512) / 1024))
+                               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')
 
@@ -137,12 +165,13 @@ def gen_list(inputs, filename):
                        f  = base + '-page%d.png' % pageno
                        if not file_exist_b (f):
                                break
-                       list_item(f, 'The output, page %d' % pageno, 'png')
-               list_item(base + '.ps.gz', 'The output', 'gzipped PostScript')
-               list_item(base + '.midi', 'The output', 'MIDI')
-               list.write ("</ul>");
+                       list_item(f, 'See a picture of page %d' % pageno, 'png')
+               list_item(base + '.pdf', 'Print ', 'PDF')
+               list_item(base + '.ps.gz', 'Print ', 'gzipped PostScript')
+               list_item(base + '.midi', 'Listen', 'MIDI')
+               list.write ("</ul>\n");
 
-       list.write( "</BODY></HTML>");
+       list.write('</body></html>\n');
        list.close()
 
 import getopt
@@ -162,7 +191,7 @@ for opt in options:
 
 dirs  = []
 for f in files:
-       dirs = dirs + find.find ('out-www', f);
+       dirs = dirs + find ('out-www', f)
 
 if not dirs:
        dirs = ['.']
@@ -170,7 +199,7 @@ if not dirs:
 allfiles = []
 
 for d in dirs:
-       allfiles = allfiles + find.find ('*.ly.txt', d)
+       allfiles = allfiles + find ('*.ly.txt', d)
 
 print allfiles