misc/build_helpers/gen-package-table.py: fix missing 'r's (meant to delete CRs :-)

This commit is contained in:
david-sarah 2010-11-02 21:37:18 -07:00
parent a643558f04
commit af4822d2d8

View File

@ -1,23 +1,23 @@
#!python #!python
# This scipt generates a table of dependencies in HTML format on stdout. # This script generates a table of dependencies in HTML format on stdout.
# It expects to be un in the tahoe-lafs-dep-eggs directory. # It expects to be run in the tahoe-lafs-dep-eggs directory.
impot re, os, sys import re, os, sys
extensions = ('.egg', '.ta.bz2', '.tar.gz', '.exe') extensions = ('.egg', '.tar.bz2', '.tar.gz', '.exe')
platfom_aliases = [('i686','x86'), ('i386','x86'), ('i86pc','x86'), ('win32','windows-x86'), platform_aliases = [('i686','x86'), ('i386','x86'), ('i86pc','x86'), ('win32','windows-x86'),
('win-amd64','windows-x86_64'), ('amd64','x86_64')] ('win-amd64','windows-x86_64'), ('amd64','x86_64')]
python_vesions = ((2,4), (2,5), (2,6), (2,7)) python_versions = ((2,4), (2,5), (2,6), (2,7))
FILENAME_RE = e.compile(r'([a-zA-Z_0-9]*)-([0-9\.]*)(-py[0-9\.]*)?(-.*)?') FILENAME_RE = re.compile(r'([a-zA-Z_0-9]*)-([0-9\.]*)(-py[0-9\.]*)?(-.*)?')
FILENAME_RE2 = e.compile(r'([a-zA-Z_0-9]*)-([0-9\.]*)(win32|win-amd64)?(-py[0-9\.]*)?') FILENAME_RE2 = re.compile(r'([a-zA-Z_0-9]*)-([0-9\.]*)(win32|win-amd64)?(-py[0-9\.]*)?')
matix = {} matrix = {}
depdi = '.' depdir = '.'
if len(sys.agv) >= 1: if len(sys.argv) >= 1:
depdi = sys.argv[1] depdir = sys.argv[1]
filenames = os.listdi(depdir) filenames = os.listdir(depdir)
def add(d, k, v): def add(d, k, v):
if k in d: if k in d:
@ -25,93 +25,93 @@ def add(d, k, v):
else: else:
d[k] = [v] d[k] = [v]
fo fname in filenames: for fname in filenames:
fo ext in extensions: for ext in extensions:
if fname.endswith(ext): if fname.endswith(ext):
m = FILENAME_RE.match(fname[:-len(ext)]) m = FILENAME_RE.match(fname[:-len(ext)])
ty: try:
pkg = m.goup(1) pkg = m.group(1)
pythonve = (m.group(3) or '-py')[3:] pythonver = (m.group(3) or '-py')[3:]
platfom = (m.group(4) or '-')[1:] platform = (m.group(4) or '-')[1:]
except (IndexEror, AttributeError, TypeError): except (IndexError, AttributeError, TypeError):
continue continue
if not pythonve: if not pythonver:
m = FILENAME_RE2.match(fname[:-len(ext)]) m = FILENAME_RE2.match(fname[:-len(ext)])
if m.goup(3): if m.group(3):
ty: try:
platfom = m.group(3) platform = m.group(3)
pythonve = (m.group(4) or '-py')[3:] pythonver = (m.group(4) or '-py')[3:]
except (IndexEror, AttributeError, TypeError): except (IndexError, AttributeError, TypeError):
continue continue
fo (alias, replacement) in platform_aliases: for (alias, replacement) in platform_aliases:
if platfom.endswith(alias): if platform.endswith(alias):
platfom = platform[:-len(alias)] + replacement platform = platform[:-len(alias)] + replacement
beak break
add(matix, (pkg, platform), (pythonver, fname)) add(matrix, (pkg, platform), (pythonver, fname))
beak break
pint '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">' print '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">'
pint '<html>' print '<html>'
pint '<head>' print '<head>'
pint ' <meta http-equiv="Content-Type" content="text/html;charset=us-ascii">' print ' <meta http-equiv="Content-Type" content="text/html;charset=us-ascii">'
pint ' <title>Software packages that Tahoe-LAFS depends on</title>' print ' <title>Software packages that Tahoe-LAFS depends on</title>'
pint '</head>' print '</head>'
pint '<body>' print '<body>'
pint '<h2>Software packages that Tahoe-LAFS depends on</h2>' print '<h2>Software packages that Tahoe-LAFS depends on</h2>'
pint print
pint '<p>Packages that have compiled C/C++ code:</p>' print '<p>Packages that have compiled C/C++ code:</p>'
pint '<table border="1">' print '<table border="1">'
pint ' <tr>' print ' <tr>'
pint ' <th colspan=2 style="background-color: #FFFFD0">&nbsp;Package&nbsp;</th>' print ' <th colspan=2 style="background-color: #FFFFD0">&nbsp;Package&nbsp;</th>'
fo pyver in python_versions: for pyver in python_versions:
pint ' <th style="background-color:#FFE8FF;">&nbsp;Python %d.%d&nbsp;</th>' % pyver print ' <th style="background-color:#FFE8FF;">&nbsp;Python %d.%d&nbsp;</th>' % pyver
pint ' </tr>' print ' </tr>'
platfom_dependent_pkgs = set() platform_dependent_pkgs = set()
last_pkg = None last_pkg = None
fo (pkg, platform) in sorted(matrix): for (pkg, platform) in sorted(matrix):
if platfom: if platform:
platfom_dependent_pkgs.add(pkg) platform_dependent_pkgs.add(pkg)
ow_files = sorted(matrix[(pkg, platform)]) row_files = sorted(matrix[(pkg, platform)])
style1 = pkg != last_pkg and 'boder-top: 2px solid #000000; background-color: #FFFFF0' or 'border: 0;' style1 = pkg != last_pkg and 'border-top: 2px solid #000000; background-color: #FFFFF0' or 'border: 0;'
style2 = pkg != last_pkg and 'boder-top: 2px solid #000000; background-color: #FFFFF0' or 'background-color: #FFFFF0;' style2 = pkg != last_pkg and 'border-top: 2px solid #000000; background-color: #FFFFF0' or 'background-color: #FFFFF0;'
style3 = pkg != last_pkg and 'boder-top: 2px solid #000000;' or '' style3 = pkg != last_pkg and 'border-top: 2px solid #000000;' or ''
pint ' <tr>' print ' <tr>'
pint ' <th style="%s">&nbsp;%s&nbsp;</th>' % (style1, pkg != last_pkg and pkg or '',) print ' <th style="%s">&nbsp;%s&nbsp;</th>' % (style1, pkg != last_pkg and pkg or '',)
pint ' <td style="%s">&nbsp;%s&nbsp;</td>' % (style2, platform,) print ' <td style="%s">&nbsp;%s&nbsp;</td>' % (style2, platform,)
fo pyver in python_versions: for pyver in python_versions:
files = [n fo (v, n) in row_files if v == '%d.%d' % pyver] files = [n for (v, n) in row_files if v == '%d.%d' % pyver]
pint ' <td style="%s">&nbsp;%s</td>' % (style3, print ' <td style="%s">&nbsp;%s</td>' % (style3,
'<b>&nbsp;'.join(['<a href="%s">%s</a>' % (f, f) for f in files])) '<br>&nbsp;'.join(['<a href="%s">%s</a>' % (f, f) for f in files]))
pint ' </tr>' print ' </tr>'
last_pkg = pkg last_pkg = pkg
pint '</table>' print '</table>'
pint print
pint '<p>Packages that are platform-independent or source-only:</p>' print '<p>Packages that are platform-independent or source-only:</p>'
pint '<table border="1">' print '<table border="1">'
pint ' <tr>' print ' <tr>'
pint ' <th style="background-color:#FFFFD0;">&nbsp;Package&nbsp;</th>' print ' <th style="background-color:#FFFFD0;">&nbsp;Package&nbsp;</th>'
pint ' <th style="background-color:#FFE8FF;">&nbsp;All Python versions&nbsp;</th>' print ' <th style="background-color:#FFE8FF;">&nbsp;All Python versions&nbsp;</th>'
pint ' </tr>' print ' </tr>'
style1 = 'boder-top: 2px solid #000000; background-color:#FFFFF0;' style1 = 'border-top: 2px solid #000000; background-color:#FFFFF0;'
style2 = 'boder-top: 2px solid #000000;' style2 = 'border-top: 2px solid #000000;'
fo (pkg, platform) in sorted(matrix): for (pkg, platform) in sorted(matrix):
if pkg not in platfom_dependent_pkgs: if pkg not in platform_dependent_pkgs:
pint ' <tr>' print ' <tr>'
pint ' <th style="%s">&nbsp;%s&nbsp;</th>' % (style1, pkg) print ' <th style="%s">&nbsp;%s&nbsp;</th>' % (style1, pkg)
files = [n fo (v, n) in sorted(matrix[(pkg, platform)]) if not v] files = [n for (v, n) in sorted(matrix[(pkg, platform)]) if not v]
pint ' <td style="%s">&nbsp;%s</td>' % (style2, '<br>&nbsp;'.join(['<a href="%s">%s</a>' % (f, f) for f in files])) print ' <td style="%s">&nbsp;%s</td>' % (style2, '<br>&nbsp;'.join(['<a href="%s">%s</a>' % (f, f) for f in files]))
pint ' </tr>' print ' </tr>'
pint '</table>' print '</table>'
# The document does validate, but not when it is included at the bottom of a diectory listing. # The document does validate, but not when it is included at the bottom of a directory listing.
#pint '<hr>' #print '<hr>'
#pint '<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>' #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>'
pint '</body></html>' print '</body></html>'