lilypond-1.3.130
[lilypond.git] / bin / add-html-footer.py
blobe18d5d244a06ee70f3e92498e0df0c1adef19c88
1 #!@PYTHON@
3 """
4 Print a nice footer. add the top of the NEWS file (up to the ********)
5 """
8 import os
9 import sys
10 import getopt
11 import __main__
13 lilypath =''
14 try:
15 lilypath = os.environ['LILYPOND_SOURCEDIR'] + '/'
16 except KeyError:
17 print 'Please set LILYPOND_SOURCEDIR to the toplevel source, eg LILYPOND_SOURCEDIR=/home/foobar/lilypond-1.2.3/'
18 sys.exit(1)
20 lilypath = lilypath + '/bin/'
21 sys.path.append(lilypath)
23 from lilypython import *
25 lilyversion= ''
26 fullname = "unknown"
27 news_file = ''
29 def set_vars():
30 __main__.lilyversion = version_tuple_to_str(lilydirs.version_tuple())
31 os.environ["CONFIGSUFFIX"] = 'www';
32 pw = pwd.getpwuid (os.getuid());
34 __main__.fullname= pw[4];
37 backstr = '\n<hr>Please take me <a href=%s>back to the index</a>\n\
38 of LilyPond -- The GNU Project Music typesetter\n\
39 <hr><font size=-1>\n\
40 This page was built from lilypond-%s by <p>\n\
41 <address><br>%s <a href=mailto:%s>&lt<!bla>%s</a>&gt</address>\n\
42 <p></font>'
44 set_vars ()
45 banner_file = ''
46 news_file=''
47 news =''
48 (options, files) = getopt.getopt(sys.argv[1:], '', ['news='])
50 for opt in options:
51 o = opt[0]
52 a = opt[1]
53 if o == '--news':
54 news_file = a
56 def footstr(index):
57 return backstr % (index, lilyversion, fullname, mailaddress (), mailaddress)
59 index_file='../../out-www/index.html'
60 banner = footstr (index_file)
61 banner_id = '<! banner_id >'
64 if news_file:
65 news = gulp_file (news_file)
66 i = regex.search ('^\*\*', news)
67 news = news[:i]
70 for f in files:
71 s = gulp_file (f)
72 if news_file:
73 s = regsub.sub ('top_of_NEWS', '<XMP>\n'+ news + '\n</XMP>\n', s)
75 if regex.search (banner_id, s) == -1:
76 s = regsub.sub ('</body>', '</BODY>', s)
77 s = regsub.sub ('</BODY>', banner_id + banner + '</BODY>', s)
79 dump_file (f, s)