- From: Cameron McCormack <cam@mcc.id.au>
- Date: Sat, 13 Jan 2007 19:09:31 +1100
- To: public-appformats@w3.org
Ian Hickson: > Sometimes more details are given using the "Status:" line after the > "Summary:" line. > > If you want more information, please download Anne's script: > > http://dev.w3.org/cvsweb/~checkout~/2006/xbl2/disposition-of-comments2html.py > > ...and make it do what you want! :-) It'd be really cool if someone hacked > that script to make it download the first mail from each "Thread" block > and automatically filled in the disposition of comments from things like > the "From" or "Subject" fields of the e-mail in the archive. I did that > for the CSSWG disposition of comments once, but that was in perl. My Python’s not very good, but below is a patch that fetches the first mail from the thread and puts the Author and Subject into the generated HTML. It only works with messages in lists.w3.org, though (which is nearly all of them). --- /tmp/doc2html.ps 2007-01-13 18:59:57.000000000 +1100 +++ /tmp/disposition-of-comments2html.py 2007-01-13 19:05:07.000000000 +1100 @@ -9,6 +9,7 @@ import sys; import re; +import urllib; def createHyperlink(link): template = """<a href="%s">%s</a>""" @@ -29,15 +30,37 @@ %s </ul> """ result = "" + author = "" + subject = "" n = 0 while lines[i + n].startswith(" http://") or lines[i + n].startswith(" data:"): + if n == 0: + url = lines[i + n][3:] + if url.startswith("http"): + author, subject = getMailDetails(url) result += getListItem(lines[i + n]) n += 1 - result = template % result + if author != "": + author = " <p>Commentor: %s</p>\n" % author + if subject != "": + subject = " <p>Subject: %s</p>\n" % subject + result = author + subject + (template % result) if not lines[i + n].startswith("\n"): result += " <p><strong>%s</strong></p>" % lines[i + n] return result +def getMailDetails(url): + author = "" + subject = "" + f = urllib.urlopen(url) + for line in f: + if line.startswith('<meta name="Author" content="'): + author = line.split('"')[3] + if line.startswith('<meta name="Subject" content="'): + subject = line.split('"')[3] + break + return [author, subject] + def formatComment(lines, i): # XXX This needs cleaning up. A lot! @@ -100,4 +123,10 @@ """ return template % formatComments(input) +class NoAuthURLOpener(urllib.FancyURLopener): + def prompt_user_passwd(a,b,c): + return ['', ''] + +urllib._urlopener = NoAuthURLOpener() + sys.stdout.write(dispositionOfComments(sys.stdin.read().splitlines())) -- Cameron McCormack, http://mcc.id.au/ xmpp:heycam@jabber.org ▪ ICQ 26955922 ▪ MSN cam@mcc.id.au
Received on Saturday, 13 January 2007 08:09:38 UTC