4 Print a nice footer. add the top of the ChangeLog file (up to the ********)
19 mail_address = '(address unknown)'
21 mail_address= os.environ['MAILADDRESS']
25 webmaster= mail_address
27 webmaster= os.environ['WEBMASTER']
36 default_footer = r"""<hr>Please take me <a href=%s>back to the index</a>
39 <!-- webmaster fields. %s %s>
42 builtstr = r"""<hr><font size=-1>
43 This page was built from %s-%s by
44 <address><br>%s <<a href="mailto:%s">%s</a>>, %s.</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':
96 elif o == '--version':
99 raise 'unknown opt ', o
103 os.environ["CONFIGSUFFIX"] = 'www';
106 pw = ntpwd.getpwname(os.environ['USERNAME'])
109 pw = pwd.getpwuid (os.getuid());
112 f = string.split (f, ',')[0]
116 def compose_header ():
117 global default_header
118 head = default_header
120 head = gulp_file (header_file)
123 def compose_footer (index):
124 global default_footer
125 foot = default_footer
128 foot = gulp_file (footer_file)
130 s = foot % (index, package_name, package_name, webmaster, webmaster)
131 s = s + builtstr % (package_name, package_version, fullname,
132 mail_address, mail_address,
133 time.strftime ('%c %Z', time.localtime (time.time ())))
137 header = compose_header ()
138 footer = compose_footer (index_file)
139 header_tag = '<! header_tag >'
140 footer_tag = '<! footer_tag >'
144 changes = gulp_file (changelog_file)
146 #m = re.search ('^\\\\*\\\\*', changes)
147 m = re.search (r'\*\*\*', changes)
149 changes = changes[:m.start (0)]
150 s = re.sub ('top_of_ChangeLog', '<XMP>\n'+ changes + '\n</XMP>\n', s)
152 if re.search (header_tag, s) == None:
153 body='<BODY BGCOLOR=WHITE><FONT COLOR=BLACK>'
154 s = re.sub ('(?i)<body>', body, s)
155 if re.search ('(?i)<BODY', s):
156 s = re.sub ('(?i)<body[^>]*>', body + header, s)
157 elif re.search ('(?i)<html', s):
158 s = re.sub ('(?i)<html>', '<HTML>' + header, s)
164 if re.search (footer_tag, s) == None:
167 if re.search ('(?i)</body', s):
168 s = re.sub ('(?i)</body>', footer + '</BODY>', s)
169 elif re.search ('(?i)</html', s):
170 s = re.sub ('(?i)</html>', footer + '</HTML>', s)
180 open (f, 'w').write (s)
183 title = '<HEAD><TITLE>' \
184 + package_name + ' -- ' + os.path.basename (os.path.splitext(f)[0]) \
186 s = check_tag ('<title>', title, s, 0)
188 s = check_tag ('<html', '', s, 0)
189 if regex.search ('<HTML', s) == -1:
191 s = check_tag ('</html>', '</HTML>', s, 1)