Exceptions raised during renaming in rotating file handlers are now passed to handleE...
[python.git] / Doc / tools / mkpkglist
blob1a1fd78f2b9f6819012a67f7e83d669597d52477
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 have_some = have_zip or have_tgz or have_bz2
72 if not have_some:
73 print " <!--"
74 print " <tr><td>%s</td>" % name
75 print get_file_cell(prefix, ".zip", have_zip)
76 print get_file_cell(prefix, ".tgz", have_tgz)
77 print get_file_cell(prefix, ".tar.bz2", have_bz2)
78 print " </tr>"
79 if not have_some:
80 print " -->"
82 print '''\
83 </tbody>
84 </table>
85 '''