4 Print a nice footer. add the top of the ChangeLog file (up to the ********)
22 mail_address = '(address unknown)'
24 mail_address= os.environ['MAILADDRESS']
29 webmaster= mail_address
31 webmaster= os.environ['WEBMASTER']
38 footer = r"""<hr>Please take me <a href=%s>back to the index</a>
41 <!-- webmaster fields. %s %s>
44 builtstr = r"""<hr><font size=-1>
45 This page was built from %s-%s by
46 <address><br>%s <<a href=mailto:%s>%s</a>>, %s.</address><p></font>"""
50 (options, files) = getopt.getopt(sys.argv[1:], 'c:hp:', [
51 'name=', 'footer=', 'version=',
52 'changelog=', 'help', 'news=', 'index='])
61 sys.stderr.write ("can't open file: %s\n" % f)
65 sys.stderr.write ("gulped empty file: %s\n" % f)
70 sys.stdout.write (r"""Usage: add-html-footer [OPTION]... HTML-FILE
71 Add a nice footer, add the top of the ChangLog file (up to the ********)
73 -h, --help print this help
74 --version package version
83 if o == '--news' or o == '--changelog' or o == '-c':
91 elif o == '-h' or o == '--help':
93 elif o == '--version':
96 raise 'unknown opt ', o
98 os.environ["CONFIGSUFFIX"] = 'www';
101 pw = ntpwd.getpwname(os.environ['USERNAME'])
104 pw = pwd.getpwuid (os.getuid());
107 f = string.split (f, ',')[0]
117 ft = open (footer_fn).read ()
119 raise 'oops: ' , footer_fn
122 s = ft % (index, package_name, package_name, webmaster, webmaster)
123 s = s + builtstr % (package_name, package_version, fullname,
124 mail_address, mail_address,
125 time.strftime ('%c %Z', time.localtime (time.time ())))
128 banner = footstr (index_file)
129 banner_id = '<! banner_id >'
133 changes = gulp_file (changelog_file)
134 m = re.search ('^\*\*', changes)
136 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)