X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=buildscripts%2Fmutopia-index.py;h=399ee211a2303b6be6b4c51d376e53c9efdd7741;hb=fd58a98a46a3def26b80a895f1f7b81c92590fc3;hp=f56ab3bca2b4d4a524d3b065b04359f8bf1274ed;hpb=c8e915a4f8c09d65db760d0637251e043320732a;p=lilypond.git diff --git a/buildscripts/mutopia-index.py b/buildscripts/mutopia-index.py old mode 100755 new mode 100644 index f56ab3bca2..399ee211a2 --- a/buildscripts/mutopia-index.py +++ b/buildscripts/mutopia-index.py @@ -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,19 +52,29 @@ 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. -

-These images are generated at approximately 180dpi. If you want a better impression of the appearance do print out one the postscript version of the samples.""" +

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 .ly source file, without any further touch +up. + +

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. + +

If you want a better impression of the appearance, do print out one of +the postscript files. +""" + +headertext_nopics= r""" +

Nothing to be seen here, move along. +""" # # 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) @@ -51,7 +88,7 @@ def read_mudela_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: @@ -66,13 +103,16 @@ def read_mudela_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) @@ -83,8 +123,8 @@ def gen_list(inputs, filename): list = open(filename, 'w') else: list = sys.stdout - list.write ('Rendered Examples\n') - list.write ('') + list.write ('Rendered Examples\n') + list.write ('\n') if inputs: list.write (headertext) @@ -97,9 +137,7 @@ def gen_list(inputs, filename): (base, ext2) = os.path.splitext (base) ext = ext2 + ext - print '%s, ' % ex - header = read_mudela_header(ex) - + header = read_lilypond_header(ex) def read_dict(s, default, h =header): try: ret = h[s] @@ -109,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('


') - list.write('

example file: %s

' % head); - if composer <> '': + list.write('
\n') + list.write('

%s

\n' % head); + if composer: list.write('

%s

\n' % composer) - if desc <> '': + if desc: list.write('%s

' % desc) - list.write ('

\n"); - list.write( ""); + list.write('\n'); list.close() import getopt @@ -154,7 +202,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 = ['.'] @@ -162,9 +210,7 @@ if not dirs: allfiles = [] for d in dirs: - allfiles = allfiles + find.find ('*.ly.txt', d) - -print allfiles + allfiles = allfiles + find ('*.ly.txt', d) gen_list (allfiles, outfile)