4 Print a nice footer. add the top of the ChangeLog file (up to the ********)
20 mail_address = '(address unknown)'
22 mail_address= os.environ['MAILADDRESS']
26 webmaster= mail_address
28 webmaster= os.environ['WEBMASTER']
37 default_footer = r"""<hr>Please take me <a href=@INDEX@>back to the index</a>
41 built = r"""<hr><font size=-1>
42 This page was built from @PACKAGE_NAME@-@PACKAGE_VERSION@ by
43 <address><br>@GCOS@ <<a href="mailto:%s">@MAIL_ADDRESS@</a>>,
44 @LOCALTIME@.</address><p></font>"""
54 sys.stderr.write ("can't open file: %s\n" % f)
58 sys.stderr.write ("gulped empty file: %s\n" % f)
63 sys.stdout.write (r"""Usage: add-html-footer [OPTION]... HTML-FILE
64 Add header, footer and top of ChangLog file (up to the ********) to HTML-FILE
67 --changelog=FILE use FILE as ChangeLog [ChangeLog]
68 --footer=FILE use FILE as footer
69 --header=FILE use FILE as header
70 -h, --help print this help
71 --index=URL set homepage to URL
72 --name=NAME set package_name to NAME
73 --version=VERSION set package version to VERSION
77 (options, files) = getopt.getopt(sys.argv[1:], 'h', [
78 'changelog=', 'footer=', 'header=', 'help', 'index=',
84 if o == '--changelog':
90 elif o == '-h' or o == '--help':
97 elif o == '--version':
100 raise 'unknown opt ', o
105 os.environ["CONFIGSUFFIX"] = 'www';
108 pw = ntpwd.getpwname(os.environ['USERNAME'])
111 pw = pwd.getpwuid (os.getuid());
114 f = string.split (f, ',')[0]
117 def compose (default, file):
124 localtime = time.strftime ('%c %Z', time.localtime (time.time ()))
126 if os.path.basename (index_url) != "index.html":
127 index_url = os.path.join (index_url , "index.html")
128 top_url = os.path.dirname (index_url) + "/"
130 header = compose (default_header, header_file)
131 footer = compose (default_footer, footer_file) + built
132 header_tag = '<! header_tag >'
133 footer_tag = '<! footer_tag >'
139 changes = gulp_file (changelog_file)
141 #m = re.search ('^\\\\*\\\\*', changes)
142 m = re.search (r'\*\*\*', changes)
144 changes = changes[:m.start (0)]
145 s = re.sub ('top_of_ChangeLog', '<XMP>\n'+ changes + '\n</XMP>\n', s)
147 if re.search (header_tag, s) == None:
148 body = '<BODY BGCOLOR=WHITE><FONT COLOR=BLACK>'
149 s = re.sub ('(?i)<body>', body, s)
150 if re.search ('(?i)<BODY', s):
151 s = re.sub ('(?i)<body[^>]*>', body + header, s, 1)
152 elif re.search ('(?i)<html', s):
153 s = re.sub ('(?i)<html>', '<HTML>' + header, s, 1)
159 if re.search (footer_tag, s) == None:
162 if re.search ('(?i)</body', s):
163 s = re.sub ('(?i)</body>', footer + '</BODY>', s, 1)
164 elif re.search ('(?i)</html', s):
165 s = re.sub ('(?i)</html>', footer + '</HTML>', s, 1)
172 if os.path.basename (f) == "index.html":
174 if os.path.basename (cwd) == "topdocs":
178 # don't cause ///////index.html entries in log files.
179 # index = "./index.html"
182 s = re.sub ('@INDEX@', index, s)
183 s = re.sub ('@TOP@', top, s)
184 s = re.sub ('@PACKAGE_NAME@', package_name, s)
185 s = re.sub ('@PACKAGE_VERSION@', package_version, s)
186 s = re.sub ('@WEBMASTER@', webmaster, s)
187 s = re.sub ('@GCOS@', gcos, s)
188 s = re.sub ('@LOCALTIME@', localtime, s)
189 s = re.sub ('@MAIL_ADDRESS@', mail_address, s)
191 open (f, 'w').write (s)