From 185f9660c5535d6da03fb3aa44de38d208d47a2d Mon Sep 17 00:00:00 2001 From: Mika Bostrom Date: Wed, 12 Aug 2009 10:00:23 +0300 Subject: [PATCH] Use same locale conversion everywhere It is not enough to use actual system locale in just one spot if all the other encodings are hard-coded to latin1. Now that we have the real locale available, do all string conversions [.encode($locale)] with that. --- pyfpdb/fpdb_simple.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/pyfpdb/fpdb_simple.py b/pyfpdb/fpdb_simple.py index 1c3e7bc4..c12d38ca 100644 --- a/pyfpdb/fpdb_simple.py +++ b/pyfpdb/fpdb_simple.py @@ -546,7 +546,7 @@ def parseActionType(line): #parses the ante out of the given line and checks which player paid it, updates antes accordingly. def parseAnteLine(line, isTourney, names, antes): for i, name in enumerate(names): - if line.startswith(name.encode("latin-1")): + if line.startswith(name.encode(encoding)): pos = line.rfind("$") + 1 if not isTourney: antes[i] += float2int(line[pos:]) @@ -825,7 +825,7 @@ def parseTourneyNo(topline): def parseWinLine(line, names, winnings, isTourney): #print "parseWinLine: line:",line for i,n in enumerate(names): - n = n.encode("latin-1") + n = n.encode(encoding) if line.startswith(n): if isTourney: pos1 = line.rfind("collected ") + 10 @@ -1036,13 +1036,13 @@ def recognisePlayerNo(line, names, atype): #print "recogniseplayerno, names:",names for i in xrange(len(names)): if (atype=="unbet"): - if (line.endswith(names[i].encode("latin-1"))): + if (line.endswith(names[i].encode(encoding))): return (i) elif (line.startswith("Dealt to ")): #print "recognisePlayerNo, card precut, line:",line tmp=line[9:] #print "recognisePlayerNo, card postcut, tmp:",tmp - if (tmp.startswith(names[i].encode("latin-1"))): + if (tmp.startswith(names[i].encode(encoding))): return (i) elif (line.startswith("Seat ")): if (line.startswith("Seat 10")): @@ -1050,10 +1050,10 @@ def recognisePlayerNo(line, names, atype): else: tmp=line[8:] - if (tmp.startswith(names[i].encode("latin-1"))): + if (tmp.startswith(names[i].encode(encoding))): return (i) else: - if (line.startswith(names[i].encode("latin-1"))): + if (line.startswith(names[i].encode(encoding))): return (i) #if we're here we mustve failed raise FpdbError ("failed to recognise player in: "+line+" atype:"+atype)