summaryrefslogtreecommitdiffstats
path: root/Doc/tools/mkpkglist
blob: 2c51ee75e88c56d9f90e173adf1f00f43eb01bc6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#! /usr/bin/env python
#
# Simple script to create the table that lists the packages available
# for download.  This expects the downloadable files and the Makefile
# to be in the current directory.
#
# The output of this script can be pasted directly into the download
# page for the documentation.

import os
import sys

from os.path import isfile


PKG_TYPES = [
    # human name, filename prefix
    ("HTML", "html"),
    ("PDF (US-Letter)", "pdf-letter"),
    ("PDF (A4)", "pdf-a4"),
    ("PostScript (US-Letter)", "postscript-letter"),
    ("PostScript (A4)", "postscript-a4"),
    ("GNU info", "info"),
    ("iSilo", "isilo"),
    ("LaTeX", "latex"),
    ]

getversioninfo = os.path.join(os.path.dirname(__file__), "getversioninfo")
fp = os.popen('"%s" "%s"' % (sys.executable, getversioninfo), "r")
release = fp.readline().strip()
fp.close()

print '''\
<table border="1" cellpadding="3" align="center">
  <thead>
    <tr bgcolor="#99ccff"><th rowspan="2">Content</th>
                          <th colspan="3">Format</th></tr>
    <tr bgcolor="#99ccff"><th>ZIP</th><th>GZip</th><th>BZip2</th></tr>
    </thead>
  <tbody>'''

# formatted using FILE_TEMPLATE % (release, prefix, release, extension)
FILE_TEMPLATE = '''\
        <td><a href="../../ftp/python/doc/%s/%s-%s%s"
            >%dK</a></td>'''

NO_FILE_TEMPLATE = '''\
        <td>&nbsp;</td>'''

def get_size(prefix, ext):
    fn = "%s-%s%s" % (prefix, release, ext)
    return int(round(os.path.getsize(fn) / 1024.0))

def get_file_cell(prefix, ext, have):
    if have:
        kb = get_size(prefix, ext)
        return FILE_TEMPLATE % (release, prefix, release, ext, kb)
    else:
        return NO_FILE_TEMPLATE

for name, prefix in PKG_TYPES:
    zip_fn = "%s-%s.zip" % (prefix, release)
    tgz_fn = "%s-%s.tgz" % (prefix, release)
    bz2_fn = "%s-%s.tar.bz2" % (prefix, release)

    have_zip = isfile(zip_fn)
    have_tgz = isfile(tgz_fn)
    have_bz2 = isfile(bz2_fn)

    if have_zip or have_tgz or have_bz2:
        print "    <tr><td>%s</td>" % name

        print get_file_cell(prefix, ".zip", have_zip)
        print get_file_cell(prefix, ".tgz", have_tgz)
        print get_file_cell(prefix, ".tar.bz2", have_bz2)

        print "      </tr>"

print '''\
    </tbody>
</table>
'''