X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=buildscripts%2Fmutopia-index.py;h=947e4ea316969fe1d6ebe7e0edbbcd4f14dcbe59;hb=29d0c4b33b7bc6434d32d735358b8768e965c117;hp=9e05102b94005f7feb55b3af7850275761c3e865;hpb=a6193f6f613e0b2ff519b804d28f99fcd6ec9b92;p=lilypond.git diff --git a/buildscripts/mutopia-index.py b/buildscripts/mutopia-index.py old mode 100755 new mode 100644 index 9e05102b94..947e4ea316 --- 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,27 +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. -We don't use GIFS due to patent problems. + +

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

-If you want an accurate impression of the output quality please print -out the samples first. -""" -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.""" +The pictures are 90 dpi anti-aliased snapshots of the printed output. +If you want a better impression of the appearance, do print out one of +the PDF or PostScript files; they use scalable fonts, and should look +good at any resolution. + +""" +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) @@ -59,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: @@ -74,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) @@ -91,8 +123,12 @@ 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') + + list.write ('\n') if inputs: list.write (headertext) @@ -105,9 +141,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] @@ -117,18 +151,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 @@ -162,7 +206,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,9 +214,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)