1 | #!python |
---|
2 | # This script generates a table of dependencies in HTML format on stdout. |
---|
3 | # It expects to be run in the tahoe-lafs-dep-eggs directory. |
---|
4 | |
---|
5 | import re, os, sys |
---|
6 | |
---|
7 | extensions = ('.egg', '.tar.bz2', '.tar.gz', '.exe') |
---|
8 | platform_aliases = [('i686','x86'), ('i386','x86'), ('i86pc','x86'), ('win32','windows-x86'), |
---|
9 | ('win-amd64','windows-x86_64'), ('amd64','x86_64')] |
---|
10 | python_versions = ((2,4), (2,5), (2,6), (2,7)) |
---|
11 | FILENAME_RE = re.compile(r'([a-zA-Z_0-9]*)-([0-9\.]*)(-py[0-9\.]*)?(-.*)?') |
---|
12 | FILENAME_RE2 = re.compile(r'([a-zA-Z_0-9]*)-([0-9\.]*)(win32|win-amd64)?(-py[0-9\.]*)?') |
---|
13 | |
---|
14 | matrix = {} |
---|
15 | |
---|
16 | depdir = '.' |
---|
17 | if len(sys.argv) >= 1: |
---|
18 | depdir = sys.argv[1] |
---|
19 | |
---|
20 | filenames = os.listdir(depdir) |
---|
21 | |
---|
22 | def add(d, k, v): |
---|
23 | if k in d: |
---|
24 | d[k] += [v] |
---|
25 | else: |
---|
26 | d[k] = [v] |
---|
27 | |
---|
28 | for fname in filenames: |
---|
29 | for ext in extensions: |
---|
30 | if fname.endswith(ext): |
---|
31 | m = FILENAME_RE.match(fname[:-len(ext)]) |
---|
32 | try: |
---|
33 | pkg = m.group(1) |
---|
34 | pythonver = (m.group(3) or '-py')[3:] |
---|
35 | platform = (m.group(4) or '-')[1:] |
---|
36 | except (IndexError, AttributeError, TypeError): |
---|
37 | continue |
---|
38 | |
---|
39 | if not pythonver: |
---|
40 | m = FILENAME_RE2.match(fname[:-len(ext)]) |
---|
41 | if m.group(3): |
---|
42 | try: |
---|
43 | platform = m.group(3) |
---|
44 | pythonver = (m.group(4) or '-py')[3:] |
---|
45 | except (IndexError, AttributeError, TypeError): |
---|
46 | continue |
---|
47 | |
---|
48 | for (alias, replacement) in platform_aliases: |
---|
49 | if platform.endswith(alias): |
---|
50 | platform = platform[:-len(alias)] + replacement |
---|
51 | break |
---|
52 | |
---|
53 | add(matrix, (pkg, platform), (pythonver, fname)) |
---|
54 | break |
---|
55 | |
---|
56 | print '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">' |
---|
57 | print '<html>' |
---|
58 | print '<head>' |
---|
59 | print ' <meta http-equiv="Content-Type" content="text/html;charset=us-ascii">' |
---|
60 | print ' <title>Software packages that Tahoe-LAFS depends on</title>' |
---|
61 | print '</head>' |
---|
62 | print '<body>' |
---|
63 | print '<h2>Software packages that Tahoe-LAFS depends on</h2>' |
---|
64 | print |
---|
65 | print '<p>Packages that have compiled C/C++ code:</p>' |
---|
66 | print '<table border="1">' |
---|
67 | print ' <tr>' |
---|
68 | print ' <th colspan=2 style="background-color: #FFFFD0"> Package </th>' |
---|
69 | for pyver in python_versions: |
---|
70 | print ' <th style="background-color:#FFE8FF;"> Python %d.%d </th>' % pyver |
---|
71 | print ' </tr>' |
---|
72 | |
---|
73 | platform_dependent_pkgs = set() |
---|
74 | |
---|
75 | last_pkg = None |
---|
76 | for (pkg, platform) in sorted(matrix): |
---|
77 | if platform: |
---|
78 | platform_dependent_pkgs.add(pkg) |
---|
79 | row_files = sorted(matrix[(pkg, platform)]) |
---|
80 | style1 = pkg != last_pkg and 'border-top: 2px solid #000000; background-color: #FFFFF0' or 'border: 0;' |
---|
81 | style2 = pkg != last_pkg and 'border-top: 2px solid #000000; background-color: #FFFFF0' or 'background-color: #FFFFF0;' |
---|
82 | style3 = pkg != last_pkg and 'border-top: 2px solid #000000;' or '' |
---|
83 | print ' <tr>' |
---|
84 | print ' <th style="%s"> %s </th>' % (style1, pkg != last_pkg and pkg or '',) |
---|
85 | print ' <td style="%s"> %s </td>' % (style2, platform,) |
---|
86 | for pyver in python_versions: |
---|
87 | files = [n for (v, n) in row_files if v == '%d.%d' % pyver] |
---|
88 | print ' <td style="%s"> %s</td>' % (style3, |
---|
89 | '<br> '.join(['<a href="%s">%s</a>' % (f, f) for f in files])) |
---|
90 | print ' </tr>' |
---|
91 | last_pkg = pkg |
---|
92 | |
---|
93 | print '</table>' |
---|
94 | print |
---|
95 | print '<p>Packages that are platform-independent or source-only:</p>' |
---|
96 | print '<table border="1">' |
---|
97 | print ' <tr>' |
---|
98 | print ' <th style="background-color:#FFFFD0;"> Package </th>' |
---|
99 | print ' <th style="background-color:#FFE8FF;"> All Python versions </th>' |
---|
100 | print ' </tr>' |
---|
101 | |
---|
102 | style1 = 'border-top: 2px solid #000000; background-color:#FFFFF0;' |
---|
103 | style2 = 'border-top: 2px solid #000000;' |
---|
104 | for (pkg, platform) in sorted(matrix): |
---|
105 | if pkg not in platform_dependent_pkgs: |
---|
106 | print ' <tr>' |
---|
107 | print ' <th style="%s"> %s </th>' % (style1, pkg) |
---|
108 | files = [n for (v, n) in sorted(matrix[(pkg, platform)]) if not v] |
---|
109 | print ' <td style="%s"> %s</td>' % (style2, '<br> '.join(['<a href="%s">%s</a>' % (f, f) for f in files])) |
---|
110 | print ' </tr>' |
---|
111 | |
---|
112 | print '</table>' |
---|
113 | |
---|
114 | # The document does validate, but not when it is included at the bottom of a directory listing. |
---|
115 | #print '<hr>' |
---|
116 | #print '<a href="http://validator.w3.org/check?uri=referer" target="_blank"><img border="0" src="http://www.w3.org/Icons/valid-html401-blue" alt="Valid HTML 4.01 Transitional" height="31" width="88"></a>' |
---|
117 | print '</body></html>' |
---|