Merge branch 'master' of git://git.assembla.com/fpdboz.git

This commit is contained in:
Eric Blade 2010-09-20 05:23:18 -04:00
commit e579d047d6
2 changed files with 31 additions and 16 deletions

View File

@ -56,7 +56,7 @@ class Hand(object):
# Class Variables # Class Variables
UPS = {'a':'A', 't':'T', 'j':'J', 'q':'Q', 'k':'K', 'S':'s', 'C':'c', 'H':'h', 'D':'d'} UPS = {'a':'A', 't':'T', 'j':'J', 'q':'Q', 'k':'K', 'S':'s', 'C':'c', 'H':'h', 'D':'d'}
LCS = {'H':'h', 'D':'d', 'C':'c', 'S':'s'} LCS = {'H':'h', 'D':'d', 'C':'c', 'S':'s'}
SYMBOL = {'USD': '$', 'EUR': u'$', 'T$': '', 'play': ''} SYMBOL = {'USD': '$', 'EUR': u'$', 'GBP': '$', 'T$': '', 'play': ''}
MS = {'horse' : 'HORSE', '8game' : '8-Game', 'hose' : 'HOSE', 'ha': 'HA'} MS = {'horse' : 'HORSE', '8game' : '8-Game', 'hose' : 'HOSE', 'ha': 'HA'}

View File

@ -22,6 +22,18 @@ import sys
import datetime import datetime
from HandHistoryConverter import * from HandHistoryConverter import *
import locale
lang=locale.getdefaultlocale()[0][0:2]
if lang=="en":
def _(string): return string
else:
import gettext
try:
trans = gettext.translation("fpdb", localedir="locale", languages=[lang])
trans.install()
except IOError:
def _(string): return string
# Win2day HH Format # Win2day HH Format
class Win2day(HandHistoryConverter): class Win2day(HandHistoryConverter):
@ -88,8 +100,10 @@ class Win2day(HandHistoryConverter):
m = self.re_GameInfo.search(handText) m = self.re_GameInfo.search(handText)
if not m: if not m:
print "determineGameType:", handText tmp = handText[0:100]
return None log.error(_("determineGameType: Unable to recognise gametype from: '%s'") % tmp)
log.error(_("determineGameType: Raising FpdbParseError"))
raise FpdbParseError(_("Unable to recognise gametype from: '%s'") % tmp)
mg = m.groupdict() mg = m.groupdict()
@ -98,7 +112,8 @@ class Win2day(HandHistoryConverter):
limits = { 'NL':'nl', 'PL':'pl'} limits = { 'NL':'nl', 'PL':'pl'}
games = { # base, category games = { # base, category
"GAME_THM" : ('hold','holdem'), "GAME_THM" : ('hold','holdem'),
# 'Omaha' : ('hold','omahahi'), "GAME_OMA" : ('hold','omahahi'),
#'Omaha Hi/Lo' : ('hold','omahahilo'), #'Omaha Hi/Lo' : ('hold','omahahilo'),
# 'Razz' : ('stud','razz'), # 'Razz' : ('stud','razz'),
#'7 Card Stud' : ('stud','studhi'), #'7 Card Stud' : ('stud','studhi'),
@ -182,15 +197,15 @@ class Win2day(HandHistoryConverter):
if street in ('FLOP','TURN','RIVER'): # a list of streets which get dealt community cards (i.e. all but PREFLOP) if street in ('FLOP','TURN','RIVER'): # a list of streets which get dealt community cards (i.e. all but PREFLOP)
#print "DEBUG readCommunityCards:", street, hand.streets.group(street) #print "DEBUG readCommunityCards:", street, hand.streets.group(street)
boardCards = set([]) boardCards = []
if street == 'FLOP': if street == 'FLOP':
m = self.re_Card.findall(hand.streets[street]) m = self.re_Card.findall(hand.streets[street])
for card in m: for card in m:
boardCards.add(self.convertWin2dayCards(card)) boardCards.append(self.convertWin2dayCards(card))
else: else:
m = self.re_BoardLast.search(hand.streets[street]) m = self.re_BoardLast.search(hand.streets[street])
boardCards.add(self.convertWin2dayCards(m.group('CARD'))) boardCards.append(self.convertWin2dayCards(m.group('CARD')))
hand.setCommunityCards(street, boardCards) hand.setCommunityCards(street, boardCards)
def readAntes(self, hand): def readAntes(self, hand):
@ -225,7 +240,7 @@ class Win2day(HandHistoryConverter):
for found in m: for found in m:
hand.hero = found.group('PNAME') hand.hero = found.group('PNAME')
for card in self.re_Card.finditer(found.group('CARDS')): for card in self.re_Card.finditer(found.group('CARDS')):
print self.convertWin2dayCards(card.group('CARD')) #print self.convertWin2dayCards(card.group('CARD'))
newcards.append(self.convertWin2dayCards(card.group('CARD'))) newcards.append(self.convertWin2dayCards(card.group('CARD')))
#hand.addHoleCards(holeCards, m.group('PNAME')) #hand.addHoleCards(holeCards, m.group('PNAME'))
@ -267,13 +282,13 @@ class Win2day(HandHistoryConverter):
newcards = player.group('NEWCARDS') newcards = player.group('NEWCARDS')
oldcards = player.group('OLDCARDS') oldcards = player.group('OLDCARDS')
if newcards == None: if newcards == None:
newcards = set() newcards = []
else: else:
newcards = set(newcards.split(' ')) newcards = newcards.split(' ')
if oldcards == None: if oldcards == None:
oldcards = set() oldcards = []
else: else:
oldcards = set(oldcards.split(' ')) oldcards = oldcards.split(' ')
hand.addDrawHoleCards(newcards, oldcards, player.group('PNAME'), street) hand.addDrawHoleCards(newcards, oldcards, player.group('PNAME'), street)
@ -337,10 +352,10 @@ class Win2day(HandHistoryConverter):
def readShowdownActions(self, hand): def readShowdownActions(self, hand):
for shows in self.re_ShowdownAction.finditer(hand.handText): for shows in self.re_ShowdownAction.finditer(hand.handText):
showdownCards = set([]) showdownCards = []
for card in self.re_Card.finditer(shows.group('CARDS')): for card in self.re_Card.finditer(shows.group('CARDS')):
#print "DEBUG:", card, card.group('CARD'), self.convertWin2dayCards(card.group('CARD')) #print "DEBUG:", card, card.group('CARD'), self.convertWin2dayCards(card.group('CARD'))
showdownCards.add(self.convertWin2dayCards(card.group('CARD'))) showdownCards.append(self.convertWin2dayCards(card.group('CARD')))
hand.addShownCards(showdownCards, shows.group('PNAME')) hand.addShownCards(showdownCards, shows.group('PNAME'))
@ -354,7 +369,7 @@ class Win2day(HandHistoryConverter):
for m in self.re_ShownCards.finditer(hand.handText): for m in self.re_ShownCards.finditer(hand.handText):
if m.group('CARDS') is not None: if m.group('CARDS') is not None:
cards = m.group('CARDS') cards = m.group('CARDS')
cards = set(cards.split(' ')) cards = cards.split(' ')
hand.addShownCards(cards=cards, player=m.group('PNAME')) hand.addShownCards(cards=cards, player=m.group('PNAME'))
if __name__ == "__main__": if __name__ == "__main__":