added test of len() method for SQLTable
[pygr.git] / doc / tools / mkpkglist
blob2c51ee75e88c56d9f90e173adf1f00f43eb01bc6
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"),
28 getversioninfo = os.path.join(os.path.dirname(__file__), "getversioninfo")
29 fp = os.popen('"%s" "%s"' % (sys.executable, getversioninfo), "r")
30 release = fp.readline().strip()
31 fp.close()
33 print '''\
34 <table border="1" cellpadding="3" align="center">
35 <thead>
36 <tr bgcolor="#99ccff"><th rowspan="2">Content</th>
37 <th colspan="3">Format</th></tr>
38 <tr bgcolor="#99ccff"><th>ZIP</th><th>GZip</th><th>BZip2</th></tr>
39 </thead>
40 <tbody>'''
42 # formatted using FILE_TEMPLATE % (release, prefix, release, extension)
43 FILE_TEMPLATE = '''\
44 <td><a href="../../ftp/python/doc/%s/%s-%s%s"
45 >%dK</a></td>'''
47 NO_FILE_TEMPLATE = '''\
48 <td>&nbsp;</td>'''
50 def get_size(prefix, ext):
51 fn = "%s-%s%s" % (prefix, release, ext)
52 return int(round(os.path.getsize(fn) / 1024.0))
54 def get_file_cell(prefix, ext, have):
55 if have:
56 kb = get_size(prefix, ext)
57 return FILE_TEMPLATE % (release, prefix, release, ext, kb)
58 else:
59 return NO_FILE_TEMPLATE
61 for name, prefix in PKG_TYPES:
62 zip_fn = "%s-%s.zip" % (prefix, release)
63 tgz_fn = "%s-%s.tgz" % (prefix, release)
64 bz2_fn = "%s-%s.tar.bz2" % (prefix, release)
66 have_zip = isfile(zip_fn)
67 have_tgz = isfile(tgz_fn)
68 have_bz2 = isfile(bz2_fn)
70 if have_zip or have_tgz or have_bz2:
71 print " <tr><td>%s</td>" % name
73 print get_file_cell(prefix, ".zip", have_zip)
74 print get_file_cell(prefix, ".tgz", have_tgz)
75 print get_file_cell(prefix, ".tar.bz2", have_bz2)
77 print " </tr>"
79 print '''\
80 </tbody>
81 </table>
82 '''