Source

utils / stats2gtable.py

import sys
import os

fh = open(sys.argv[1])

content = fh.readlines()

sep = '   +------------------------------------+------------+------------+'

print ".. table:: **Stats for %s**" % os.path.basename(sys.argv[1])
print
print sep
print '   |                                    |   number   |  %         |'
print sep
for line in content[5:17]:
  f = line.split(':')
  v = f[1].split()
  if len(v) == 1:
    v.append('')
  print '   |%-36s|%-12s|%-12s|' % (f[0], v[0], v[1])
  print sep