More installation info. Bump alpha version.
[python/dscho.git] / Doc / tools / mkpkglist
blobeefe2e5692838838e69d3429a77eace6b905b63c
1 #! /usr/bin/env python
3 # Simple script to create the table that lists the packages available
4 # for download. This expects the downloadable files and the Makefile
5 # to be in the current directory.
7 # The output of this script can be pasted directly into the download
8 # page for the documentation.
10 import os
11 import sys
13 from os.path import isfile
16 PKG_TYPES = [
17 # human name, filename prefix
18 ("HTML", "html"),
19 ("PDF (US-Letter)", "pdf-letter"),
20 ("PDF (A4)", "pdf-a4"),
21 ("PostScript (US-Letter)", "postscript-letter"),
22 ("PostScript (A4)", "postscript-a4"),
23 ("GNU info", "info"),
24 ("iSilo", "isilo"),
25 ("LaTeX", "latex"),
29 fp = open("Makefile")
30 for line in fp:
31 line = line.replace('=', ' ', 1)
32 parts = line.split()
33 if parts[:1] == ["RELEASE"]:
34 release = parts[1]
35 break
36 else:
37 print >>sys.stderr, "Could not locate RELEASE in Makefile."
38 sys.exit(1)
40 print '''\
41 <table border="1" cellpadding="3" align="center">
42 <thead>
43 <tr bgcolor="#99ccff"><th rowspan="2">Content</th>
44 <th colspan="3">Format</th>
45 </tr>
46 <tr bgcolor="#99ccff"><th>ZIP</th><th>GZip</th><th>BZip2</th>
47 </thead>
48 <tbody>'''
50 # formatted using FILE_TEMPLATE % (release, prefix, release, extension)
51 FILE_TEMPLATE = '''\
52 <td><a href="../../ftp/python/doc/%s/%s-%s%s"
53 >%dK</a></td>'''
55 NO_FILE_TEMPLATE = '''\
56 <td>&nbsp;</td>'''
58 def get_size(prefix, ext):
59 fn = "%s-%s%s" % (prefix, release, ext)
60 return int(round(os.path.getsize(fn) / 1024.0))
62 def get_file_cell(prefix, ext, have):
63 if have:
64 kb = get_size(prefix, ext)
65 return FILE_TEMPLATE % (release, prefix, release, ext, kb)
66 else:
67 return NO_FILE_TEMPLATE
69 for name, prefix in PKG_TYPES:
70 zip_fn = "%s-%s.zip" % (prefix, release)
71 tgz_fn = "%s-%s.tgz" % (prefix, release)
72 bz2_fn = "%s-%s.tar.bz2" % (prefix, release)
74 have_zip = isfile(zip_fn)
75 have_tgz = isfile(tgz_fn)
76 have_bz2 = isfile(bz2_fn)
78 if have_zip or have_tgz or have_bz2:
79 print " <tr><td>%s</td>" % name
81 print get_file_cell(prefix, ".zip", have_zip)
82 print get_file_cell(prefix, ".tgz", have_tgz)
83 print get_file_cell(prefix, ".tar.bz2", have_bz2)
85 print " </tr>"
87 print '''\
88 </tbody>
89 </table>
90 '''