]> git.donarmstrong.com Git - lilypond.git/blob - bin/add-html-footer.py
partial: 1.0.1.jcn
[lilypond.git] / bin / add-html-footer.py
1 #!@PYTHON@
2
3 """
4 Print a nice footer.  add the top of the NEWS file (up to the ********)
5 """
6
7
8 import os
9 import sys
10 import getopt
11 import __main__
12
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)
19
20 lilypath = lilypath + '/bin/'
21 sys.path.append(lilypath)
22  
23 from lilypython import *
24
25 lilyversion= ''
26 fullname = "unknown"
27 news_file = ''
28
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());
33
34     __main__.fullname= pw[4];
35
36
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>' 
43
44 set_vars ()
45 banner_file = ''
46 news_file=''
47 news =''
48 (options, files) = getopt.getopt(sys.argv[1:], '', ['news=']) 
49
50 for opt in options:
51     o = opt[0]
52     a = opt[1]
53     if o == '--news':
54         news_file = a
55
56 def footstr(index):
57      return backstr % (index, lilyversion, fullname, mailaddress (), mailaddress)
58
59 index_file='../../out-www/index.html'
60 banner = footstr (index_file)
61 banner_id = '<! banner_id >'
62
63
64 if news_file:
65     news = gulp_file (news_file)
66     i = regex.search ('^\*\*', news)
67     news = news[:i]
68     
69     
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)
74
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)
78
79     dump_file (f, s)