mirror of
git://git.savannah.nongnu.org/eliot.git
synced 2024-12-28 09:58:15 +01:00
6fbd7febb0
The reports are already usable, but the statistics report could be improved.
32 lines
900 B
Python
Executable file
32 lines
900 B
Python
Executable file
#!/usr/bin/env python
|
|
|
|
import os
|
|
import sys
|
|
import argparse
|
|
from Cheetah.Template import Template
|
|
|
|
# Eliot modules
|
|
import eliot
|
|
|
|
|
|
# Command-line parsing
|
|
parser = argparse.ArgumentParser(description="""Generate an HTML page roughly equivalent to the Statistics window in Eliot""")
|
|
parser.add_argument("-s", "--savegame", help="game saved with Eliot", type=file, required=True)
|
|
parser.add_argument("-o", "--output", help="output file (stdout by default)",
|
|
type=argparse.FileType('w'), default=sys.stdout)
|
|
args = parser.parse_args()
|
|
|
|
# Do most of the work: open the save game file, parse it,
|
|
# and build easy to use data structures
|
|
gameData = eliot.readSaveGame(args.savegame.name)
|
|
|
|
# Load the template
|
|
with file("stats.tmpl") as f:
|
|
templDef = f.read()
|
|
|
|
# Fill it with values
|
|
templ = Template(templDef, {'gameData': gameData})
|
|
|
|
# Print the generated document
|
|
args.output.write(str(templ));
|
|
|