10 sys
.path
.append ('@abs-step-bindir@')
14 header_regex
= regex
.compile('\\header[ \t\n]*{\([^}]*\)}')
15 header_entry_regex
= regex
.compile('[\n\t ]*\([^\n\t ]+\)[\n\t ]*=[\n \t]*\([^;]+\)[\n \t]*;')
18 These example files are taken from the LilyPond distribution.
19 LilyPond currently only outputs TeX and MIDI. The pictures and
20 PostScript files were generated using TeX, Ghostscript and some
21 graphics tools. The papersize used for these examples is A4.
22 The images are in PNG format, and should be viewable with any current browser.
23 We don't use GIFS due to <a href="http://www.gnu.org/philosophy/gif.html">patent problems</a>.
25 If you want an accurate impression of the output quality please <em>print
26 out</em> the samples first.
29 headertext_nopics
= r
"""This is a subdirectory of the LilyPond example
30 set. We decided not to show any examples from this directory. If you
31 want to view them, then you have to download LilyPond and compile them
36 # FIXME breaks on multiple strings.
38 def read_mudela_header (fn
):
40 s
= regsub
.gsub('%.*$', '', s
)
41 s
= regsub
.gsub('\n', ' ', s
)
44 if header_regex
.search(s
) <> -1:
45 h
= header_regex
.group(1)
49 while regex
.search('=', h
) <> -1:
51 if header_entry_regex
.search (h
) == -1:
55 h
= regsub
.sub(header_entry_regex
, '', h
)
56 left
= header_entry_regex
.group(1)
57 right
= header_entry_regex
.group(2)
59 right
= regsub
.gsub('\([^\\]\)\"', '\\1', right
)
60 right
= regsub
.gsub('^"', '', right
)
61 left
= regsub
.gsub('\([^\\]\)\"', '', left
)
62 left
= regsub
.gsub('^"', '', left
)
72 sys
.stdout
.write ("Usage: " + name
+ " [options] INFILE OUTFILE\n"
73 + "Generate index for mutopia\n\n"
75 + " -h, --help print this help\n"
76 + " -p, --package=DIR specify package\n"
77 + " --prefix=PRE specify prefix\n"
78 + " -s, --subdirs=DIR add subdir\n"
79 + " --suffix=SUF specify suffix\n"
83 def gen_list(inputs
, subdir
, filename
):
84 (pre
, subdirs
, post
)=subdir
85 print "generating HTML list %s\n" % filename
86 list = open(filename
, 'w')
87 list.write ('<html><TITLE>Rendered Examples</TITLE>\n')
88 list.write ('<body bgcolor=white>')
90 list.write ('<h2>subdirectories</h2>')
93 print 'subdir %s ' % ex
94 list.write ('<li><a href=%s/index.html>Subdirectory: %s</a></li>\n' % (pre
+ ex
+ post
, ex
))
101 list.write('<h2>Contents of this directory</h2>\n');
103 list.write (headertext
)
105 list.write (headertext_nopics
)
112 header
= read_mudela_header(ex
+ ex_ext
+ '.txt')
115 header
= read_mudela_header(ex
+ ex_ext
+ '.txt')
117 def read_dict(s
, default
, h
=header
):
123 head
= read_dict('title', ex
)
124 composer
= read_dict('composer', '')
125 desc
= read_dict('description', '')
127 list.write('<h1>example file: %s</h1>' % head
);
129 list.write('<h2>%s</h2>\n' % composer
)
131 list.write('%s<p>' % desc
)
133 def list_item(filename
, desc
, type, l
= list):
134 if file_exist_b(filename
):
135 l
.write ('<li><a href=%s>%s</a>' % (filename
, desc
))
136 size
=os
.stat(filename
)[stat
.ST_SIZE
]
137 l
.write (' (%s %dk)' % (type, (size
+ 512) / 1024))
138 pictures
= ['jpeg', 'png', 'xpm']
140 if 0 and type in pictures
:
141 l
.write (' <a href="http://www.gnu.org/philosophy/gif.html">no gifs due to patent problems</a>')
143 list_item(ex
+ ex_ext
+ '.txt', 'The input', 'ASCII')
144 for pageno
in range(1,100):
145 f
= ex
+ '-page%d.png' % pageno
146 if not file_exist_b (f
):
148 list_item(f
, 'The output, page %d' % pageno
, 'png')
149 list_item(ex
+ '.ps.gz', 'The output', 'gzipped PostScript')
150 list_item(ex
+ '.midi', 'The output', 'MIDI')
151 list.write ("</ul>");
153 list.write( "</BODY></HTML>");
158 (options
, files
) = getopt
.getopt(sys
.argv
[1:],
159 'hp:s:', ['help', 'subdirs=', 'suffix=', 'package=', 'prefix='])
167 if o
== '--subdirs' or o
== '-s':
169 elif o
== '--prefix':
171 elif o
== '-p' or o
== '--package':
173 elif o
== '--suffix':
176 sys
.path
.append (topdir
+ '/stepmake/bin')
177 from packagepython
import *
178 package
= Package (topdir
)
179 packager
= Packager ()
185 allfiles
= multiple_find (['*.*ly.txt'], '.')
187 gen_list (files
, (subdir_pre
, subdirs
, subdir_suf
), 'index.html')