Write Anonymise output to .anon file, rather than the terminal

This commit is contained in:
gimick 2010-06-06 21:06:04 +01:00
parent fb51ea03f7
commit 38ad49bf38

View File

@ -4,6 +4,7 @@ import codecs
import Options import Options
import HandHistoryConverter import HandHistoryConverter
import Configuration import Configuration
import sys
(options, argv) = Options.fpdb_options() (options, argv) = Options.fpdb_options()
config = Configuration.Config() config = Configuration.Config()
@ -27,6 +28,13 @@ else:
m = hhc.re_PlayerInfo.finditer(filecontents) 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 = [] players = []
for a in m: for a in m:
players = players + [a.group('PNAME')] players = players + [a.group('PNAME')]
@ -37,3 +45,7 @@ for i, name in enumerate(uniq):
filecontents = filecontents.replace(name, 'Player%d' %i) filecontents = filecontents.replace(name, 'Player%d' %i)
print filecontents print filecontents
sys.stdout = savestdout
fsock.close()