#!/usr/local/bin/python1.5 # -*- python -*- import httplib, sys, time, os, re, string, stat libsource = '/doc/lib/lib.html' tocfile = os.path.expanduser('~skip/public_html/python/libtoc.html') def get_lib_toc(): if os.path.exists(tocfile): timestamp = os.stat(tocfile)[stat.ST_MTIME] else: timestamp = 0 httpobj = httplib.HTTP('www.python.org', 80) httpobj.putrequest('GET', libsource) httpobj.putheader('If-Modified-Since', time.strftime('%a, %d %b %Y %X GMT', time.localtime(timestamp))) httpobj.putheader('Accept', 'text/html') httpobj.endheaders() reply, msg, hdrs = httpobj.getreply() if reply == 200: return httpobj.getfile().readlines() else: return [] def compare(s,t): s = string.lower(s[0][0]) t = string.lower(t[0][0]) if s < t: return -1 if s > t: return 1 return 0 def main(): mpat = re.compile(' *HREF="([^"]*)">' ']*>[0-9]+\.]*>[0-9]+' ' +([^<]*) --', re.I) lines = get_lib_toc() if lines: modules = [] for line in lines: m = mpat.match(string.strip(line)) if m is not None: modules.append(map(string.strip, map(m.group, [2, 1]))) if not modules: print "Error! No lines in the library manual matched!" return out = open(tocfile, 'w') out.write("""
Extracted from the Python Library Reference Manual.
Updated: %s
| %s\n" % string.upper(left[i])) out.write(" | \n")
out.write("
| %s\n" % string.upper(right[i])) out.write(" | \n")
out.write("
| \n") out.write(""" | |||
|---|---|---|---|---|---|---|---|
Last Modified: %s """ % (time.strftime('%a, %d %b %Y %X GMT', time.localtime(time.time())))) if __name__ == '__main__': main()