4 Print a nice footer. add the top of the ChangeLog file (up to the ********)
21 mail_address = '(address unknown)'
23 mail_address= os.environ['MAILADDRESS']
28 webmaster= mail_address
30 webmaster= os.environ['WEBMASTER']
37 footer = r"""<hr>Please take me <a href=%s>back to the index</a>
40 <!-- webmaster fields. %s %s>
43 builtstr = r"""<hr><font size=-1>
44 This page was built from %s-%s by
45 <address><br>%s <<a href=\"mailto:%s\">%s</a>>, %s.</address><p></font>"""
49 (options, files) = getopt.getopt(sys.argv[1:], 'c:hp:', [
50 'name=', 'footer=', 'version=',
51 'changelog=', 'help', 'news=', 'index='])
60 sys.stderr.write ("can't open file: %s\n" % f)
64 sys.stderr.write ("gulped empty file: %s\n" % f)
69 sys.stdout.write (r"""Usage: add-html-footer [OPTION]... HTML-FILE
70 Add a nice footer, add the top of the ChangLog file (up to the ********)
72 -h, --help print this help
73 --version package version
82 if o == '--news' or o == '--changelog' or o == '-c':
90 elif o == '-h' or o == '--help':
92 elif o == '--version':
95 raise 'unknown opt ', o
97 os.environ["CONFIGSUFFIX"] = 'www';
100 pw = ntpwd.getpwname(os.environ['USERNAME'])
103 pw = pwd.getpwuid (os.getuid());
106 f = string.split (f, ',')[0]
116 ft = open (footer_fn).read ()
118 raise 'oops: ' , footer_fn
121 s = ft % (index, package_name, package_name, webmaster, webmaster)
122 s = s + builtstr % (package_name, package_version, fullname,
123 mail_address, mail_address,
124 time.strftime ('%c %Z', time.localtime (time.time ())))
127 banner = footstr (index_file)
128 banner_id = '<! banner_id >'
136 changes = gulp_file (changelog_file)
138 #m = re.search ('^\\\\*\\\\*', changes)
139 m = re.search (r'\*\*\*', changes)
141 changes = changes[:m.start (0)]
142 s = re.sub ('top_of_ChangeLog', '<XMP>\n'+ changes + '\n</XMP>\n', s)
145 if re.search (banner_id, s) == None:
150 s = re.sub ('(?i)<body>', '<BODY BGCOLOR=WHITE><FONT COLOR=BLACK>', s)
152 #s = check_tag ('<body', '', s, 0)
153 if re.search ('(?i)</body', s):
154 s = re.sub ('(?i)</body>', banner + '</BODY>', s)
155 elif re.search ('(?i)</html', s):
156 s = re.sub ('(?i)</html>', banner + '</HTML>', s)
165 open (f, 'w').write (s)
168 title = '<HEAD><TITLE>' \
169 + package_name + ' -- ' + os.path.basename (os.path.splitext(f)[0]) \
171 s = check_tag ('<title>', title, s, 0)
173 s = check_tag ('<html', '', s, 0)
174 if regex.search ('<HTML', s) == -1:
176 s = check_tag ('</html>', '</HTML>', s, 1)