[Stats Index script Karthik Arumugham **20071012170354 statsindex.py: A Python script to generate a directory index for a clue server's web statistics directory. ] { addfile ./Vanilla/scripts/statsindex.py hunk ./Vanilla/scripts/statsindex.py 1 - +#!/usr/bin/env python + +import os, time + +TIMEFORMAT = "%a, %b %d %Y" # Fri, Oct 12 2007 +TIMEOFFSET = 4800 # 80 minutes (60 regulation + 20 overtime) + +def dirtimecomp(a, b): + return b[1][8] - a[1][8] + +dirs = [] +for f in os.listdir('.'): + if f.find("-vs-") == -1: + continue + dirs += [[f, os.stat(f)]] +dirs.sort(dirtimecomp) + +print "Clue Game Statistics" +print "

Clue Game Statistics

" +print "

" +print "
" + +for d in dirs: + url = d[0].replace("?", "%3f") + name, score = d[0].rsplit(" (", 1) + score = score.replace(")", "") + date = time.strftime(TIMEFORMAT, time.localtime(d[1][8] - TIMEOFFSET)) + print "" % (date, url, name, score) + +print "
Game DateHome Team -vs- Away TeamScore
%s%s%s
" }