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"),
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()
34 <table border="1" cellpadding="3" align="center">
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>
42 # formatted using FILE_TEMPLATE % (release, prefix, release, extension)
44 <td><a href="../../ftp/python/doc/%s/%s-%s%s"
47 NO_FILE_TEMPLATE
= '''\
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
):
56 kb
= get_size(prefix
, ext
)
57 return FILE_TEMPLATE
% (release
, prefix
, release
, ext
, kb
)
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
)