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.
13 from os
.path
import isfile
17 # human name, filename prefix
19 ("PDF (US-Letter)", "pdf-letter"),
20 ("PDF (A4)", "pdf-a4"),
21 ("PostScript (US-Letter)", "postscript-letter"),
22 ("PostScript (A4)", "postscript-a4"),
31 line
= line
.replace('=', ' ', 1)
33 if parts
[:1] == ["RELEASE"]:
37 print >>sys
.stderr
, "Could not locate RELEASE in Makefile."
41 <table border="1" cellpadding="3" align="center">
43 <tr bgcolor="#99ccff"><th rowspan="2">Content</th>
44 <th colspan="3">Format</th>
46 <tr bgcolor="#99ccff"><th>ZIP</th><th>GZip</th><th>BZip2</th>
50 # formatted using FILE_TEMPLATE % (release, prefix, release, extension)
52 <td><a href="../../ftp/python/doc/%s/%s-%s%s"
55 NO_FILE_TEMPLATE
= '''\
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
):
64 kb
= get_size(prefix
, ext
)
65 return FILE_TEMPLATE
% (release
, prefix
, release
, ext
, kb
)
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
)