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.
This commit is contained in:
Mika Bostrom 2009-08-12 10:00:23 +03:00
parent 89dccac169
commit 185f9660c5

View File

@ -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)