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