From 38ad49bf38d77d5af54e7e8320c6e953fbf51013 Mon Sep 17 00:00:00 2001 From: gimick Date: Sun, 6 Jun 2010 21:06:04 +0100 Subject: [PATCH] Write Anonymise output to .anon file, rather than the terminal --- pyfpdb/Anonymise.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/pyfpdb/Anonymise.py b/pyfpdb/Anonymise.py index 512980e0..1d9fd63e 100644 --- a/pyfpdb/Anonymise.py +++ b/pyfpdb/Anonymise.py @@ -4,6 +4,7 @@ import codecs import Options import HandHistoryConverter import Configuration +import sys (options, argv) = Options.fpdb_options() config = Configuration.Config() @@ -27,6 +28,13 @@ else: m = hhc.re_PlayerInfo.finditer(filecontents) +outfile = options.infile+".anon" +print "Output being written to", outfile + +savestdout = sys.stdout +fsock = open(outfile,"w") +sys.stdout = fsock + players = [] for a in m: players = players + [a.group('PNAME')] @@ -37,3 +45,7 @@ for i, name in enumerate(uniq): filecontents = filecontents.replace(name, 'Player%d' %i) print filecontents + +sys.stdout = savestdout +fsock.close() +